From 8e93134008292f4916cc63f7c5b92663a2b9f2e4 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Thu, 9 May 2019 08:37:58 +0000 Subject: [PATCH] [MergeICmps][NFC] Re-generate tests with update_test_checks. And use a more compact name for the tested struct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360319 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../MergeICmps/X86/alias-merge-blocks.ll | 31 ++++--- test/Transforms/MergeICmps/X86/atomic.ll | 22 ++--- .../MergeICmps/X86/entry-block-shuffled.ll | 45 ++++++++--- test/Transforms/MergeICmps/X86/gep-used-outside.ll | 35 ++++++-- test/Transforms/MergeICmps/X86/int64-and-ptr.ll | 1 + .../MergeICmps/X86/last-block-produce-no-value.ll | 26 +++--- test/Transforms/MergeICmps/X86/lit.local.cfg | 1 - .../MergeICmps/X86/multiple-blocks-does-work.ll | 54 ++++++++----- test/Transforms/MergeICmps/X86/pair-int32-int32.ll | 53 ++++++------ .../MergeICmps/X86/split-block-does-work.ll | 94 ++++++++++++++-------- test/Transforms/MergeICmps/X86/two-complex-bb.ll | 26 +++--- test/Transforms/MergeICmps/X86/volatile.ll | 23 +++--- 12 files changed, 243 insertions(+), 168 deletions(-) diff --git a/test/Transforms/MergeICmps/X86/alias-merge-blocks.ll b/test/Transforms/MergeICmps/X86/alias-merge-blocks.ll index dfb369ca0f2..fa4af66e639 100644 --- a/test/Transforms/MergeICmps/X86/alias-merge-blocks.ll +++ b/test/Transforms/MergeICmps/X86/alias-merge-blocks.ll @@ -1,14 +1,15 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mtriple=x86_64-unknown-unknown -mergeicmps -S | FileCheck %s --check-prefix=X86 -%"struct.std::pair" = type { i32, i32, i32, i32 } +%S = type { i32, i32, i32, i32 } +define zeroext i1 @opeq1( ; X86-LABEL: @opeq1( ; X86-NEXT: entry: ; X86-NEXT: [[PTR:%.*]] = alloca i32 ; X86-NEXT: store i32 42, i32* [[PTR]] -; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 -; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[FIRST_I]] to i8* ; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[FIRST1_I]] to i8* ; X86-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 16) @@ -17,17 +18,15 @@ ; X86: opeq1.exit: ; X86-NEXT: [[TMP1:%.*]] = phi i1 [ [[TMP0]], [[ENTRY:%.*]] ] ; X86-NEXT: ret i1 [[TMP1]] - -define zeroext i1 @opeq1( - - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { +; + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: %ptr = alloca i32 - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 ; Does other work, has no interference, merge block store i32 42, i32* %ptr @@ -35,25 +34,25 @@ entry: br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp2.i = icmp eq i32 %2, %3 br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit land.rhs.i.2: - %third.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 2 + %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 2 %4 = load i32, i32* %third.i, align 4 - %third2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 2 + %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 2 %5 = load i32, i32* %third2.i, align 4 %cmp3.i = icmp eq i32 %4, %5 br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit land.rhs.i.3: - %fourth.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 3 + %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3 %6 = load i32, i32* %fourth.i, align 4 - %fourth2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %7 = load i32, i32* %fourth2.i, align 4 %cmp4.i = icmp eq i32 %6, %7 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/atomic.ll b/test/Transforms/MergeICmps/X86/atomic.ll index 8893373ca7b..8a7e25e594c 100644 --- a/test/Transforms/MergeICmps/X86/atomic.ll +++ b/test/Transforms/MergeICmps/X86/atomic.ll @@ -1,21 +1,21 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s -%"struct.std::pair" = type { i32, i32 } +%S = type { i32, i32 } define zeroext i1 @opeq( ; CHECK-LABEL: @opeq( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; CHECK: land.rhs.i: -; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 ; CHECK-NEXT: [[TMP2:%.*]] = load atomic i32, i32* [[SECOND_I]] seq_cst, align 4 -; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; CHECK-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] ; CHECK-NEXT: br label [[OPEQ1_EXIT]] @@ -23,20 +23,20 @@ define zeroext i1 @opeq( ; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] ; CHECK-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(8) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(8) %a, + %S* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load atomic i32, i32* %second.i seq_cst, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/entry-block-shuffled.ll b/test/Transforms/MergeICmps/X86/entry-block-shuffled.ll index 4e9d97d0eba..f416fa451eb 100644 --- a/test/Transforms/MergeICmps/X86/entry-block-shuffled.ll +++ b/test/Transforms/MergeICmps/X86/entry-block-shuffled.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s -%"struct.std::pair" = type { i32, i32, i32, i32 } +%S = type { i32, i32, i32, i32 } ; The entry block is part of the chain. It however can not be merged. We need to make the ; first comparison block in the chain the new entry block of the function. @@ -9,43 +9,62 @@ define zeroext i1 @opeq1( ; CHECK-LABEL: @opeq1( ; CHECK-NEXT: br label [[LAND_RHS_I:%.*]] +; CHECK: entry: +; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 3 +; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST_I]], align 4 +; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 2 +; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[FIRST1_I]], align 4 +; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP1]], [[TMP2]] +; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I_3:%.*]], label [[OPEQ1_EXIT:%.*]] ; CHECK: land.rhs.i: -; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 -; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 +; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 0 +; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 0 ; CHECK-NEXT: [[CSTR:%.*]] = bitcast i32* [[SECOND_I]] to i8* ; CHECK-NEXT: [[CSTR1:%.*]] = bitcast i32* [[SECOND2_I]] to i8* ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 8) +; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[MEMCMP]], 0 +; CHECK-NEXT: br i1 [[TMP3]], label [[ENTRY:%.*]], label [[OPEQ1_EXIT]] +; CHECK: land.rhs.i.3: +; CHECK-NEXT: [[FOURTH_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 3 +; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* [[FOURTH_I]], align 4 +; CHECK-NEXT: [[FOURTH2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 3 +; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[FOURTH2_I]], align 4 +; CHECK-NEXT: [[CMP5_I:%.*]] = icmp eq i32 [[TMP4]], [[TMP5]] +; CHECK-NEXT: br label [[OPEQ1_EXIT]] +; CHECK: opeq1.exit: +; CHECK-NEXT: [[TMP6:%.*]] = phi i1 [ false, [[LAND_RHS_I]] ], [ false, [[ENTRY]] ], [ [[CMP5_I]], [[LAND_RHS_I_3]] ] +; CHECK-NEXT: ret i1 [[TMP6]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 3 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 2 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 2 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br i1 %cmp3.i, label %land.rhs.i.2, label %opeq1.exit land.rhs.i.2: - %third.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %4 = load i32, i32* %third.i, align 4 - %third2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %5 = load i32, i32* %third2.i, align 4 %cmp4.i = icmp eq i32 %4, %5 br i1 %cmp4.i, label %land.rhs.i.3, label %opeq1.exit land.rhs.i.3: - %fourth.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 3 + %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3 %6 = load i32, i32* %fourth.i, align 4 - %fourth2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %7 = load i32, i32* %fourth2.i, align 4 %cmp5.i = icmp eq i32 %6, %7 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/gep-used-outside.ll b/test/Transforms/MergeICmps/X86/gep-used-outside.ll index 9c944d52500..1fc1644cdcd 100644 --- a/test/Transforms/MergeICmps/X86/gep-used-outside.ll +++ b/test/Transforms/MergeICmps/X86/gep-used-outside.ll @@ -1,29 +1,48 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s -%"struct.std::pair" = type { i32, i32 } +%S = type { i32, i32 } ; Check that the transformation is avoided when GEP has a use outside of the ; parant block of the load instruction. define zeroext i32 @opeq1( ; CHECK-LABEL: @opeq1( -; CHECK-NOT: [[MEMCMP:%.*]] = call i32 @memcmp +; CHECK-NEXT: entry: +; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 1 +; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 +; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 1 +; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 +; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] +; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] +; CHECK: land.rhs.i: +; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 0 +; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 +; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 0 +; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 +; CHECK-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] +; CHECK-NEXT: br label [[OPEQ1_EXIT]] +; CHECK: opeq1.exit: +; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] +; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[FIRST_I]], align 4 +; CHECK-NEXT: [[TMP6:%.*]] = select i1 [[TMP4]], i32 [[TMP5]], i32 0 +; CHECK-NEXT: ret i32 [[TMP6]] +; - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/int64-and-ptr.ll b/test/Transforms/MergeICmps/X86/int64-and-ptr.ll index 2526d1b8162..28e499539e1 100644 --- a/test/Transforms/MergeICmps/X86/int64-and-ptr.ll +++ b/test/Transforms/MergeICmps/X86/int64-and-ptr.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mtriple=x86_64-unknown-unknown -mergeicmps -S | FileCheck %s --check-prefix=X86 ; 8-byte int and 8-byte pointer should merge into a 16-byte memcmp. diff --git a/test/Transforms/MergeICmps/X86/last-block-produce-no-value.ll b/test/Transforms/MergeICmps/X86/last-block-produce-no-value.ll index 302b3912c4d..0b8428ad5cd 100644 --- a/test/Transforms/MergeICmps/X86/last-block-produce-no-value.ll +++ b/test/Transforms/MergeICmps/X86/last-block-produce-no-value.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s -%"struct.std::pair" = type { i32, i32, i32 } +%S = type { i32, i32, i32 } ; Last block does not produce the non-constant value into the phi. ; We could handle this case, but an easier way would be to allow other transformations such as @@ -11,39 +11,39 @@ define zeroext i1 @opeq1( ; CHECK-LABEL: @opeq1( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; CHECK: land.rhs.i: -; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 -; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; CHECK-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] -; CHECK-NEXT: br i1 [[CMP3_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] +; CHECK-NEXT: br i1 [[CMP3_I]], label [[LAND_RHS_I_2:%.*]], label [[OPEQ1_EXIT]] ; CHECK: land.rhs.i.2: ; CHECK-NEXT: br label [[OPEQ1_EXIT]] ; CHECK: opeq1.exit: -; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] +; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ false, [[LAND_RHS_I]] ], [ [[CMP3_I]], [[LAND_RHS_I_2]] ] ; CHECK-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(12) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(12) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(12) %a, + %S* nocapture readonly dereferenceable(12) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br i1 %cmp3.i, label %land.rhs.i.2, label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/lit.local.cfg b/test/Transforms/MergeICmps/X86/lit.local.cfg index e71f3cc4c41..c8625f4d9d2 100644 --- a/test/Transforms/MergeICmps/X86/lit.local.cfg +++ b/test/Transforms/MergeICmps/X86/lit.local.cfg @@ -1,3 +1,2 @@ if not 'X86' in config.root.targets: config.unsupported = True - diff --git a/test/Transforms/MergeICmps/X86/multiple-blocks-does-work.ll b/test/Transforms/MergeICmps/X86/multiple-blocks-does-work.ll index 7fee119616b..790c0e9854d 100644 --- a/test/Transforms/MergeICmps/X86/multiple-blocks-does-work.ll +++ b/test/Transforms/MergeICmps/X86/multiple-blocks-does-work.ll @@ -1,31 +1,47 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s --check-prefix=X86 -%"struct.std::pair" = type { i32, i32, i32, i32 } +%S = type { i32, i32, i32, i32 } declare void @foo(...) ; We can discard %entry and %land.rhs.i, but still merge the last 2 blocks. define zeroext i1 @opeq1( ; X86-LABEL: @opeq1( -; X86: land.rhs.i.2: -; X86-NEXT: [[THIRD_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 2 -; X86-NEXT: [[THIRD1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 2 +; X86-NEXT: entry: +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 +; X86-NEXT: call void (...) @foo() +; X86-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] +; X86-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] +; X86: land.rhs.i: +; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 +; X86-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 +; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 +; X86-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 +; X86-NEXT: call void (...) @foo() +; X86-NEXT: [[CMP2_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] +; X86-NEXT: br i1 [[CMP2_I]], label [[LAND_RHS_I_2:%.*]], label [[OPEQ1_EXIT]] +; X86: land.rhs.i.2: +; X86-NEXT: [[THIRD_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 2 +; X86-NEXT: [[THIRD2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 2 ; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[THIRD_I]] to i8* -; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[THIRD1_I]] to i8* +; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[THIRD2_I]] to i8* ; X86-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 8) -; X86-NEXT: [[TMP0:%.*]] = icmp eq i32 [[MEMCMP]], 0 -; X86-NEXT: br label [[OPEQ1_EXIT:%.*]] +; X86-NEXT: [[TMP4:%.*]] = icmp eq i32 [[MEMCMP]], 0 +; X86-NEXT: br label [[OPEQ1_EXIT]] ; X86: opeq1.exit: -; X86-NEXT: [[TMP1:%.*]] = phi i1 [ false, %entry ], [ false, %land.rhs.i ], [ [[TMP0]], %land.rhs.i.2 ] -; X86-NEXT: ret i1 [[TMP1]] +; X86-NEXT: [[TMP5:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ false, [[LAND_RHS_I]] ], [ [[TMP4]], [[LAND_RHS_I_2]] ] +; X86-NEXT: ret i1 [[TMP5]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 ; Does other work. call void (...) @foo() @@ -33,9 +49,9 @@ entry: br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 ; Does other work. call void (...) @foo() @@ -43,17 +59,17 @@ land.rhs.i: br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit land.rhs.i.2: - %third.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 2 + %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 2 %4 = load i32, i32* %third.i, align 4 - %third2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 2 + %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 2 %5 = load i32, i32* %third2.i, align 4 %cmp3.i = icmp eq i32 %4, %5 br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit land.rhs.i.3: - %fourth.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 3 + %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3 %6 = load i32, i32* %fourth.i, align 4 - %fourth2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %7 = load i32, i32* %fourth2.i, align 4 %cmp4.i = icmp eq i32 %6, %7 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/pair-int32-int32.ll b/test/Transforms/MergeICmps/X86/pair-int32-int32.ll index 37201fa3956..13f2f4874d8 100644 --- a/test/Transforms/MergeICmps/X86/pair-int32-int32.ll +++ b/test/Transforms/MergeICmps/X86/pair-int32-int32.ll @@ -2,13 +2,13 @@ ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s --check-prefix=X86 ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S -disable-simplify-libcalls | FileCheck %s --check-prefix=X86-NOBUILTIN -%"struct.std::pair" = type { i32, i32 } +%S = type { i32, i32 } define zeroext i1 @opeq1( ; X86-LABEL: @opeq1( ; X86-NEXT: entry: -; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 -; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[FIRST_I]] to i8* ; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[FIRST1_I]] to i8* ; X86-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 8) @@ -20,16 +20,16 @@ define zeroext i1 @opeq1( ; ; X86-NOBUILTIN-LABEL: @opeq1( ; X86-NOBUILTIN-NEXT: entry: -; X86-NOBUILTIN-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 +; X86-NOBUILTIN-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 ; X86-NOBUILTIN-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; X86-NOBUILTIN-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; X86-NOBUILTIN-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; X86-NOBUILTIN-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; X86-NOBUILTIN-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; X86-NOBUILTIN-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; X86-NOBUILTIN: land.rhs.i: -; X86-NOBUILTIN-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 1 +; X86-NOBUILTIN-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 ; X86-NOBUILTIN-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 -; X86-NOBUILTIN-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 1 +; X86-NOBUILTIN-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 ; X86-NOBUILTIN-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; X86-NOBUILTIN-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] ; X86-NOBUILTIN-NEXT: br label [[OPEQ1_EXIT]] @@ -37,20 +37,20 @@ define zeroext i1 @opeq1( ; X86-NOBUILTIN-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] ; X86-NOBUILTIN-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(8) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(8) %a, + %S* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br label %opeq1.exit @@ -69,8 +69,8 @@ define zeroext i1 @opeq1_inverse( ; X86-LABEL: @opeq1_inverse( ; X86-NEXT: br label [[LAND_RHS_I:%.*]] ; X86: land.rhs.i: -; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 -; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[SECOND_I]] to i8* ; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[SECOND2_I]] to i8* ; X86-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 8) @@ -82,16 +82,16 @@ define zeroext i1 @opeq1_inverse( ; ; X86-NOBUILTIN-LABEL: @opeq1_inverse( ; X86-NOBUILTIN-NEXT: entry: -; X86-NOBUILTIN-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 1 +; X86-NOBUILTIN-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 1 ; X86-NOBUILTIN-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; X86-NOBUILTIN-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 1 +; X86-NOBUILTIN-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 1 ; X86-NOBUILTIN-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; X86-NOBUILTIN-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; X86-NOBUILTIN-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; X86-NOBUILTIN: land.rhs.i: -; X86-NOBUILTIN-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 0 +; X86-NOBUILTIN-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 0 ; X86-NOBUILTIN-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 -; X86-NOBUILTIN-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 0 +; X86-NOBUILTIN-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 0 ; X86-NOBUILTIN-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; X86-NOBUILTIN-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] ; X86-NOBUILTIN-NEXT: br label [[OPEQ1_EXIT]] @@ -99,20 +99,20 @@ define zeroext i1 @opeq1_inverse( ; X86-NOBUILTIN-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] ; X86-NOBUILTIN-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(8) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(8) %a, + %S* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br label %opeq1.exit @@ -126,6 +126,3 @@ opeq1.exit: ; The branch is now a direct branch; the other block has been removed. ; The phi is updated. } - - - diff --git a/test/Transforms/MergeICmps/X86/split-block-does-work.ll b/test/Transforms/MergeICmps/X86/split-block-does-work.ll index d4f4c94323f..91ef9b1622c 100644 --- a/test/Transforms/MergeICmps/X86/split-block-does-work.ll +++ b/test/Transforms/MergeICmps/X86/split-block-does-work.ll @@ -1,31 +1,33 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s --check-prefix=X86 -%"struct.std::pair" = type { i32, i32, i32, i32 } +%S = type { i32, i32, i32, i32 } declare void @foo(...) nounwind readnone ; We can split %entry and create a memcmp(16 bytes). define zeroext i1 @opeq1( ; X86-LABEL: @opeq1( -; -; Make sure this call is moved to the beginning of the entry block. -; X86: entry: +; X86-NEXT: entry: ; X86-NEXT: call void (...) @foo() -; X86-NEXT: [[THIRD_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 -; X86-NEXT: [[THIRD1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 -; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[THIRD_I]] to i8* -; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[THIRD1_I]] to i8* +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[CSTR:%.*]] = bitcast i32* [[FIRST_I]] to i8* +; X86-NEXT: [[CSTR1:%.*]] = bitcast i32* [[FIRST1_I]] to i8* ; X86-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR1]], i64 16) ; X86-NEXT: [[TMP0:%.*]] = icmp eq i32 [[MEMCMP]], 0 ; X86-NEXT: br label [[OPEQ1_EXIT:%.*]] +; X86: opeq1.exit: +; X86-NEXT: [[TMP1:%.*]] = phi i1 [ [[TMP0]], [[ENTRY:%.*]] ] +; X86-NEXT: ret i1 [[TMP1]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { +; Make sure this call is moved to the beginning of the entry block. + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 ; Does other work. call void (...) @foo() @@ -33,25 +35,25 @@ entry: br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp2.i = icmp eq i32 %2, %3 br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit land.rhs.i.2: - %third.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 2 + %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 2 %4 = load i32, i32* %third.i, align 4 - %third2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 2 + %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 2 %5 = load i32, i32* %third2.i, align 4 %cmp3.i = icmp eq i32 %4, %5 br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit land.rhs.i.3: - %fourth.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 3 + %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3 %6 = load i32, i32* %fourth.i, align 4 - %fourth2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %7 = load i32, i32* %fourth2.i, align 4 %cmp4.i = icmp eq i32 %6, %7 br label %opeq1.exit @@ -65,18 +67,46 @@ opeq1.exit: ; We will not be able to merge anything, make sure the call is not moved out. define zeroext i1 @opeq1_discontiguous( ; X86-LABEL: @opeq1_discontiguous( +; X86-NEXT: entry: +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 1 +; X86-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 +; X86-NEXT: call void (...) @foo() +; X86-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] +; X86-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] +; X86: land.rhs.i: +; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 2 +; X86-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 +; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 +; X86-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 +; X86-NEXT: [[CMP2_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] +; X86-NEXT: br i1 [[CMP2_I]], label [[LAND_RHS_I_2:%.*]], label [[OPEQ1_EXIT]] +; X86: land.rhs.i.2: +; X86-NEXT: [[THIRD_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 2 +; X86-NEXT: [[TMP4:%.*]] = load i32, i32* [[THIRD_I]], align 4 +; X86-NEXT: [[THIRD2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 3 +; X86-NEXT: [[TMP5:%.*]] = load i32, i32* [[THIRD2_I]], align 4 +; X86-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP4]], [[TMP5]] +; X86-NEXT: br i1 [[CMP3_I]], label [[LAND_RHS_I_3:%.*]], label [[OPEQ1_EXIT]] +; X86: land.rhs.i.3: +; X86-NEXT: [[FOURTH_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 +; X86-NEXT: [[TMP6:%.*]] = load i32, i32* [[FOURTH_I]], align 4 +; X86-NEXT: [[FOURTH2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 3 +; X86-NEXT: [[TMP7:%.*]] = load i32, i32* [[FOURTH2_I]], align 4 +; X86-NEXT: [[CMP4_I:%.*]] = icmp eq i32 [[TMP6]], [[TMP7]] +; X86-NEXT: br label [[OPEQ1_EXIT]] +; X86: opeq1.exit: +; X86-NEXT: [[TMP8:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ false, [[LAND_RHS_I]] ], [ false, [[LAND_RHS_I_2]] ], [ [[CMP4_I]], [[LAND_RHS_I_3]] ] +; X86-NEXT: ret i1 [[TMP8]] ; ; Make sure this call is moved in the entry block. -; X86: entry: -; X86: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 1 -; X86: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 -; X86: call void (...) @foo() - %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(16) %a, + %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 ; Does other work. call void (...) @foo() @@ -84,25 +114,25 @@ entry: br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 2 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 2 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp2.i = icmp eq i32 %2, %3 br i1 %cmp2.i, label %land.rhs.i.2, label %opeq1.exit land.rhs.i.2: - %third.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 2 + %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 2 %4 = load i32, i32* %third.i, align 4 - %third2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %5 = load i32, i32* %third2.i, align 4 %cmp3.i = icmp eq i32 %4, %5 br i1 %cmp3.i, label %land.rhs.i.3, label %opeq1.exit land.rhs.i.3: - %fourth.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %6 = load i32, i32* %fourth.i, align 4 - %fourth2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 3 + %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3 %7 = load i32, i32* %fourth2.i, align 4 %cmp4.i = icmp eq i32 %6, %7 br label %opeq1.exit diff --git a/test/Transforms/MergeICmps/X86/two-complex-bb.ll b/test/Transforms/MergeICmps/X86/two-complex-bb.ll index 945a2d076f6..b0659450e2b 100644 --- a/test/Transforms/MergeICmps/X86/two-complex-bb.ll +++ b/test/Transforms/MergeICmps/X86/two-complex-bb.ll @@ -1,23 +1,23 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s --check-prefix=X86 -%"struct.std::pair" = type { i32, i32 } +%S = type { i32, i32 } ; This tests a function with two complex basic blocks. define zeroext i1 @twocomplexblocks( ; X86-LABEL: @twocomplexblocks( ; X86-NEXT: entry: -; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 ; X86-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; X86-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; X86-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; X86-NEXT: [[EXTRAWORK:%.*]] = add i32 [[TMP0]], [[TMP1]] ; X86-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; X86-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; X86: land.rhs.i: -; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 1 +; X86-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 ; X86-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4 -; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 1 +; X86-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 ; X86-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; X86-NEXT: [[EXTRAWORK2:%.*]] = add i32 [[TMP2]], [[TMP3]] ; X86-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] @@ -26,13 +26,13 @@ define zeroext i1 @twocomplexblocks( ; X86-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] ; X86-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(8) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(8) %a, + %S* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { entry: ; This is a complex BCE Basic Block. - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 %extrawork = add i32 %0, %1 %cmp.i = icmp eq i32 %0, %1 @@ -40,9 +40,9 @@ entry: land.rhs.i: ; This is a complex BCE Basic Block. - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %extrawork2 = add i32 %2, %3 %cmp3.i = icmp eq i32 %2, %3 @@ -52,7 +52,3 @@ opeq1.exit: %4 = phi i1 [ false, %entry ], [ %cmp3.i, %land.rhs.i ] ret i1 %4 } - - - - diff --git a/test/Transforms/MergeICmps/X86/volatile.ll b/test/Transforms/MergeICmps/X86/volatile.ll index 3e9af6c1d8b..43f87e0241f 100644 --- a/test/Transforms/MergeICmps/X86/volatile.ll +++ b/test/Transforms/MergeICmps/X86/volatile.ll @@ -1,21 +1,21 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s -%"struct.std::pair" = type { i32, i32 } +%S = type { i32, i32 } define zeroext i1 @opeq( ; CHECK-LABEL: @opeq( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4 -; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B:%.*]], i64 0, i32 0 +; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]] ; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]] ; CHECK: land.rhs.i: -; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[A]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1 ; CHECK-NEXT: [[TMP2:%.*]] = load volatile i32, i32* [[SECOND_I]], align 4 -; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* [[B]], i64 0, i32 1 +; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4 ; CHECK-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]] ; CHECK-NEXT: br label [[OPEQ1_EXIT]] @@ -23,20 +23,20 @@ define zeroext i1 @opeq( ; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ] ; CHECK-NEXT: ret i1 [[TMP4]] ; - %"struct.std::pair"* nocapture readonly dereferenceable(8) %a, - %"struct.std::pair"* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { + %S* nocapture readonly dereferenceable(8) %a, + %S* nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 { entry: - %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 + %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0 %0 = load i32, i32* %first.i, align 4 - %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 + %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0 %1 = load i32, i32* %first1.i, align 4 %cmp.i = icmp eq i32 %0, %1 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit land.rhs.i: - %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 + %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1 %2 = load volatile i32, i32* %second.i, align 4 - %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 + %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1 %3 = load i32, i32* %second2.i, align 4 %cmp3.i = icmp eq i32 %2, %3 br label %opeq1.exit @@ -45,4 +45,3 @@ opeq1.exit: %4 = phi i1 [ false, %entry ], [ %cmp3.i, %land.rhs.i ] ret i1 %4 } - -- 2.11.0