summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r--test/Transforms/InstCombine/2002-05-14-SubFailure.ll5
-rw-r--r--test/Transforms/InstCombine/2002-12-05-MissedConstProp.ll4
-rw-r--r--test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll5
-rw-r--r--test/Transforms/InstCombine/2006-10-20-mask.ll4
-rw-r--r--test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll5
-rw-r--r--test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll3
-rw-r--r--test/Transforms/InstCombine/2007-01-27-AndICmp.ll4
-rw-r--r--test/Transforms/InstCombine/2008-01-06-BitCastAttributes.ll25
-rw-r--r--test/Transforms/InstCombine/2008-01-06-VoidCast.ll10
-rw-r--r--test/Transforms/InstCombine/2008-01-27-FloatSelect.ll3
-rw-r--r--test/Transforms/InstCombine/2008-02-13-MulURem.ll4
-rw-r--r--test/Transforms/InstCombine/2008-05-31-AddBool.ll4
-rw-r--r--test/Transforms/InstCombine/2008-11-20-DivMulRem.ll12
-rw-r--r--test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll2
-rw-r--r--test/Transforms/InstCombine/2010-03-03-ExtElim.ll20
-rw-r--r--test/Transforms/InstCombine/2010-11-01-lshr-mask.ll4
-rw-r--r--test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll4
-rw-r--r--test/Transforms/InstCombine/2010-11-23-Distributed.ll4
-rw-r--r--test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll4
-rw-r--r--test/Transforms/InstCombine/2012-03-10-InstCombine.ll2
-rw-r--r--test/Transforms/InstCombine/2012-04-24-vselect.ll2
-rw-r--r--test/Transforms/InstCombine/2012-05-28-select-hang.ll2
-rw-r--r--test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll4
-rw-r--r--test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll8
-rw-r--r--test/Transforms/InstCombine/2012-09-17-ZeroSizedAlloca.ll2
-rw-r--r--test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll2
-rw-r--r--test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll2
-rw-r--r--test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll2
-rw-r--r--test/Transforms/InstCombine/ExtractCast.ll4
-rw-r--r--test/Transforms/InstCombine/LandingPadClauses.ll6
-rw-r--r--test/Transforms/InstCombine/PR7357.ll17
-rw-r--r--test/Transforms/InstCombine/abs-1.ll6
-rw-r--r--test/Transforms/InstCombine/add2.ll8
-rw-r--r--test/Transforms/InstCombine/add4.ll45
-rw-r--r--test/Transforms/InstCombine/addrspacecast.ll69
-rw-r--r--test/Transforms/InstCombine/align-addr.ll31
-rw-r--r--test/Transforms/InstCombine/align-external.ll2
-rw-r--r--test/Transforms/InstCombine/alloca.ll37
-rw-r--r--test/Transforms/InstCombine/and-xor-or.ll4
-rw-r--r--test/Transforms/InstCombine/and.ll6
-rw-r--r--test/Transforms/InstCombine/and2.ll18
-rw-r--r--test/Transforms/InstCombine/apint-call-cast-target.ll7
-rw-r--r--test/Transforms/InstCombine/apint-select.ll5
-rw-r--r--test/Transforms/InstCombine/apint-shift-simplify.ll6
-rw-r--r--test/Transforms/InstCombine/apint-shift.ll60
-rw-r--r--test/Transforms/InstCombine/apint-shl-trunc.ll4
-rw-r--r--test/Transforms/InstCombine/atomic.ll4
-rw-r--r--test/Transforms/InstCombine/badmalloc.ll4
-rw-r--r--test/Transforms/InstCombine/bitcast-alias-function.ll229
-rw-r--r--test/Transforms/InstCombine/bitcast-bigendian.ll45
-rw-r--r--test/Transforms/InstCombine/bitcast-vec-uniform.ll16
-rw-r--r--test/Transforms/InstCombine/bitcast-vector-fold.ll2
-rw-r--r--test/Transforms/InstCombine/bitcast.ll32
-rw-r--r--test/Transforms/InstCombine/call-cast-target.ll9
-rw-r--r--test/Transforms/InstCombine/call.ll222
-rw-r--r--test/Transforms/InstCombine/canonicalize_branch.ll8
-rw-r--r--test/Transforms/InstCombine/cast.ll147
-rw-r--r--test/Transforms/InstCombine/cast_ptr.ll55
-rw-r--r--test/Transforms/InstCombine/compare-signs.ll12
-rw-r--r--test/Transforms/InstCombine/constant-fold-address-space-pointer.ll232
-rw-r--r--test/Transforms/InstCombine/constant-fold-gep.ll22
-rw-r--r--test/Transforms/InstCombine/cos-1.ll6
-rw-r--r--test/Transforms/InstCombine/cos-2.ll2
-rw-r--r--test/Transforms/InstCombine/debug-line.ll16
-rw-r--r--test/Transforms/InstCombine/debuginfo.ll27
-rw-r--r--test/Transforms/InstCombine/disable-simplify-libcalls.ll74
-rw-r--r--test/Transforms/InstCombine/div-shift-crash.ll101
-rw-r--r--test/Transforms/InstCombine/div-shift.ll38
-rw-r--r--test/Transforms/InstCombine/div.ll30
-rw-r--r--test/Transforms/InstCombine/double-float-shrink-1.ll13
-rw-r--r--test/Transforms/InstCombine/enforce-known-alignment.ll26
-rw-r--r--test/Transforms/InstCombine/err-rep-cold.ll77
-rw-r--r--test/Transforms/InstCombine/exact.ll36
-rw-r--r--test/Transforms/InstCombine/exp2-1.ll16
-rw-r--r--test/Transforms/InstCombine/exp2-2.ll2
-rw-r--r--test/Transforms/InstCombine/extractvalue.ll6
-rw-r--r--test/Transforms/InstCombine/fast-math.ll84
-rw-r--r--test/Transforms/InstCombine/fcmp.ll32
-rw-r--r--test/Transforms/InstCombine/fdiv.ll6
-rw-r--r--test/Transforms/InstCombine/ffs-1.ll32
-rw-r--r--test/Transforms/InstCombine/float-shrink-compare.ll179
-rw-r--r--test/Transforms/InstCombine/fmul.ll37
-rw-r--r--test/Transforms/InstCombine/fneg-ext.ll23
-rw-r--r--test/Transforms/InstCombine/fold-bin-operand.ll4
-rw-r--r--test/Transforms/InstCombine/fold-calls.ll4
-rw-r--r--test/Transforms/InstCombine/fold-fops-into-selects.ll71
-rw-r--r--test/Transforms/InstCombine/fold-vector-select.ll4
-rw-r--r--test/Transforms/InstCombine/fpcast.ll12
-rw-r--r--test/Transforms/InstCombine/fprintf-1.ll16
-rw-r--r--test/Transforms/InstCombine/fputs-1.ll6
-rw-r--r--test/Transforms/InstCombine/fwrite-1.ll10
-rw-r--r--test/Transforms/InstCombine/gep-addrspace.ll2
-rw-r--r--test/Transforms/InstCombine/getelementptr.ll436
-rw-r--r--test/Transforms/InstCombine/icmp-logical.ll152
-rw-r--r--test/Transforms/InstCombine/icmp.ll604
-rw-r--r--test/Transforms/InstCombine/idioms.ll2
-rw-r--r--test/Transforms/InstCombine/intrinsics.ll40
-rw-r--r--test/Transforms/InstCombine/invoke.ll6
-rw-r--r--test/Transforms/InstCombine/isascii-1.ll6
-rw-r--r--test/Transforms/InstCombine/isdigit-1.ll10
-rw-r--r--test/Transforms/InstCombine/lit.local.cfg1
-rw-r--r--test/Transforms/InstCombine/load-cmp.ll334
-rw-r--r--test/Transforms/InstCombine/load-select.ll2
-rw-r--r--test/Transforms/InstCombine/load3.ll6
-rw-r--r--test/Transforms/InstCombine/malloc-free-delete.ll36
-rw-r--r--test/Transforms/InstCombine/memcmp-1.ll12
-rw-r--r--test/Transforms/InstCombine/memcmp-2.ll2
-rw-r--r--test/Transforms/InstCombine/memcpy-1.ll2
-rw-r--r--test/Transforms/InstCombine/memcpy-2.ll2
-rw-r--r--test/Transforms/InstCombine/memcpy-from-global.ll18
-rw-r--r--test/Transforms/InstCombine/memcpy.ll6
-rw-r--r--test/Transforms/InstCombine/memcpy_chk-1.ll8
-rw-r--r--test/Transforms/InstCombine/memcpy_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/memmove-1.ll2
-rw-r--r--test/Transforms/InstCombine/memmove-2.ll2
-rw-r--r--test/Transforms/InstCombine/memmove_chk-1.ll8
-rw-r--r--test/Transforms/InstCombine/memmove_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/memset-1.ll2
-rw-r--r--test/Transforms/InstCombine/memset-2.ll2
-rw-r--r--test/Transforms/InstCombine/memset_chk-1.ll10
-rw-r--r--test/Transforms/InstCombine/memset_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/merge-icmp.ll4
-rw-r--r--test/Transforms/InstCombine/mul.ll38
-rw-r--r--test/Transforms/InstCombine/multi-size-address-space-pointer.ll112
-rw-r--r--test/Transforms/InstCombine/no-negzero.ll2
-rw-r--r--test/Transforms/InstCombine/nsw.ll18
-rw-r--r--test/Transforms/InstCombine/objsize-64.ll4
-rw-r--r--test/Transforms/InstCombine/objsize-address-space.ll80
-rw-r--r--test/Transforms/InstCombine/objsize.ll92
-rw-r--r--test/Transforms/InstCombine/onehot_merge.ll35
-rw-r--r--test/Transforms/InstCombine/or-fcmp.ll10
-rw-r--r--test/Transforms/InstCombine/or-xor.ll18
-rw-r--r--test/Transforms/InstCombine/or.ll78
-rw-r--r--test/Transforms/InstCombine/osx-names.ll4
-rw-r--r--test/Transforms/InstCombine/overflow.ll14
-rw-r--r--test/Transforms/InstCombine/phi-select-constexpr.ll19
-rw-r--r--test/Transforms/InstCombine/phi.ll54
-rw-r--r--test/Transforms/InstCombine/pow-1.ll45
-rw-r--r--test/Transforms/InstCombine/pow-2.ll2
-rw-r--r--test/Transforms/InstCombine/pow-3.ll12
-rw-r--r--test/Transforms/InstCombine/pr17827.ll74
-rw-r--r--test/Transforms/InstCombine/pr8547.ll2
-rw-r--r--test/Transforms/InstCombine/printf-1.ll22
-rw-r--r--test/Transforms/InstCombine/printf-2.ll6
-rw-r--r--test/Transforms/InstCombine/ptr-int-cast.ll8
-rw-r--r--test/Transforms/InstCombine/puts-1.ll4
-rw-r--r--test/Transforms/InstCombine/rem.ll122
-rw-r--r--test/Transforms/InstCombine/select-2.ll5
-rw-r--r--test/Transforms/InstCombine/select-crash.ll4
-rw-r--r--test/Transforms/InstCombine/select-extractelement.ll102
-rw-r--r--test/Transforms/InstCombine/select.ll220
-rw-r--r--test/Transforms/InstCombine/sext.ll34
-rw-r--r--test/Transforms/InstCombine/shift-sra.ll10
-rw-r--r--test/Transforms/InstCombine/shift.ll187
-rw-r--r--test/Transforms/InstCombine/sign-test-and-or.ll18
-rw-r--r--test/Transforms/InstCombine/signext.ll16
-rw-r--r--test/Transforms/InstCombine/simplify-libcalls.ll144
-rw-r--r--test/Transforms/InstCombine/sincospi.ll91
-rw-r--r--test/Transforms/InstCombine/sink_instruction.ll4
-rw-r--r--test/Transforms/InstCombine/sprintf-1.ll18
-rw-r--r--test/Transforms/InstCombine/sqrt.ll6
-rw-r--r--test/Transforms/InstCombine/store.ll15
-rw-r--r--test/Transforms/InstCombine/stpcpy-1.ll6
-rw-r--r--test/Transforms/InstCombine/stpcpy-2.ll2
-rw-r--r--test/Transforms/InstCombine/stpcpy_chk-1.ll20
-rw-r--r--test/Transforms/InstCombine/stpcpy_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/strcat-1.ll2
-rw-r--r--test/Transforms/InstCombine/strcat-2.ll4
-rw-r--r--test/Transforms/InstCombine/strcat-3.ll2
-rw-r--r--test/Transforms/InstCombine/strchr-1.ll11
-rw-r--r--test/Transforms/InstCombine/strcmp-1.ll12
-rw-r--r--test/Transforms/InstCombine/strcmp-2.ll2
-rw-r--r--test/Transforms/InstCombine/strcpy-1.ll6
-rw-r--r--test/Transforms/InstCombine/strcpy-2.ll2
-rw-r--r--test/Transforms/InstCombine/strcpy_chk-1.ll20
-rw-r--r--test/Transforms/InstCombine/strcpy_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/strcpy_chk-64.ll2
-rw-r--r--test/Transforms/InstCombine/strcspn-1.ll8
-rw-r--r--test/Transforms/InstCombine/strcspn-2.ll2
-rw-r--r--test/Transforms/InstCombine/strlen-1.ll18
-rw-r--r--test/Transforms/InstCombine/strlen-2.ll2
-rw-r--r--test/Transforms/InstCombine/strncat-1.ll2
-rw-r--r--test/Transforms/InstCombine/strncat-2.ll8
-rw-r--r--test/Transforms/InstCombine/strncat-3.ll2
-rw-r--r--test/Transforms/InstCombine/strncmp-1.ll16
-rw-r--r--test/Transforms/InstCombine/strncmp-2.ll2
-rw-r--r--test/Transforms/InstCombine/strncpy-1.ll12
-rw-r--r--test/Transforms/InstCombine/strncpy-2.ll2
-rw-r--r--test/Transforms/InstCombine/strncpy_chk-1.ll10
-rw-r--r--test/Transforms/InstCombine/strncpy_chk-2.ll2
-rw-r--r--test/Transforms/InstCombine/strpbrk-1.ll10
-rw-r--r--test/Transforms/InstCombine/strpbrk-2.ll2
-rw-r--r--test/Transforms/InstCombine/strrchr-1.ll13
-rw-r--r--test/Transforms/InstCombine/strspn-1.ll8
-rw-r--r--test/Transforms/InstCombine/strstr-1.ll10
-rw-r--r--test/Transforms/InstCombine/strstr-2.ll2
-rw-r--r--test/Transforms/InstCombine/strto-1.ll30
-rw-r--r--test/Transforms/InstCombine/struct-assign-tbaa.ll8
-rw-r--r--test/Transforms/InstCombine/sub-xor.ll8
-rw-r--r--test/Transforms/InstCombine/sub.ll237
-rw-r--r--test/Transforms/InstCombine/toascii-1.ll14
-rw-r--r--test/Transforms/InstCombine/trunc.ll20
-rw-r--r--test/Transforms/InstCombine/udivrem-change-width.ll12
-rw-r--r--test/Transforms/InstCombine/vec_demanded_elts.ll18
-rw-r--r--test/Transforms/InstCombine/vec_extract_elt.ll3
-rw-r--r--test/Transforms/InstCombine/vec_insertelt.ll3
-rw-r--r--test/Transforms/InstCombine/vec_phi_extract.ll25
-rw-r--r--test/Transforms/InstCombine/vec_shuffle.ll105
-rw-r--r--test/Transforms/InstCombine/vector-casts.ll12
-rw-r--r--test/Transforms/InstCombine/vector-mul.ll408
-rw-r--r--test/Transforms/InstCombine/vector_gep2.ll2
-rw-r--r--test/Transforms/InstCombine/weak-symbols.ll4
-rw-r--r--test/Transforms/InstCombine/win-math.ll295
-rw-r--r--test/Transforms/InstCombine/xor2.ll14
-rw-r--r--test/Transforms/InstCombine/zext-bool-add-sub.ll2
215 files changed, 5915 insertions, 1519 deletions
diff --git a/test/Transforms/InstCombine/2002-05-14-SubFailure.ll b/test/Transforms/InstCombine/2002-05-14-SubFailure.ll
index d2b2b0027a52..854ec604d01a 100644
--- a/test/Transforms/InstCombine/2002-05-14-SubFailure.ll
+++ b/test/Transforms/InstCombine/2002-05-14-SubFailure.ll
@@ -1,7 +1,8 @@
; Instcombine was missing a test that caused it to make illegal transformations
; sometimes. In this case, it transforms the sub into an add:
-; RUN: opt < %s -instcombine -S | grep sub
-;
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: sub
+
define i32 @test(i32 %i, i32 %j) {
%A = mul i32 %i, %j
%B = sub i32 2, %A
diff --git a/test/Transforms/InstCombine/2002-12-05-MissedConstProp.ll b/test/Transforms/InstCombine/2002-12-05-MissedConstProp.ll
index 22574f77f1d9..49e55c620a49 100644
--- a/test/Transforms/InstCombine/2002-12-05-MissedConstProp.ll
+++ b/test/Transforms/InstCombine/2002-12-05-MissedConstProp.ll
@@ -1,4 +1,6 @@
-; RUN: opt < %s -instcombine -S | not grep add
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; CHECK-NOT: add
define i32 @test(i32 %A) {
%A.neg = sub i32 0, %A ; <i32> [#uses=1]
diff --git a/test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll b/test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll
index c02d33ccc1b7..bb9a8181ccd4 100644
--- a/test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll
+++ b/test/Transforms/InstCombine/2003-08-12-AllocaNonNull.ll
@@ -1,6 +1,7 @@
-; This testcase can be simplified by "realizing" that alloca can never return
+; This testcase can be simplified by "realizing" that alloca can never return
; null.
-; RUN: opt < %s -instcombine -simplifycfg -S | not grep br
+; RUN: opt < %s -instcombine -simplifycfg -S | FileCheck %s
+; CHECK-NOT: br
declare i32 @bitmap_clear(...)
diff --git a/test/Transforms/InstCombine/2006-10-20-mask.ll b/test/Transforms/InstCombine/2006-10-20-mask.ll
index 0aaa5e8c21b4..e9797ae50c95 100644
--- a/test/Transforms/InstCombine/2006-10-20-mask.ll
+++ b/test/Transforms/InstCombine/2006-10-20-mask.ll
@@ -1,5 +1,5 @@
-; RUN: opt < %s -instcombine -S | \
-; RUN: grep and
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: and
define i64 @foo(i64 %tmp, i64 %tmp2) {
%tmp.upgrd.1 = trunc i64 %tmp to i32 ; <i32> [#uses=1]
diff --git a/test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll b/test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll
index d3ba1e2287a3..8ab50e222745 100644
--- a/test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll
+++ b/test/Transforms/InstCombine/2006-10-26-VectorReassoc.ll
@@ -1,5 +1,6 @@
-; RUN: opt < %s -instcombine -S | \
-; RUN: grep mul | count 2
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: mul
+; CHECK: mul
define <4 x float> @test(<4 x float> %V) {
%Y = fmul <4 x float> %V, < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 > ; <<4 x float>> [#uses=1]
diff --git a/test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll b/test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll
index 2665791fe086..272753cc98d6 100644
--- a/test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll
+++ b/test/Transforms/InstCombine/2006-12-08-Select-ICmp.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -instcombine -S | grep select
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: select
; END.
target datalayout = "e-p:32:32"
diff --git a/test/Transforms/InstCombine/2007-01-27-AndICmp.ll b/test/Transforms/InstCombine/2007-01-27-AndICmp.ll
index 4d1b982f6766..6298a0723338 100644
--- a/test/Transforms/InstCombine/2007-01-27-AndICmp.ll
+++ b/test/Transforms/InstCombine/2007-01-27-AndICmp.ll
@@ -1,8 +1,8 @@
; RUN: opt < %s -instcombine -S | grep "ugt.*, 1"
define i1 @test(i32 %tmp1030) {
- %tmp1037 = icmp ne i32 %tmp1030, 40 ; <i1> [#uses=1]
- %tmp1039 = icmp ne i32 %tmp1030, 41 ; <i1> [#uses=1]
+ %tmp1037 = icmp ne i32 %tmp1030, 39 ; <i1> [#uses=1]
+ %tmp1039 = icmp ne i32 %tmp1030, 40 ; <i1> [#uses=1]
%tmp1042 = and i1 %tmp1037, %tmp1039 ; <i1> [#uses=1]
ret i1 %tmp1042
}
diff --git a/test/Transforms/InstCombine/2008-01-06-BitCastAttributes.ll b/test/Transforms/InstCombine/2008-01-06-BitCastAttributes.ll
index 23b606779e66..22c078250ece 100644
--- a/test/Transforms/InstCombine/2008-01-06-BitCastAttributes.ll
+++ b/test/Transforms/InstCombine/2008-01-06-BitCastAttributes.ll
@@ -1,23 +1,30 @@
; Ignore stderr, we expect warnings there
-; RUN: opt < %s -instcombine 2> /dev/null -S | not grep bitcast
+; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s
+
+; CHECK-NOT: bitcast
define void @a() {
- ret void
+ ret void
}
define signext i32 @b(i32* inreg %x) {
- ret i32 0
+ ret i32 0
}
define void @c(...) {
- ret void
+ ret void
}
define void @g(i32* %y) {
- call void bitcast (void ()* @a to void (i32*)*)( i32* noalias %y )
- call <2 x i32> bitcast (i32 (i32*)* @b to <2 x i32> (i32*)*)( i32* inreg null ) ; <<2 x i32>>:1 [#uses=0]
+; CHECK-LABEL: @g(
+; CHECK: call i64 bitcast (i32 (i32*)* @b to i64 (i32)*)(i32 0)
%x = call i64 bitcast (i32 (i32*)* @b to i64 (i32)*)( i32 0 ) ; <i64> [#uses=0]
- call void bitcast (void (...)* @c to void (i32)*)( i32 0 )
- call void bitcast (void (...)* @c to void (i32)*)( i32 zeroext 0 )
- ret void
+
+; The rest should not have bitcasts remaining
+; CHECK-NOT: bitcast
+ call void bitcast (void ()* @a to void (i32*)*)( i32* noalias %y )
+ call <2 x i32> bitcast (i32 (i32*)* @b to <2 x i32> (i32*)*)( i32* inreg null ) ; <<2 x i32>>:1 [#uses=0]
+ call void bitcast (void (...)* @c to void (i32)*)( i32 0 )
+ call void bitcast (void (...)* @c to void (i32)*)( i32 zeroext 0 )
+ ret void
}
diff --git a/test/Transforms/InstCombine/2008-01-06-VoidCast.ll b/test/Transforms/InstCombine/2008-01-06-VoidCast.ll
index 407ff4ddc29a..5dcaa38edc02 100644
--- a/test/Transforms/InstCombine/2008-01-06-VoidCast.ll
+++ b/test/Transforms/InstCombine/2008-01-06-VoidCast.ll
@@ -1,10 +1,12 @@
-; RUN: opt < %s -instcombine -S | not grep bitcast
+; RUN: opt < %s -instcombine -S | FileCheck %s
define void @f(i16 %y) {
- ret void
+ ret void
}
define i32 @g(i32 %y) {
- %x = call i32 bitcast (void (i16)* @f to i32 (i32)*)( i32 %y ) ; <i32> [#uses=1]
- ret i32 %x
+; CHECK-LABEL: @g(
+; CHECK: call i32 bitcast
+ %x = call i32 bitcast (void (i16)* @f to i32 (i32)*)( i32 %y ) ; <i32> [#uses=1]
+ ret i32 %x
}
diff --git a/test/Transforms/InstCombine/2008-01-27-FloatSelect.ll b/test/Transforms/InstCombine/2008-01-27-FloatSelect.ll
index c161bcc9045d..6b4e89dbbe60 100644
--- a/test/Transforms/InstCombine/2008-01-27-FloatSelect.ll
+++ b/test/Transforms/InstCombine/2008-01-27-FloatSelect.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -instcombine -S | grep select
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: select
define double @fold(i1 %a, double %b) {
%s = select i1 %a, double 0., double 1.
diff --git a/test/Transforms/InstCombine/2008-02-13-MulURem.ll b/test/Transforms/InstCombine/2008-02-13-MulURem.ll
index a88c51097247..d85ef97553ab 100644
--- a/test/Transforms/InstCombine/2008-02-13-MulURem.ll
+++ b/test/Transforms/InstCombine/2008-02-13-MulURem.ll
@@ -1,6 +1,8 @@
-; RUN: opt < %s -instcombine -S | grep rem
+; RUN: opt < %s -instcombine -S | FileCheck %s
; PR1933
+; CHECK: rem
+
define i32 @fold(i32 %a) {
%s = mul i32 %a, 3
%c = urem i32 %s, 3
diff --git a/test/Transforms/InstCombine/2008-05-31-AddBool.ll b/test/Transforms/InstCombine/2008-05-31-AddBool.ll
index ed2069041d1b..31b17196d8f5 100644
--- a/test/Transforms/InstCombine/2008-05-31-AddBool.ll
+++ b/test/Transforms/InstCombine/2008-05-31-AddBool.ll
@@ -1,6 +1,8 @@
-; RUN: opt < %s -instcombine -S | grep "xor"
+; RUN: opt < %s -instcombine -S | FileCheck %s
; PR2389
+; CHECK: xor
+
define i1 @test(i1 %a, i1 %b) {
%A = add i1 %a, %b
ret i1 %A
diff --git a/test/Transforms/InstCombine/2008-11-20-DivMulRem.ll b/test/Transforms/InstCombine/2008-11-20-DivMulRem.ll
index 43af190abcea..0c0e55a0b2d9 100644
--- a/test/Transforms/InstCombine/2008-11-20-DivMulRem.ll
+++ b/test/Transforms/InstCombine/2008-11-20-DivMulRem.ll
@@ -2,7 +2,7 @@
; PR3103
define i8 @test1(i8 %x, i8 %y) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
%A = udiv i8 %x, %y
; CHECK-NEXT: urem
%B = mul i8 %A, %y
@@ -12,7 +12,7 @@ define i8 @test1(i8 %x, i8 %y) {
}
define i8 @test2(i8 %x, i8 %y) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
%A = sdiv i8 %x, %y
; CHECK-NEXT: srem
%B = mul i8 %A, %y
@@ -22,7 +22,7 @@ define i8 @test2(i8 %x, i8 %y) {
}
define i8 @test3(i8 %x, i8 %y) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
%A = udiv i8 %x, %y
; CHECK-NEXT: urem
%B = mul i8 %A, %y
@@ -33,7 +33,7 @@ define i8 @test3(i8 %x, i8 %y) {
}
define i8 @test4(i8 %x) {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
%A = udiv i8 %x, 3
; CHECK-NEXT: urem
%B = mul i8 %A, -3
@@ -45,7 +45,7 @@ define i8 @test4(i8 %x) {
}
define i32 @test5(i32 %x, i32 %y) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; (((X / Y) * Y) / Y) -> X / Y
%div = sdiv i32 %x, %y
; CHECK-NEXT: sdiv
@@ -56,7 +56,7 @@ define i32 @test5(i32 %x, i32 %y) {
}
define i32 @test6(i32 %x, i32 %y) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; (((X / Y) * Y) / Y) -> X / Y
%div = udiv i32 %x, %y
; CHECK-NEXT: udiv
diff --git a/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll b/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll
index 949fc592203f..e3543116a666 100644
--- a/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll
+++ b/test/Transforms/InstCombine/2009-01-16-PointerAddrSpace.ll
@@ -5,7 +5,7 @@ target triple = "i386-apple-darwin9.6"
define i32 @test(i32* %P) nounwind {
entry:
- %Q = bitcast i32* %P to i32 addrspace(1)*
+ %Q = addrspacecast i32* %P to i32 addrspace(1)*
store i32 0, i32 addrspace(1)* %Q, align 4
ret i32 0
}
diff --git a/test/Transforms/InstCombine/2010-03-03-ExtElim.ll b/test/Transforms/InstCombine/2010-03-03-ExtElim.ll
index bb3159e1e6fa..b1384ec00209 100644
--- a/test/Transforms/InstCombine/2010-03-03-ExtElim.ll
+++ b/test/Transforms/InstCombine/2010-03-03-ExtElim.ll
@@ -1,5 +1,4 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
-; PR6486
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-unknown-linux-gnu"
@@ -7,8 +6,8 @@ target triple = "i386-unknown-linux-gnu"
@g_92 = common global [2 x i32*] zeroinitializer, align 4 ; <[2 x i32*]*> [#uses=1]
@g_177 = constant i32** bitcast (i8* getelementptr (i8* bitcast ([2 x i32*]* @g_92 to i8*), i64 4) to i32**), align 4 ; <i32***> [#uses=1]
-define i1 @test() nounwind {
-; CHECK: @test
+define i1 @PR6486() nounwind {
+; CHECK-LABEL: @PR6486(
%tmp = load i32*** @g_177 ; <i32**> [#uses=1]
%cmp = icmp ne i32** null, %tmp ; <i1> [#uses=1]
%conv = zext i1 %cmp to i32 ; <i32> [#uses=1]
@@ -16,3 +15,18 @@ define i1 @test() nounwind {
ret i1 %cmp1
; CHECK: ret i1 true
}
+
+@d = common global i32 0, align 4
+@a = common global [1 x i32] zeroinitializer, align 4
+
+define i1 @PR16462_1() nounwind {
+; CHECK-LABEL: @PR16462_1(
+ ret i1 icmp sgt (i32 sext (i16 trunc (i32 select (i1 icmp eq (i32* getelementptr inbounds ([1 x i32]* @a, i32 0, i32 0), i32* @d), i32 0, i32 1) to i16) to i32), i32 65535)
+; CHECK: ret i1 icmp sgt (i32 sext (i16 trunc (i32 select (i1 icmp eq (i32* getelementptr inbounds ([1 x i32]* @a, i32 0, i32 0), i32* @d), i32 0, i32 1) to i16) to i32), i32 65535)
+}
+
+define i1 @PR16462_2() nounwind {
+; CHECK-LABEL: @PR16462_2(
+ ret i1 icmp sgt (i32 sext (i16 trunc (i32 select (i1 icmp eq (i32* getelementptr inbounds ([1 x i32]* @a, i32 0, i32 0), i32* @d), i32 0, i32 1) to i16) to i32), i32 42)
+; CHECK: ret i1 icmp sgt (i16 trunc (i32 select (i1 icmp eq (i32* getelementptr inbounds ([1 x i32]* @a, i32 0, i32 0), i32* @d), i32 0, i32 1) to i16), i16 42)
+}
diff --git a/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll b/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
index 800162197919..1549c0d0f46e 100644
--- a/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
+++ b/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
@@ -1,7 +1,7 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
; <rdar://problem/8606771>
-; CHECK: @main
+; CHECK-LABEL: @main(
define i32 @main(i32 %argc) nounwind ssp {
entry:
%tmp3151 = trunc i32 %argc to i8
@@ -23,7 +23,7 @@ entry:
}
; rdar://8739316
-; CHECK: @foo
+; CHECK-LABEL: @foo(
define i8 @foo(i8 %arg, i8 %arg1) nounwind {
bb:
%tmp = shl i8 %arg, 7
diff --git a/test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll b/test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll
index 720365c4d6b2..80983ef27098 100644
--- a/test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll
+++ b/test/Transforms/InstCombine/2010-11-21-SizeZeroTypeGEP.ll
@@ -3,14 +3,14 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
define {}* @foo({}* %x, i32 %n) {
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK-NOT: getelementptr
%p = getelementptr {}* %x, i32 %n
ret {}* %p
}
define i8* @bar(i64 %n, {{}, [0 x {[0 x i8]}]}* %p) {
-; CHECK: @bar
+; CHECK-LABEL: @bar(
%g = getelementptr {{}, [0 x {[0 x i8]}]}* %p, i64 %n, i32 1, i64 %n, i32 0, i64 %n
; CHECK: %p, i64 0, i32 1, i64 0, i32 0, i64 %n
ret i8* %g
diff --git a/test/Transforms/InstCombine/2010-11-23-Distributed.ll b/test/Transforms/InstCombine/2010-11-23-Distributed.ll
index 4f8e8dc713b4..20bfed87798b 100644
--- a/test/Transforms/InstCombine/2010-11-23-Distributed.ll
+++ b/test/Transforms/InstCombine/2010-11-23-Distributed.ll
@@ -1,6 +1,6 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @foo(i32 %x, i32 %y) {
-; CHECK: @foo
+; CHECK-LABEL: @foo(
%add = add nsw i32 %y, %x
%mul = mul nsw i32 %add, %y
%square = mul nsw i32 %y, %y
@@ -11,7 +11,7 @@ define i32 @foo(i32 %x, i32 %y) {
}
define i1 @bar(i64 %x, i64 %y) {
-; CHECK: @bar
+; CHECK-LABEL: @bar(
%a = and i64 %y, %x
; CHECK: and
; CHECK-NOT: and
diff --git a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
index fedb46dd24ad..a75a4656e68a 100644
--- a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
+++ b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
@@ -2,7 +2,7 @@
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
-; CHECK: define void @fu1
+; CHECK-LABEL: define void @fu1(
define void @fu1(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
; CHECK: alloca double*
@@ -33,7 +33,7 @@ define void @fu1(i32 %parm) nounwind ssp {
declare void @bar(double*)
-; CHECK: define void @fu2
+; CHECK-LABEL: define void @fu2(
define void @fu2(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
%ptr = alloca double*, align 4
diff --git a/test/Transforms/InstCombine/2012-03-10-InstCombine.ll b/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
index 58ccf12e6cf4..d1860bccd75e 100644
--- a/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
+++ b/test/Transforms/InstCombine/2012-03-10-InstCombine.ll
@@ -2,7 +2,7 @@
; Derived from gcc.c-torture/execute/frame-address.c
-; CHECK: @func
+; CHECK-LABEL: @func(
; CHECK: return:
; CHECK-NOT: ret i32 0
; CHECK: ret i32 %retval
diff --git a/test/Transforms/InstCombine/2012-04-24-vselect.ll b/test/Transforms/InstCombine/2012-04-24-vselect.ll
index 8d2de2b2431c..211d401a3bca 100644
--- a/test/Transforms/InstCombine/2012-04-24-vselect.ll
+++ b/test/Transforms/InstCombine/2012-04-24-vselect.ll
@@ -1,6 +1,6 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK: <i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
define <8 x i32> @foo() nounwind {
diff --git a/test/Transforms/InstCombine/2012-05-28-select-hang.ll b/test/Transforms/InstCombine/2012-05-28-select-hang.ll
index c580bacb0dcb..db1dbd5b6e2f 100644
--- a/test/Transforms/InstCombine/2012-05-28-select-hang.ll
+++ b/test/Transforms/InstCombine/2012-05-28-select-hang.ll
@@ -34,6 +34,6 @@ land.end: ; preds = %land.rhs, %entry
store i8 %conv9, i8* @a, align 1
ret void
-; CHECK: @func
+; CHECK-LABEL: @func(
; CHECK-NOT: select
}
diff --git a/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll b/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll
index 6f3df5b2fd99..4d185bf7e06e 100644
--- a/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll
+++ b/test/Transforms/InstCombine/2012-07-30-addrsp-bitcast.ll
@@ -1,10 +1,10 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: bitcast
+; CHECK: addrspacecast
@base = internal addrspace(3) unnamed_addr global [16 x i32] zeroinitializer, align 16
declare void @foo(i32*)
define void @test() nounwind {
- call void @foo(i32* getelementptr (i32* bitcast ([16 x i32] addrspace(3)* @base to i32*), i64 2147483647)) nounwind
+ call void @foo(i32* getelementptr (i32* addrspacecast ([16 x i32] addrspace(3)* @base to i32*), i64 2147483647)) nounwind
ret void
}
diff --git a/test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll b/test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll
index 4efaf8c17255..0374bd52afd4 100644
--- a/test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll
+++ b/test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll
@@ -5,7 +5,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.8.0"
-; CHECK: @udiv400
+; CHECK-LABEL: @udiv400(
; CHECK: udiv i32 %x, 400
; CHECK: ret
define i32 @udiv400(i32 %x) {
@@ -16,7 +16,7 @@ entry:
}
-; CHECK: @udiv400_no
+; CHECK-LABEL: @udiv400_no(
; CHECK: ashr
; CHECK: div
; CHECK: ret
@@ -27,7 +27,7 @@ entry:
ret i32 %div1
}
-; CHECK: @sdiv400_yes
+; CHECK-LABEL: @sdiv400_yes(
; CHECK: udiv i32 %x, 400
; CHECK: ret
define i32 @sdiv400_yes(i32 %x) {
@@ -41,7 +41,7 @@ entry:
}
-; CHECK: @udiv_i80
+; CHECK-LABEL: @udiv_i80(
; CHECK: udiv i80 %x, 400
; CHECK: ret
define i80 @udiv_i80(i80 %x) {
diff --git a/test/Transforms/InstCombine/2012-09-17-ZeroSizedAlloca.ll b/test/Transforms/InstCombine/2012-09-17-ZeroSizedAlloca.ll
index ba025e92b010..7015725feb16 100644
--- a/test/Transforms/InstCombine/2012-09-17-ZeroSizedAlloca.ll
+++ b/test/Transforms/InstCombine/2012-09-17-ZeroSizedAlloca.ll
@@ -9,7 +9,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.8.0"
-; CHECK: @f
+; CHECK-LABEL: @f(
; CHECK-NEXT: alloca [0 x i8], align 1024
; CHECK-NOT: alloca
; CHECK: ret void
diff --git a/test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll b/test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll
index 4cd60b42fbe1..35b62850c626 100644
--- a/test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll
+++ b/test/Transforms/InstCombine/2012-09-24-MemcpyFromGlobalCrash.ll
@@ -8,7 +8,7 @@ declare void @bar(i8*)
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
define void @test() {
-; CHECK: @test
+; CHECK-LABEL: @test(
; CHECK: llvm.memcpy
; CHECK: ret void
%A = alloca [100 x i8]
diff --git a/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll b/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
index c1602da4c84d..466629cb5fd6 100644
--- a/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
+++ b/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
@@ -9,4 +9,4 @@ entry:
%or4 = or i32 or (i32 zext (i1 icmp eq (i32* @g, i32* null) to i32), i32 1), %xor
ret i32 %or4
}
-; CHECK: define i32 @function
+; CHECK-LABEL: define i32 @function(
diff --git a/test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll b/test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll
index b20c3a07c0ac..789e3172e7c4 100644
--- a/test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll
+++ b/test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll
@@ -10,7 +10,7 @@ target triple = "x86_64-apple-macosx10.9.0"
; allocation of an i96 because of the bitcast to create %2. That's not valid,
; as the other 32 bits of the structure still feed into the return value
define { i64, i64 } @function(i32 %x, i32 %y, i32 %z) nounwind {
-; CHECK: @function
+; CHECK-LABEL: @function(
; CHECK-NEXT: entry:
; CHECK-NEXT: %retval = alloca %struct._my_struct, align 8
; CHECK-NOT: bitcast i96* %retval to %struct._my_struct*
diff --git a/test/Transforms/InstCombine/ExtractCast.ll b/test/Transforms/InstCombine/ExtractCast.ll
index 5ebbefd97b3e..9a8872f2fb1f 100644
--- a/test/Transforms/InstCombine/ExtractCast.ll
+++ b/test/Transforms/InstCombine/ExtractCast.ll
@@ -1,6 +1,6 @@
; RUN: opt < %s -instcombine -S -o - | FileCheck %s
-; CHECK: @a
+; CHECK-LABEL: @a(
define i32 @a(<4 x i64> %I) {
entry:
; CHECK-NOT: trunc <4 x i64>
@@ -13,7 +13,7 @@ entry:
}
-; CHECK: @b
+; CHECK-LABEL: @b(
define i32 @b(<4 x float> %I) {
entry:
; CHECK-NOT: fptosi <4 x float>
diff --git a/test/Transforms/InstCombine/LandingPadClauses.ll b/test/Transforms/InstCombine/LandingPadClauses.ll
index de3b2d34fb94..10af4bcadf68 100644
--- a/test/Transforms/InstCombine/LandingPadClauses.ll
+++ b/test/Transforms/InstCombine/LandingPadClauses.ll
@@ -11,7 +11,7 @@ declare i32 @__objc_personality_v0(i32, i64, i8*, i8*)
declare void @bar()
define void @foo_generic() {
-; CHECK: @foo_generic
+; CHECK-LABEL: @foo_generic(
invoke void @bar()
to label %cont.a unwind label %lpad.a
cont.a:
@@ -131,7 +131,7 @@ lpad.i:
}
define void @foo_cxx() {
-; CHECK: @foo_cxx
+; CHECK-LABEL: @foo_cxx(
invoke void @bar()
to label %cont.a unwind label %lpad.a
cont.a:
@@ -182,7 +182,7 @@ lpad.d:
}
define void @foo_objc() {
-; CHECK: @foo_objc
+; CHECK-LABEL: @foo_objc(
invoke void @bar()
to label %cont.a unwind label %lpad.a
cont.a:
diff --git a/test/Transforms/InstCombine/PR7357.ll b/test/Transforms/InstCombine/PR7357.ll
new file mode 100644
index 000000000000..c397c5ee05e3
--- /dev/null
+++ b/test/Transforms/InstCombine/PR7357.ll
@@ -0,0 +1,17 @@
+; RUN: opt < %s "-default-data-layout=e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32" -instcombine -S | FileCheck %s
+@.str1 = private constant [11 x i8] c"(){};[]&|:\00", align 4
+
+; check that simplify libcalls will not replace a call with one calling
+; convention with a new call with a different calling convention.
+
+; CHECK: define arm_aapcscc i32 @foo(i32 %argc)
+; CHECK: call arm_aapcscc i8* @strchr
+define arm_aapcscc i32 @foo(i32 %argc) nounwind {
+bb.nph:
+ %c = call arm_aapcscc i8* @strchr(i8* getelementptr ([11 x i8]* @.str1, i32 0,
+i32 0), i32 %argc) nounwind readonly
+ %p = ptrtoint i8* %c to i32
+ ret i32 %p
+}
+
+declare arm_aapcscc i8* @strchr(i8*, i32) nounwind readonly
diff --git a/test/Transforms/InstCombine/abs-1.ll b/test/Transforms/InstCombine/abs-1.ll
index 807f238755b5..2c223edcfa74 100644
--- a/test/Transforms/InstCombine/abs-1.ll
+++ b/test/Transforms/InstCombine/abs-1.ll
@@ -11,7 +11,7 @@ declare i64 @llabs(i64)
; Check abs(x) -> x >s -1 ? x : -x.
define i32 @test_simplify1(i32 %x) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @abs(i32 %x)
; CHECK-NEXT: [[ISPOS:%[a-z0-9]+]] = icmp sgt i32 %x, -1
; CHECK-NEXT: [[NEG:%[a-z0-9]+]] = sub i32 0, %x
@@ -21,7 +21,7 @@ define i32 @test_simplify1(i32 %x) {
}
define i64 @test_simplify2(i64 %x) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%ret = call i64 @labs(i64 %x)
; CHECK-NEXT: [[ISPOS:%[a-z0-9]+]] = icmp sgt i64 %x, -1
; CHECK-NEXT: [[NEG:%[a-z0-9]+]] = sub i64 0, %x
@@ -31,7 +31,7 @@ define i64 @test_simplify2(i64 %x) {
}
define i64 @test_simplify3(i64 %x) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%ret = call i64 @llabs(i64 %x)
; CHECK-NEXT: [[ISPOS:%[a-z0-9]+]] = icmp sgt i64 %x, -1
; CHECK-NEXT: [[NEG:%[a-z0-9]+]] = sub i64 0, %x
diff --git a/test/Transforms/InstCombine/add2.ll b/test/Transforms/InstCombine/add2.ll
index c5109c528857..0964bc00d1cb 100644
--- a/test/Transforms/InstCombine/add2.ll
+++ b/test/Transforms/InstCombine/add2.ll
@@ -6,7 +6,7 @@ define i64 @test1(i64 %A, i32 %B) {
%tmp5 = add i64 %tmp3, %A
%tmp6 = and i64 %tmp5, 123
ret i64 %tmp6
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: and i64 %A, 123
; CHECK-NEXT: ret i64
}
@@ -16,7 +16,7 @@ define i32 @test2(i32 %A) {
%C = and i32 %A, 32
%F = add i32 %B, %C
ret i32 %F
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: and i32 %A, 39
; CHECK-NEXT: ret i32
}
@@ -26,7 +26,7 @@ define i32 @test3(i32 %A) {
%C = lshr i32 %A, 30
%F = add i32 %B, %C
ret i32 %F
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: and
; CHECK-NEXT: lshr
; CHECK-NEXT: or i32 %B, %C
@@ -36,7 +36,7 @@ define i32 @test3(i32 %A) {
define i32 @test4(i32 %A) {
%B = add nuw i32 %A, %A
ret i32 %B
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: %B = shl nuw i32 %A, 1
; CHECK-NEXT: ret i32 %B
}
diff --git a/test/Transforms/InstCombine/add4.ll b/test/Transforms/InstCombine/add4.ll
index 0fc0a6c1ac26..208c7f03200e 100644
--- a/test/Transforms/InstCombine/add4.ll
+++ b/test/Transforms/InstCombine/add4.ll
@@ -1,9 +1,5 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-;; Target triple for gep raising case below.
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
-target triple = "i686-apple-darwin8"
-
define float @test1(float %A, float %B, i1 %C) {
EntryBlock:
;; A*(1 - uitofp i1 C) -> select C, 0, A
@@ -11,7 +7,7 @@ EntryBlock:
%mc = fsub float 1.000000e+00, %cf
%p1 = fmul fast float %A, %mc
ret float %p1
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: select i1 %C, float -0.000000e+00, float %A
}
@@ -21,38 +17,63 @@ EntryBlock:
%cf = uitofp i1 %C to float
%p2 = fmul fast float %B, %cf
ret float %p2
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: select i1 %C, float %B, float -0.000000e+00
}
define float @test3(float %A, float %B, i1 %C) {
EntryBlock:
+ ;; select C, 0, B + select C, A, 0 -> select C, A, B
+ %cf = uitofp i1 %C to float
+ %s1 = select i1 %C, float 0.000000e+00, float %B
+ %s2 = select i1 %C, float %A, float 0.000000e+00
+ %sum = fadd fast float %s1, %s2
+ ret float %sum
+; CHECK-LABEL: @test3(
+; CHECK: select i1 %C, float %A, float %B
+}
+
+define float @test4(float %A, float %B, i1 %C) {
+EntryBlock:
+ ;; B*(uitofp i1 C) + A*(1 - uitofp i1 C) -> select C, A, B
+ %cf = uitofp i1 %C to float
+ %mc = fsub fast float 1.000000e+00, %cf
+ %p1 = fmul fast float %A, %mc
+ %p2 = fmul fast float %B, %cf
+ %s1 = fadd fast float %p2, %p1
+ ret float %s1
+; CHECK-LABEL: @test4(
+; CHECK: select i1 %C, float %B, float %A
+}
+
+define float @test5(float %A, float %B, i1 %C) {
+EntryBlock:
;; A*(1 - uitofp i1 C) + B*(uitofp i1 C) -> select C, A, B
%cf = uitofp i1 %C to float
- %mc = fsub float 1.000000e+00, %cf
+ %mc = fsub fast float 1.000000e+00, %cf
%p1 = fmul fast float %A, %mc
%p2 = fmul fast float %B, %cf
%s1 = fadd fast float %p1, %p2
ret float %s1
-; CHECK: @test3
+; CHECK-LABEL: @test5(
; CHECK: select i1 %C, float %B, float %A
}
; PR15952
-define float @test4(float %A, float %B, i32 %C) {
+define float @test6(float %A, float %B, i32 %C) {
%cf = uitofp i32 %C to float
%mc = fsub float 1.000000e+00, %cf
%p1 = fmul fast float %A, %mc
ret float %p1
-; CHECK: @test4
+; CHECK-LABEL: @test6(
; CHECK: uitofp
}
-define float @test5(float %A, float %B, i32 %C) {
+define float @test7(float %A, float %B, i32 %C) {
%cf = uitofp i32 %C to float
%p2 = fmul fast float %B, %cf
ret float %p2
-; CHECK: @test5
+; CHECK-LABEL: @test7(
; CHECK: uitofp
}
diff --git a/test/Transforms/InstCombine/addrspacecast.ll b/test/Transforms/InstCombine/addrspacecast.ll
new file mode 100644
index 000000000000..d908b556e195
--- /dev/null
+++ b/test/Transforms/InstCombine/addrspacecast.ll
@@ -0,0 +1,69 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64-p1:32:32:32-p2:16:16:16-n8:16:32:64"
+
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) nounwind
+declare void @llvm.memcpy.p0i8.p1i8.i32(i8*, i8 addrspace(1)*, i32, i32, i1) nounwind
+declare void @llvm.memcpy.p0i8.p2i8.i32(i8*, i8 addrspace(2)*, i32, i32, i1) nounwind
+
+
+define i32* @combine_redundant_addrspacecast(i32 addrspace(1)* %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast(
+; CHECK: addrspacecast i32 addrspace(1)* %x to i32*
+; CHECK-NEXT: ret
+ %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
+ %z = addrspacecast i32 addrspace(3)* %y to i32*
+ ret i32* %z
+}
+
+define <4 x i32*> @combine_redundant_addrspacecast_vector(<4 x i32 addrspace(1)*> %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast_vector(
+; CHECK: addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32*>
+; CHECK-NEXT: ret
+ %y = addrspacecast <4 x i32 addrspace(1)*> %x to <4 x i32 addrspace(3)*>
+ %z = addrspacecast <4 x i32 addrspace(3)*> %y to <4 x i32*>
+ ret <4 x i32*> %z
+}
+
+define float* @combine_redundant_addrspacecast_types(i32 addrspace(1)* %x) nounwind {
+; CHECK-LABEL: @combine_redundant_addrspacecast_types(
+; CHECK: addrspacecast i32 addrspace(1)* %x to float*
+; CHECK-NEXT: ret
+ %y = addrspacecast i32 addrspace(1)* %x to i32 addrspace(3)*
+ %z = addrspacecast i32 addrspace(3)* %y to float*
+ ret float* %z
+}
+
+@const_array = addrspace(2) constant [60 x i8] [i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22,
+ i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22,
+ i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22,
+ i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22,
+ i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22, i8 2, i8 9, i8 4, i8 22 ]
+
+declare void @foo(i8*) nounwind
+
+; A copy from a constant addrspacecast'ed global
+; CHECK-LABEL: @memcpy_addrspacecast(
+; CHECK-NOT: call void @llvm.memcpy
+define i32 @memcpy_addrspacecast() nounwind {
+entry:
+ %alloca = alloca i8, i32 48
+ call void @llvm.memcpy.p0i8.p1i8.i32(i8* %alloca, i8 addrspace(1)* addrspacecast (i8 addrspace(2)* getelementptr inbounds ([60 x i8] addrspace(2)* @const_array, i16 0, i16 4) to i8 addrspace(1)*), i32 48, i32 4, i1 false) nounwind
+ br label %loop.body
+
+loop.body:
+ %i = phi i32 [ 0, %entry ], [ %i.inc, %loop.body ]
+ %sum = phi i32 [ 0, %entry ], [ %sum.inc, %loop.body]
+ %ptr = getelementptr i8* %alloca, i32 %i
+ %load = load i8* %ptr
+ %ext = zext i8 %load to i32
+ %sum.inc = add i32 %sum, %ext
+ %i.inc = add i32 %i, 1
+ %cmp = icmp ne i32 %i, 48
+ br i1 %cmp, label %loop.body, label %end
+
+end:
+ ret i32 %sum.inc
+}
+
diff --git a/test/Transforms/InstCombine/align-addr.ll b/test/Transforms/InstCombine/align-addr.ll
index 4ea1bd9beb3b..4d22c2cd2ef2 100644
--- a/test/Transforms/InstCombine/align-addr.ll
+++ b/test/Transforms/InstCombine/align-addr.ll
@@ -1,10 +1,10 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
+target datalayout = "E-p:64:64:64-p1:32:32:32-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
; Instcombine should be able to prove vector alignment in the
; presence of a few mild address computation tricks.
-; CHECK: @test0(
+; CHECK-LABEL: @test0(
; CHECK: align 16
define void @test0(i8* %b, i64 %n, i64 %u, i64 %y) nounwind {
@@ -35,7 +35,7 @@ return:
; When we see a unaligned load from an insufficiently aligned global or
; alloca, increase the alignment of the load, turning it into an aligned load.
-; CHECK: @test1(
+; CHECK-LABEL: @test1(
; CHECK: tmp = load
; CHECK: GLOBAL{{.*}}align 16
@@ -47,9 +47,30 @@ entry:
ret <16 x i8> %tmp
}
+@GLOBAL_as1 = internal addrspace(1) global [4 x i32] zeroinitializer
+
+define <16 x i8> @test1_as1(<2 x i64> %x) {
+; CHECK-LABEL: @test1_as1(
+; CHECK: tmp = load
+; CHECK: GLOBAL_as1{{.*}}align 16
+ %tmp = load <16 x i8> addrspace(1)* bitcast ([4 x i32] addrspace(1)* @GLOBAL_as1 to <16 x i8> addrspace(1)*), align 1
+ ret <16 x i8> %tmp
+}
+
+@GLOBAL_as1_gep = internal addrspace(1) global [8 x i32] zeroinitializer
+
+define <16 x i8> @test1_as1_gep(<2 x i64> %x) {
+; CHECK-LABEL: @test1_as1_gep(
+; CHECK: tmp = load
+; CHECK: GLOBAL_as1_gep{{.*}}align 16
+ %tmp = load <16 x i8> addrspace(1)* bitcast (i32 addrspace(1)* getelementptr ([8 x i32] addrspace(1)* @GLOBAL_as1_gep, i16 0, i16 4) to <16 x i8> addrspace(1)*), align 1
+ ret <16 x i8> %tmp
+}
+
+
; When a load or store lacks an explicit alignment, add one.
-; CHECK: @test2(
+; CHECK-LABEL: @test2(
; CHECK: load double* %p, align 8
; CHECK: store double %n, double* %p, align 8
@@ -67,7 +88,7 @@ declare void @use(i8*)
define void @test3(%struct.s* sret %a4) {
; Check that the alignment is bumped up the alignment of the sret type.
-; CHECK: @test3
+; CHECK-LABEL: @test3(
%a4.cast = bitcast %struct.s* %a4 to i8*
call void @llvm.memset.p0i8.i64(i8* %a4.cast, i8 0, i64 16, i32 1, i1 false)
; CHECK: call void @llvm.memset.p0i8.i64(i8* %a4.cast, i8 0, i64 16, i32 4, i1 false)
diff --git a/test/Transforms/InstCombine/align-external.ll b/test/Transforms/InstCombine/align-external.ll
index c3ef2dbb70f0..66ff9c16e424 100644
--- a/test/Transforms/InstCombine/align-external.ll
+++ b/test/Transforms/InstCombine/align-external.ll
@@ -22,7 +22,7 @@ define i64 @foo(i64 %a) {
}
define i32 @bar() {
-; CHECK: @bar
+; CHECK-LABEL: @bar(
%r = load i32* @B, align 1
; CHECK: align 1
ret i32 %r
diff --git a/test/Transforms/InstCombine/alloca.ll b/test/Transforms/InstCombine/alloca.ll
index 68a671cec88a..ae1cfa1ed2fc 100644
--- a/test/Transforms/InstCombine/alloca.ll
+++ b/test/Transforms/InstCombine/alloca.ll
@@ -1,14 +1,14 @@
-target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
+; RUN: opt < %s -instcombine -S -default-data-layout="E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" | FileCheck %s
+; RUN: opt < %s -instcombine -S -default-data-layout="E-p:32:32:32-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" | FileCheck %s -check-prefix=P32
+; RUN: opt < %s -instcombine -S | FileCheck %s -check-prefix=NODL
-; RUN: opt < %s -instcombine -S | FileCheck %s
-; END.
declare void @use(...)
@int = global i32 zeroinitializer
; Zero byte allocas should be merged if they can't be deleted.
-; CHECK: @test
+; CHECK-LABEL: @test(
; CHECK: alloca
; CHECK-NOT: alloca
define void @test() {
@@ -25,7 +25,7 @@ define void @test() {
}
; Zero byte allocas should be deleted.
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: alloca
define void @test2() {
%A = alloca i32 ; <i32*> [#uses=1]
@@ -34,7 +34,7 @@ define void @test2() {
}
; Zero byte allocas should be deleted.
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NOT: alloca
define void @test3() {
%A = alloca { i32 } ; <{ i32 }*> [#uses=1]
@@ -43,7 +43,7 @@ define void @test3() {
ret void
}
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: = zext i32 %n to i64
; CHECK: %A = alloca i32, i64 %
define i32* @test4(i32 %n) {
@@ -54,7 +54,7 @@ define i32* @test4(i32 %n) {
; Allocas which are only used by GEPs, bitcasts, and stores (transitively)
; should be deleted.
define void @test5() {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NOT: alloca
; CHECK-NOT: store
; CHECK: ret
@@ -80,7 +80,7 @@ declare void @f(i32* %p)
; Check that we don't delete allocas in some erroneous cases.
define void @test6() {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NOT: ret
; CHECK: alloca
; CHECK-NEXT: alloca
@@ -110,3 +110,22 @@ entry:
}
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
+
+
+; Check that the GEP indices use the pointer size, or 64 if unknown
+define void @test8() {
+; CHECK-LABEL: @test8(
+; CHECK: alloca [100 x i32]
+; CHECK: getelementptr inbounds [100 x i32]* %x1, i64 0, i64 0
+
+; P32-LABEL: @test8(
+; P32: alloca [100 x i32]
+; P32: getelementptr inbounds [100 x i32]* %x1, i32 0, i32 0
+
+; NODL-LABEL: @test8(
+; NODL: alloca [100 x i32]
+; NODL: getelementptr inbounds [100 x i32]* %x1, i64 0, i64 0
+ %x = alloca i32, i32 100
+ call void (...)* @use(i32* %x)
+ ret void
+}
diff --git a/test/Transforms/InstCombine/and-xor-or.ll b/test/Transforms/InstCombine/and-xor-or.ll
index 7ff810b6eeec..ec36d13ec1af 100644
--- a/test/Transforms/InstCombine/and-xor-or.ll
+++ b/test/Transforms/InstCombine/and-xor-or.ll
@@ -7,7 +7,7 @@ define i64 @or(i64 %x, i64 %y) nounwind uwtable readnone ssp {
%2 = xor i64 %y, %x
%3 = add i64 %1, %2
ret i64 %3
-; CHECK: @or
+; CHECK-LABEL: @or(
; CHECK: or i64
; CHECK-NEXT: ret
}
@@ -18,7 +18,7 @@ define i64 @or2(i64 %x, i64 %y) nounwind uwtable readnone ssp {
%2 = xor i64 %y, %x
%3 = or i64 %1, %2
ret i64 %3
-; CHECK: @or2
+; CHECK-LABEL: @or2(
; CHECK: or i64
; CHECK-NEXT: ret
}
diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll
index 8492df9a1209..3d36bfb404d1 100644
--- a/test/Transforms/InstCombine/and.ll
+++ b/test/Transforms/InstCombine/and.ll
@@ -186,9 +186,9 @@ define i1 @test25(i32 %A) {
}
define i1 @test26(i32 %A) {
- %B = icmp ne i32 %A, 50 ; <i1> [#uses=1]
- %C = icmp ne i32 %A, 51 ; <i1> [#uses=1]
- ;; (A-50) > 1
+ %B = icmp ne i32 %A, 49 ; <i1> [#uses=1]
+ %C = icmp ne i32 %A, 50 ; <i1> [#uses=1]
+ ;; (A-49) > 1
%D = and i1 %B, %C ; <i1> [#uses=1]
ret i1 %D
}
diff --git a/test/Transforms/InstCombine/and2.ll b/test/Transforms/InstCombine/and2.ll
index 531aedb668a0..e88fd5983003 100644
--- a/test/Transforms/InstCombine/and2.ll
+++ b/test/Transforms/InstCombine/and2.ll
@@ -13,7 +13,7 @@ define i1 @test2(i1 %X, i1 %Y) {
%a = and i1 %X, %Y
%b = and i1 %a, %X
ret i1 %b
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: and i1 %X, %Y
; CHECK-NEXT: ret
}
@@ -22,7 +22,7 @@ define i32 @test3(i32 %X, i32 %Y) {
%a = and i32 %X, %Y
%b = and i32 %Y, %a
ret i32 %b
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: and i32 %X, %Y
; CHECK-NEXT: ret
}
@@ -32,7 +32,7 @@ define i1 @test4(i32 %X) {
%b = icmp slt i32 %X, 0
%c = and i1 %a, %b
ret i1 %c
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: ret i1 false
}
@@ -42,3 +42,15 @@ define <4 x i32> @test5(<4 x i32> %A) {
%2 = and <4 x i32> <i32 1, i32 2, i32 3, i32 4>, %1
ret <4 x i32> %2
}
+
+; Check that we combine "if x!=0 && x!=-1" into "if x+1u>1"
+define i32 @test6(i64 %x) nounwind {
+; CHECK: @test6
+; CHECK-NEXT: add i64 %x, 1
+; CHECK-NEXT: icmp ugt i64 %x.off, 1
+ %cmp1 = icmp ne i64 %x, -1
+ %not.cmp = icmp ne i64 %x, 0
+ %.cmp1 = and i1 %cmp1, %not.cmp
+ %land.ext = zext i1 %.cmp1 to i32
+ ret i32 %land.ext
+}
diff --git a/test/Transforms/InstCombine/apint-call-cast-target.ll b/test/Transforms/InstCombine/apint-call-cast-target.ll
index fe336de75242..4e98f9b2b3ac 100644
--- a/test/Transforms/InstCombine/apint-call-cast-target.ll
+++ b/test/Transforms/InstCombine/apint-call-cast-target.ll
@@ -1,16 +1,19 @@
-; RUN: opt < %s -instcombine -S | grep call | not grep bitcast
+; RUN: opt < %s -instcombine -S | FileCheck %s
target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu"
-
define i32 @main() {
+; CHECK-LABEL: @main(
+; CHECK: call i32 bitcast
entry:
%tmp = call i32 bitcast (i7* (i999*)* @ctime to i32 (i99*)*)( i99* null )
ret i32 %tmp
}
define i7* @ctime(i999*) {
+; CHECK-LABEL: @ctime(
+; CHECK: call i7* bitcast
entry:
%tmp = call i7* bitcast (i32 ()* @main to i7* ()*)( )
ret i7* %tmp
diff --git a/test/Transforms/InstCombine/apint-select.ll b/test/Transforms/InstCombine/apint-select.ll
index f2ea60101c5f..cf24a44d6288 100644
--- a/test/Transforms/InstCombine/apint-select.ll
+++ b/test/Transforms/InstCombine/apint-select.ll
@@ -1,6 +1,7 @@
; This test makes sure that these instructions are properly eliminated.
-; RUN: opt < %s -instcombine -S | not grep select
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK-NOT: select
define i41 @test1(i1 %C) {
@@ -37,7 +38,7 @@ define i41 @test5(i41 %X) {
define i1023 @test6(i1023 %X) {
;; ((X & 27) ? 27 : 0)
- %Y = and i1023 %X, 64
+ %Y = and i1023 %X, 64
%t = icmp ne i1023 %Y, 0
%V = select i1 %t, i1023 64, i1023 0
ret i1023 %V
diff --git a/test/Transforms/InstCombine/apint-shift-simplify.ll b/test/Transforms/InstCombine/apint-shift-simplify.ll
index 14e895ad4bf6..63703ba112ac 100644
--- a/test/Transforms/InstCombine/apint-shift-simplify.ll
+++ b/test/Transforms/InstCombine/apint-shift-simplify.ll
@@ -5,7 +5,7 @@ define i41 @test0(i41 %A, i41 %B, i41 %C) {
%Y = shl i41 %B, %C
%Z = and i41 %X, %Y
ret i41 %Z
-; CHECK: @test0
+; CHECK-LABEL: @test0(
; CHECK-NEXT: and i41 %A, %B
; CHECK-NEXT: shl i41
; CHECK-NEXT: ret
@@ -16,7 +16,7 @@ define i57 @test1(i57 %A, i57 %B, i57 %C) {
%Y = lshr i57 %B, %C
%Z = or i57 %X, %Y
ret i57 %Z
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: or i57 %A, %B
; CHECK-NEXT: lshr i57
; CHECK-NEXT: ret
@@ -27,7 +27,7 @@ define i49 @test2(i49 %A, i49 %B, i49 %C) {
%Y = ashr i49 %B, %C
%Z = xor i49 %X, %Y
ret i49 %Z
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: xor i49 %A, %B
; CHECK-NEXT: ashr i49
; CHECK-NEXT: ret
diff --git a/test/Transforms/InstCombine/apint-shift.ll b/test/Transforms/InstCombine/apint-shift.ll
index 73f630ebfec6..f5764c2d5e8a 100644
--- a/test/Transforms/InstCombine/apint-shift.ll
+++ b/test/Transforms/InstCombine/apint-shift.ll
@@ -2,14 +2,14 @@
; even with arbitrary precision integers.
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NOT: sh
define i47 @test1(i47 %A) {
%B = shl i47 %A, 0 ; <i47> [#uses=1]
ret i47 %B
}
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: sh
define i41 @test2(i7 %X) {
%A = zext i7 %X to i41 ; <i41> [#uses=1]
@@ -17,14 +17,14 @@ define i41 @test2(i7 %X) {
ret i41 %B
}
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NOT: sh
define i41 @test3(i41 %A) {
%B = ashr i41 %A, 0 ; <i41> [#uses=1]
ret i41 %B
}
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NOT: sh
define i39 @test4(i7 %X) {
%A = zext i7 %X to i39 ; <i39> [#uses=1]
@@ -32,21 +32,21 @@ define i39 @test4(i7 %X) {
ret i39 %B
}
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NOT: sh
define i55 @test5(i55 %A) {
%B = lshr i55 %A, 55 ; <i55> [#uses=1]
ret i55 %B
}
-; CHECK: @test5a
+; CHECK-LABEL: @test5a(
; CHECK-NOT: sh
define i32 @test5a(i32 %A) {
%B = shl i32 %A, 32 ; <i32> [#uses=1]
ret i32 %B
}
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: mul i55 %A, 6
define i55 @test6(i55 %A) {
%B = shl i55 %A, 1 ; <i55> [#uses=1]
@@ -54,7 +54,7 @@ define i55 @test6(i55 %A) {
ret i55 %C
}
-; CHECK: @test6a
+; CHECK-LABEL: @test6a(
; CHECK: mul i55 %A, 6
define i55 @test6a(i55 %A) {
%B = mul i55 %A, 3 ; <i55> [#uses=1]
@@ -62,7 +62,7 @@ define i55 @test6a(i55 %A) {
ret i55 %C
}
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NOT: sh
define i29 @test7(i8 %X) {
%A = zext i8 %X to i29 ; <i29> [#uses=1]
@@ -70,7 +70,7 @@ define i29 @test7(i8 %X) {
ret i29 %B
}
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NOT: sh
define i7 @test8(i7 %A) {
%B = shl i7 %A, 4 ; <i7> [#uses=1]
@@ -78,7 +78,7 @@ define i7 @test8(i7 %A) {
ret i7 %C
}
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NOT: sh
define i17 @test9(i17 %A) {
%B = shl i17 %A, 16 ; <i17> [#uses=1]
@@ -86,7 +86,7 @@ define i17 @test9(i17 %A) {
ret i17 %C
}
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK-NOT: sh
define i19 @test10(i19 %A) {
%B = lshr i19 %A, 18 ; <i19> [#uses=1]
@@ -94,7 +94,7 @@ define i19 @test10(i19 %A) {
ret i19 %C
}
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; Don't hide the shl from scalar evolution. DAGCombine will get it.
; CHECK: shl
define i23 @test11(i23 %A) {
@@ -104,7 +104,7 @@ define i23 @test11(i23 %A) {
ret i23 %C
}
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NOT: sh
define i47 @test12(i47 %A) {
%B = ashr i47 %A, 8 ; <i47> [#uses=1]
@@ -112,7 +112,7 @@ define i47 @test12(i47 %A) {
ret i47 %C
}
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; Don't hide the shl from scalar evolution. DAGCombine will get it.
; CHECK: shl
define i18 @test13(i18 %A) {
@@ -122,7 +122,7 @@ define i18 @test13(i18 %A) {
ret i18 %C
}
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK-NOT: sh
define i35 @test14(i35 %A) {
%B = lshr i35 %A, 4 ; <i35> [#uses=1]
@@ -131,7 +131,7 @@ define i35 @test14(i35 %A) {
ret i35 %D
}
-; CHECK: @test14a
+; CHECK-LABEL: @test14a(
; CHECK-NOT: sh
define i79 @test14a(i79 %A) {
%B = shl i79 %A, 4 ; <i79> [#uses=1]
@@ -140,7 +140,7 @@ define i79 @test14a(i79 %A) {
ret i79 %D
}
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK-NOT: sh
define i45 @test15(i1 %C) {
%A = select i1 %C, i45 3, i45 1 ; <i45> [#uses=1]
@@ -148,7 +148,7 @@ define i45 @test15(i1 %C) {
ret i45 %V
}
-; CHECK: @test15a
+; CHECK-LABEL: @test15a(
; CHECK-NOT: sh
define i53 @test15a(i1 %X) {
%A = select i1 %X, i8 3, i8 1 ; <i8> [#uses=1]
@@ -157,7 +157,7 @@ define i53 @test15a(i1 %X) {
ret i53 %V
}
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK-NOT: sh
define i1 @test16(i84 %X) {
%tmp.3 = ashr i84 %X, 4 ; <i84> [#uses=1]
@@ -166,7 +166,7 @@ define i1 @test16(i84 %X) {
ret i1 %tmp.7
}
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK-NOT: sh
define i1 @test17(i106 %A) {
%B = lshr i106 %A, 3 ; <i106> [#uses=1]
@@ -174,7 +174,7 @@ define i1 @test17(i106 %A) {
ret i1 %C
}
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK-NOT: sh
define i1 @test18(i11 %A) {
%B = lshr i11 %A, 10 ; <i11> [#uses=1]
@@ -182,7 +182,7 @@ define i1 @test18(i11 %A) {
ret i1 %C
}
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK-NOT: sh
define i1 @test19(i37 %A) {
%B = ashr i37 %A, 2 ; <i37> [#uses=1]
@@ -190,7 +190,7 @@ define i1 @test19(i37 %A) {
ret i1 %C
}
-; CHECK: @test19a
+; CHECK-LABEL: @test19a(
; CHECK-NOT: sh
define i1 @test19a(i39 %A) {
%B = ashr i39 %A, 2 ; <i39> [#uses=1]
@@ -198,7 +198,7 @@ define i1 @test19a(i39 %A) {
ret i1 %C
}
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK-NOT: sh
define i1 @test20(i13 %A) {
%B = ashr i13 %A, 12 ; <i13> [#uses=1]
@@ -206,7 +206,7 @@ define i1 @test20(i13 %A) {
ret i1 %C
}
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK-NOT: sh
define i1 @test21(i12 %A) {
%B = shl i12 %A, 6 ; <i12> [#uses=1]
@@ -214,7 +214,7 @@ define i1 @test21(i12 %A) {
ret i1 %C
}
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK-NOT: sh
define i1 @test22(i14 %A) {
%B = shl i14 %A, 7 ; <i14> [#uses=1]
@@ -222,7 +222,7 @@ define i1 @test22(i14 %A) {
ret i1 %C
}
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK-NOT: sh
define i11 @test23(i44 %A) {
%B = shl i44 %A, 33 ; <i44> [#uses=1]
@@ -231,7 +231,7 @@ define i11 @test23(i44 %A) {
ret i11 %D
}
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK-NOT: sh
define i37 @test25(i37 %tmp.2, i37 %AA) {
%x = lshr i37 %AA, 17 ; <i37> [#uses=1]
@@ -241,7 +241,7 @@ define i37 @test25(i37 %tmp.2, i37 %AA) {
ret i37 %tmp.6
}
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK-NOT: sh
define i40 @test26(i40 %A) {
%B = lshr i40 %A, 1 ; <i40> [#uses=1]
diff --git a/test/Transforms/InstCombine/apint-shl-trunc.ll b/test/Transforms/InstCombine/apint-shl-trunc.ll
index f2dc7d5130a9..b4450d4a3a00 100644
--- a/test/Transforms/InstCombine/apint-shl-trunc.ll
+++ b/test/Transforms/InstCombine/apint-shl-trunc.ll
@@ -1,7 +1,7 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
define i1 @test0(i39 %X, i39 %A) {
-; CHECK: @test0
+; CHECK-LABEL: @test0(
; CHECK: %[[V1:.*]] = shl i39 1, %A
; CHECK: %[[V2:.*]] = and i39 %[[V1]], %X
; CHECK: %[[V3:.*]] = icmp ne i39 %[[V2]], 0
@@ -13,7 +13,7 @@ define i1 @test0(i39 %X, i39 %A) {
}
define i1 @test1(i799 %X, i799 %A) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %[[V1:.*]] = shl i799 1, %A
; CHECK: %[[V2:.*]] = and i799 %[[V1]], %X
; CHECK: %[[V3:.*]] = icmp ne i799 %[[V2]], 0
diff --git a/test/Transforms/InstCombine/atomic.ll b/test/Transforms/InstCombine/atomic.ll
index 097cf5eafe06..ccee87433f32 100644
--- a/test/Transforms/InstCombine/atomic.ll
+++ b/test/Transforms/InstCombine/atomic.ll
@@ -6,7 +6,7 @@ target triple = "x86_64-apple-macosx10.7.0"
; Check transforms involving atomic operations
define i32* @test1(i8** %p) {
-; CHECK: define i32* @test1
+; CHECK-LABEL: define i32* @test1(
; CHECK: load atomic i8** %p monotonic, align 8
%c = bitcast i8** %p to i32**
%r = load atomic i32** %c monotonic, align 8
@@ -14,7 +14,7 @@ define i32* @test1(i8** %p) {
}
define i32 @test2(i32* %p) {
-; CHECK: define i32 @test2
+; CHECK-LABEL: define i32 @test2(
; CHECK: %x = load atomic i32* %p seq_cst, align 4
; CHECK: shl i32 %x, 1
%x = load atomic i32* %p seq_cst, align 4
diff --git a/test/Transforms/InstCombine/badmalloc.ll b/test/Transforms/InstCombine/badmalloc.ll
index 3abe28aede5d..2074d262ccbd 100644
--- a/test/Transforms/InstCombine/badmalloc.ll
+++ b/test/Transforms/InstCombine/badmalloc.ll
@@ -15,11 +15,11 @@ define i1 @test1() {
call void @free(i8* %A)
ret i1 %B
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i1 false
}
-; CHECK: @test2
+; CHECK-LABEL: @test2(
define noalias i8* @test2() nounwind {
entry:
; CHECK: @malloc
diff --git a/test/Transforms/InstCombine/bitcast-alias-function.ll b/test/Transforms/InstCombine/bitcast-alias-function.ll
new file mode 100644
index 000000000000..a6b56f94ffbf
--- /dev/null
+++ b/test/Transforms/InstCombine/bitcast-alias-function.ll
@@ -0,0 +1,229 @@
+; RUN: opt -S -instcombine -o - %s | FileCheck %s
+target datalayout = "e-p:32:32:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v64:64:64-v128:128:128-a0:0:64"
+
+
+
+; Cases that should be bitcast
+
+; Test cast between scalars with same bit sizes
+@alias_i32_to_f32 = alias bitcast (i32 (i32)* @func_i32 to float (float)*)
+
+; Test cast between vectors with same number of elements and bit sizes
+@alias_v2i32_to_v2f32 = alias bitcast (<2 x i32> (<2 x i32>)* @func_v2i32 to <2 x float> (<2 x float>)*)
+
+; Test cast from vector to scalar with same number of bits
+@alias_v2f32_to_i64 = alias bitcast (i64 (i64)* @func_i64 to <2 x float> (<2 x float>)*)
+
+; Test cast from scalar to vector with same number of bits
+@alias_i64_to_v2f32 = alias bitcast (<2 x float> (<2 x float>)* @func_v2f32 to i64 (i64)*)
+
+; Test cast between vectors of pointers
+@alias_v2i32p_to_v2i64p = alias bitcast (<2 x i32*> (<2 x i32*>)* @func_v2i32p to <2 x i64*> (<2 x i64*>)*)
+
+
+; Cases that should be invalid and unchanged
+
+; Test cast between scalars with different bit sizes
+@alias_i64_to_f32 = alias bitcast (i64 (i64)* @func_i64 to float (float)*)
+
+; Test cast between vectors with different bit sizes but the
+; same number of elements
+@alias_v2i64_to_v2f32 = alias bitcast (<2 x i64> (<2 x i64>)* @func_v2i64 to <2 x float> (<2 x float>)*)
+
+; Test cast between vectors with same number of bits and different
+; numbers of elements
+@alias_v2i32_to_v4f32 = alias bitcast (<2 x i32> (<2 x i32>)* @func_v2i32 to <4 x float> (<4 x float>)*)
+
+; Test cast between scalar and vector with different number of bits
+@alias_i64_to_v4f32 = alias bitcast (<4 x float> (<4 x float>)* @func_v4f32 to i64 (i64)*)
+
+; Test cast between vector and scalar with different number of bits
+@alias_v4f32_to_i64 = alias bitcast (i64 (i64)* @func_i64 to <4 x float> (<4 x float>)*)
+
+; Test cast from scalar to vector of pointers with same number of bits
+; We don't know the pointer size at this point, so this can't be done
+@alias_i64_to_v2i32p = alias bitcast (<2 x i32*> (<2 x i32*>)* @func_v2i32p to i64 (i64)*)
+
+; Test cast between vector of pointers and scalar with different number of bits
+@alias_v4i32p_to_i64 = alias bitcast (i64 (i64)* @func_i64 to <4 x i32*> (<4 x i32*>)*)
+
+
+
+define internal <2 x i32> @func_v2i32(<2 x i32> %v) noinline nounwind {
+entry:
+ ret <2 x i32> %v
+}
+
+define internal <2 x float> @func_v2f32(<2 x float> %v) noinline nounwind {
+entry:
+ ret <2 x float> %v
+}
+
+define internal <4 x float> @func_v4f32(<4 x float> %v) noinline nounwind {
+entry:
+ ret <4 x float> %v
+}
+
+define internal i32 @func_i32(i32 %v) noinline nounwind {
+entry:
+ ret i32 %v
+}
+
+define internal i64 @func_i64(i64 %v) noinline nounwind {
+entry:
+ ret i64 %v
+}
+
+define internal <2 x i64> @func_v2i64(<2 x i64> %v) noinline nounwind {
+entry:
+ ret <2 x i64> %v
+}
+
+define internal <2 x i32*> @func_v2i32p(<2 x i32*> %v) noinline nounwind {
+entry:
+ ret <2 x i32*> %v
+}
+
+; Valid cases, only bitcast for argument / return type and call underlying function
+
+; Sizes match, should only bitcast
+define void @bitcast_alias_scalar(float* noalias %source, float* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_scalar
+; CHECK: bitcast float %tmp to i32
+; CHECK-NOT: fptoui
+; CHECK-NOT: uitofp
+; CHECK: bitcast i32 %call to float
+ %tmp = load float* %source, align 8
+ %call = call float @alias_i32_to_f32(float %tmp) nounwind
+ store float %call, float* %dest, align 8
+ ret void
+}
+
+; Sizes match, should only bitcast
+define void @bitcast_alias_vector(<2 x float>* noalias %source, <2 x float>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector
+; CHECK: bitcast <2 x float> %tmp to <2 x i32>
+; CHECK-NOT: fptoui
+; CHECK-NOT: uitofp
+; CHECK: bitcast <2 x i32> %call to <2 x float>
+ %tmp = load <2 x float>* %source, align 8
+ %call = call <2 x float> @alias_v2i32_to_v2f32(<2 x float> %tmp) nounwind
+ store <2 x float> %call, <2 x float>* %dest, align 8
+ ret void
+}
+
+; Sizes match, should only bitcast
+define void @bitcast_alias_vector_scalar_same_size(<2 x float>* noalias %source, <2 x float>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector_scalar_same_size
+; CHECK: bitcast <2 x float> %tmp to i64
+; CHECK: %call = call i64 @func_i64
+; CHECK: bitcast i64 %call to <2 x float>
+ %tmp = load <2 x float>* %source, align 8
+ %call = call <2 x float> @alias_v2f32_to_i64(<2 x float> %tmp) nounwind
+ store <2 x float> %call, <2 x float>* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_scalar_vector_same_size(i64* noalias %source, i64* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_scalar_vector_same_size
+; CHECK: bitcast i64 %tmp to <2 x float>
+; CHECK: call <2 x float> @func_v2f32
+; CHECK: bitcast <2 x float> %call to i64
+ %tmp = load i64* %source, align 8
+ %call = call i64 @alias_i64_to_v2f32(i64 %tmp) nounwind
+ store i64 %call, i64* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_vector_ptrs_same_size(<2 x i64*>* noalias %source, <2 x i64*>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector_ptrs_same_size
+; CHECK: bitcast <2 x i64*> %tmp to <2 x i32*>
+; CHECK: call <2 x i32*> @func_v2i32p
+; CHECK: bitcast <2 x i32*> %call to <2 x i64*>
+ %tmp = load <2 x i64*>* %source, align 8
+ %call = call <2 x i64*> @alias_v2i32p_to_v2i64p(<2 x i64*> %tmp) nounwind
+ store <2 x i64*> %call, <2 x i64*>* %dest, align 8
+ ret void
+}
+
+; Invalid cases:
+
+define void @bitcast_alias_mismatch_scalar_size(float* noalias %source, float* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_mismatch_scalar_size
+; CHECK-NOT: fptoui
+; CHECK: @alias_i64_to_f32
+; CHECK-NOT: uitofp
+ %tmp = load float* %source, align 8
+ %call = call float @alias_i64_to_f32(float %tmp) nounwind
+ store float %call, float* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_mismatch_vector_element_and_bit_size(<2 x float>* noalias %source, <2 x float>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_mismatch_vector_element_and_bit_size
+; CHECK-NOT: fptoui <2 x float> %tmp to <2 x i64>
+; CHECK: @alias_v2i64_to_v2f32
+; CHECK-NOT: uitofp <2 x i64> %call to <2 x float>
+ %tmp = load <2 x float>* %source, align 8
+ %call = call <2 x float> @alias_v2i64_to_v2f32(<2 x float> %tmp) nounwind
+ store <2 x float> %call, <2 x float>* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_vector_mismatched_number_elements(<4 x float>* noalias %source, <4 x float>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector_mismatched_number_elements
+; CHECK: %call = call <4 x float> @alias_v2i32_to_v4f32
+ %tmp = load <4 x float>* %source, align 8
+ %call = call <4 x float> @alias_v2i32_to_v4f32(<4 x float> %tmp) nounwind
+ store <4 x float> %call, <4 x float>* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_vector_scalar_mismatched_bit_size(<4 x float>* noalias %source, <4 x float>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector_scalar_mismatched_bit_size
+; CHECK: %call = call <4 x float> @alias_v4f32_to_i64
+ %tmp = load <4 x float>* %source, align 8
+ %call = call <4 x float> @alias_v4f32_to_i64(<4 x float> %tmp) nounwind
+ store <4 x float> %call, <4 x float>* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_vector_ptrs_scalar_mismatched_bit_size(<4 x i32*>* noalias %source, <4 x i32*>* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_vector_ptrs_scalar_mismatched_bit_size
+; CHECK: @alias_v4i32p_to_i64
+ %tmp = load <4 x i32*>* %source, align 8
+ %call = call <4 x i32*> @alias_v4i32p_to_i64(<4 x i32*> %tmp) nounwind
+ store <4 x i32*> %call, <4 x i32*>* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_scalar_vector_ptrs_same_size(i64* noalias %source, i64* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_scalar_vector_ptrs_same_size
+; CHECK: @alias_i64_to_v2i32p
+ %tmp = load i64* %source, align 8
+ %call = call i64 @alias_i64_to_v2i32p(i64 %tmp) nounwind
+ store i64 %call, i64* %dest, align 8
+ ret void
+}
+
+define void @bitcast_alias_scalar_vector_mismatched_bit_size(i64* noalias %source, i64* noalias %dest) nounwind {
+entry:
+; CHECK-LABEL: @bitcast_alias_scalar_vector_mismatched_bit_size
+; CHECK: call i64 @alias_i64_to_v4f32
+ %tmp = load i64* %source, align 8
+ %call = call i64 @alias_i64_to_v4f32(i64 %tmp) nounwind
+ store i64 %call, i64* %dest, align 8
+ ret void
+}
+
diff --git a/test/Transforms/InstCombine/bitcast-bigendian.ll b/test/Transforms/InstCombine/bitcast-bigendian.ll
index 4ded581a14c6..ed812e15f385 100644
--- a/test/Transforms/InstCombine/bitcast-bigendian.ll
+++ b/test/Transforms/InstCombine/bitcast-bigendian.ll
@@ -18,7 +18,7 @@ define float @test2(<2 x float> %A, <2 x i32> %B) {
%add = fadd float %tmp24, %tmp4
ret float %add
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 1
; CHECK-NEXT: bitcast <2 x i32> %B to <2 x float>
; CHECK-NEXT: %tmp4 = extractelement <2 x float> {{.*}}, i32 1
@@ -40,7 +40,7 @@ define float @test3(<2 x float> %A, <2 x i64> %B) {
%add = fadd float %tmp24, %tmp4
ret float %add
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 0
; CHECK-NEXT: bitcast <2 x i64> %B to <4 x float>
; CHECK-NEXT: %tmp4 = extractelement <4 x float> {{.*}}, i32 1
@@ -48,3 +48,44 @@ define float @test3(<2 x float> %A, <2 x i64> %B) {
; CHECK-NEXT: ret float %add
}
+define <2 x i32> @test4(i32 %A, i32 %B){
+ %tmp38 = zext i32 %A to i64
+ %tmp32 = zext i32 %B to i64
+ %tmp33 = shl i64 %tmp32, 32
+ %ins35 = or i64 %tmp33, %tmp38
+ %tmp43 = bitcast i64 %ins35 to <2 x i32>
+ ret <2 x i32> %tmp43
+ ; CHECK-LABEL: @test4(
+ ; CHECK-NEXT: insertelement <2 x i32> undef, i32 %B, i32 0
+ ; CHECK-NEXT: insertelement <2 x i32> {{.*}}, i32 %A, i32 1
+ ; CHECK-NEXT: ret <2 x i32>
+
+}
+
+define <2 x float> @test5(float %A, float %B) {
+ %tmp37 = bitcast float %A to i32
+ %tmp38 = zext i32 %tmp37 to i64
+ %tmp31 = bitcast float %B to i32
+ %tmp32 = zext i32 %tmp31 to i64
+ %tmp33 = shl i64 %tmp32, 32
+ %ins35 = or i64 %tmp33, %tmp38
+ %tmp43 = bitcast i64 %ins35 to <2 x float>
+ ret <2 x float> %tmp43
+ ; CHECK-LABEL: @test5(
+ ; CHECK-NEXT: insertelement <2 x float> undef, float %B, i32 0
+ ; CHECK-NEXT: insertelement <2 x float> {{.*}}, float %A, i32 1
+ ; CHECK-NEXT: ret <2 x float>
+}
+
+define <2 x float> @test6(float %A){
+ %tmp23 = bitcast float %A to i32 ; <i32> [#uses=1]
+ %tmp24 = zext i32 %tmp23 to i64 ; <i64> [#uses=1]
+ %tmp25 = shl i64 %tmp24, 32 ; <i64> [#uses=1]
+ %mask20 = or i64 %tmp25, 1109917696 ; <i64> [#uses=1]
+ %tmp35 = bitcast i64 %mask20 to <2 x float> ; <<2 x float>> [#uses=1]
+ ret <2 x float> %tmp35
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: insertelement <2 x float> undef, float %A, i32 0
+; CHECK-NEXT: insertelement <2 x float> {{.*}}, float 4.200000e+01, i32 1
+; CHECK: ret
+}
diff --git a/test/Transforms/InstCombine/bitcast-vec-uniform.ll b/test/Transforms/InstCombine/bitcast-vec-uniform.ll
index 5975f1ec396e..bfb77191a75f 100644
--- a/test/Transforms/InstCombine/bitcast-vec-uniform.ll
+++ b/test/Transforms/InstCombine/bitcast-vec-uniform.ll
@@ -1,6 +1,6 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: @a
+; CHECK-LABEL: @a(
; CHECK-NOT: bitcast
; CHECK: ret
define <4 x i32> @a(<1 x i64> %y) {
@@ -8,7 +8,7 @@ define <4 x i32> @a(<1 x i64> %y) {
ret <4 x i32> %c
}
-; CHECK: @b
+; CHECK-LABEL: @b(
; CHECK-NOT: bitcast
; CHECK: ret
@@ -17,7 +17,7 @@ define <4 x i32> @b(<1 x i64> %y) {
ret <4 x i32> %c
}
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK-NOT: bitcast
; CHECK: ret
@@ -28,7 +28,7 @@ define <2 x float> @foo() {
}
-; CHECK: @foo2
+; CHECK-LABEL: @foo2(
; CHECK-NOT: bitcast
; CHECK: ret
define <2 x double> @foo2() {
@@ -36,7 +36,7 @@ define <2 x double> @foo2() {
ret <2 x double> %cast
}
-; CHECK: @foo3
+; CHECK-LABEL: @foo3(
; CHECK-NOT: bitcast
; CHECK: ret
define <1 x float> @foo3() {
@@ -44,7 +44,7 @@ define <1 x float> @foo3() {
ret <1 x float> %cast
}
-; CHECK: @foo4
+; CHECK-LABEL: @foo4(
; CHECK-NOT: bitcast
; CHECK: ret
define float @foo4() {
@@ -52,7 +52,7 @@ define float @foo4() {
ret float %cast
}
-; CHECK: @foo5
+; CHECK-LABEL: @foo5(
; CHECK-NOT: bitcast
; CHECK: ret
define double @foo5() {
@@ -61,7 +61,7 @@ define double @foo5() {
}
-; CHECK: @foo6
+; CHECK-LABEL: @foo6(
; CHECK-NOT: bitcast
; CHECK: ret
define <2 x double> @foo6() {
diff --git a/test/Transforms/InstCombine/bitcast-vector-fold.ll b/test/Transforms/InstCombine/bitcast-vector-fold.ll
index 8fd7f35b7bb7..04c2861ae9b7 100644
--- a/test/Transforms/InstCombine/bitcast-vector-fold.ll
+++ b/test/Transforms/InstCombine/bitcast-vector-fold.ll
@@ -35,4 +35,4 @@ define <4 x i32> @test6() {
define i32 @test7() {
%tmp3 = bitcast <2 x half> <half 0xH1100, half 0xH0011> to i32
ret i32 %tmp3
-} \ No newline at end of file
+}
diff --git a/test/Transforms/InstCombine/bitcast.ll b/test/Transforms/InstCombine/bitcast.ll
index 1e6113256bf3..c7a520bcf360 100644
--- a/test/Transforms/InstCombine/bitcast.ll
+++ b/test/Transforms/InstCombine/bitcast.ll
@@ -12,7 +12,7 @@ define i32 @test1(i64 %a) {
%t4 = extractelement <2 x i32> %t3, i32 0
ret i32 %t4
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 0
}
@@ -31,7 +31,7 @@ define float @test2(<2 x float> %A, <2 x i32> %B) {
%add = fadd float %tmp24, %tmp4
ret float %add
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 0
; CHECK-NEXT: bitcast <2 x i32> %B to <2 x float>
; CHECK-NEXT: %tmp4 = extractelement <2 x float> {{.*}}, i32 0
@@ -56,7 +56,7 @@ define float @test3(<2 x float> %A, <2 x i64> %B) {
%add = fadd float %tmp24, %tmp4
ret float %add
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 1
; CHECK-NEXT: bitcast <2 x i64> %B to <4 x float>
; CHECK-NEXT: %tmp4 = extractelement <4 x float> {{.*}}, i32 2
@@ -72,7 +72,7 @@ define <2 x i32> @test4(i32 %A, i32 %B){
%ins35 = or i64 %tmp33, %tmp38
%tmp43 = bitcast i64 %ins35 to <2 x i32>
ret <2 x i32> %tmp43
- ; CHECK: @test4
+ ; CHECK-LABEL: @test4(
; CHECK-NEXT: insertelement <2 x i32> undef, i32 %A, i32 0
; CHECK-NEXT: insertelement <2 x i32> {{.*}}, i32 %B, i32 1
; CHECK-NEXT: ret <2 x i32>
@@ -89,7 +89,7 @@ define <2 x float> @test5(float %A, float %B) {
%ins35 = or i64 %tmp33, %tmp38
%tmp43 = bitcast i64 %ins35 to <2 x float>
ret <2 x float> %tmp43
- ; CHECK: @test5
+ ; CHECK-LABEL: @test5(
; CHECK-NEXT: insertelement <2 x float> undef, float %A, i32 0
; CHECK-NEXT: insertelement <2 x float> {{.*}}, float %B, i32 1
; CHECK-NEXT: ret <2 x float>
@@ -102,7 +102,7 @@ define <2 x float> @test6(float %A){
%mask20 = or i64 %tmp25, 1109917696 ; <i64> [#uses=1]
%tmp35 = bitcast i64 %mask20 to <2 x float> ; <<2 x float>> [#uses=1]
ret <2 x float> %tmp35
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: insertelement <2 x float> <float 4.200000e+01, float undef>, float %A, i32 1
; CHECK: ret
}
@@ -110,7 +110,7 @@ define <2 x float> @test6(float %A){
define i64 @ISPC0(i64 %in) {
%out = and i64 %in, xor (i64 bitcast (<4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1> to i64), i64 -1)
ret i64 %out
-; CHECK: @ISPC0
+; CHECK-LABEL: @ISPC0(
; CHECK: ret i64 0
}
@@ -118,14 +118,14 @@ define i64 @ISPC0(i64 %in) {
define i64 @Vec2(i64 %in) {
%out = and i64 %in, xor (i64 bitcast (<4 x i16> <i16 0, i16 0, i16 0, i16 0> to i64), i64 0)
ret i64 %out
-; CHECK: @Vec2
+; CHECK-LABEL: @Vec2(
; CHECK: ret i64 0
}
define i64 @All11(i64 %in) {
%out = and i64 %in, xor (i64 bitcast (<2 x float> bitcast (i64 -1 to <2 x float>) to i64), i64 -1)
ret i64 %out
-; CHECK: @All11
+; CHECK-LABEL: @All11(
; CHECK: ret i64 0
}
@@ -133,7 +133,7 @@ define i64 @All11(i64 %in) {
define i32 @All111(i32 %in) {
%out = and i32 %in, xor (i32 bitcast (<1 x float> bitcast (i32 -1 to <1 x float>) to i32), i32 -1)
ret i32 %out
-; CHECK: @All111
+; CHECK-LABEL: @All111(
; CHECK: ret i32 0
}
@@ -141,6 +141,16 @@ define <2 x i16> @BitcastInsert(i32 %a) {
%v = insertelement <1 x i32> undef, i32 %a, i32 0
%r = bitcast <1 x i32> %v to <2 x i16>
ret <2 x i16> %r
-; CHECK: @BitcastInsert
+; CHECK-LABEL: @BitcastInsert(
; CHECK: bitcast i32 %a to <2 x i16>
}
+
+; PR17293
+define <2 x i64> @test7(<2 x i8*>* %arg) nounwind {
+ %cast = bitcast <2 x i8*>* %arg to <2 x i64>*
+ %load = load <2 x i64>* %cast, align 16
+ ret <2 x i64> %load
+; CHECK: @test7
+; CHECK: bitcast
+; CHECK: load
+}
diff --git a/test/Transforms/InstCombine/call-cast-target.ll b/test/Transforms/InstCombine/call-cast-target.ll
index 7addc8abc84f..315c51683fd2 100644
--- a/test/Transforms/InstCombine/call-cast-target.ll
+++ b/test/Transforms/InstCombine/call-cast-target.ll
@@ -1,13 +1,14 @@
-; RUN: opt < %s -instcombine -S | \
-; RUN: grep call | not grep bitcast
+; RUN: opt < %s -instcombine -S | FileCheck %s
target datalayout = "e-p:32:32"
target triple = "i686-pc-linux-gnu"
define i32 @main() {
+; CHECK-LABEL: @main
+; CHECK: call i32 bitcast
entry:
- %tmp = call i32 bitcast (i8* (i32*)* @ctime to i32 (i32*)*)( i32* null ) ; <i32> [#uses=1]
- ret i32 %tmp
+ %tmp = call i32 bitcast (i8* (i32*)* @ctime to i32 (i32*)*)( i32* null ) ; <i32> [#uses=1]
+ ret i32 %tmp
}
declare i8* @ctime(i32*)
diff --git a/test/Transforms/InstCombine/call.ll b/test/Transforms/InstCombine/call.ll
index 96ec420eaa8e..e68c0ad9b208 100644
--- a/test/Transforms/InstCombine/call.ll
+++ b/test/Transforms/InstCombine/call.ll
@@ -1,98 +1,122 @@
; Ignore stderr, we expect warnings there
; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s
-target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
+target datalayout = "E-p:64:64:64-p1:16:16:16-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
; Simple case, argument translatable without changing the value
declare void @test1a(i8*)
define void @test1(i32* %A) {
- call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
- ret void
+; CHECK-LABEL: @test1(
; CHECK: %1 = bitcast i32* %A to i8*
; CHECK: call void @test1a(i8* %1)
; CHECK: ret void
+ call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
+ ret void
}
-; More complex case, translate argument because of resolution. This is safe
+
+; Should not do because of change in address space of the parameter
+define void @test1_as1_illegal(i32 addrspace(1)* %A) {
+; CHECK-LABEL: @test1_as1_illegal(
+; CHECK: call void bitcast
+ call void bitcast (void (i8*)* @test1a to void (i32 addrspace(1)*)*)(i32 addrspace(1)* %A)
+ ret void
+}
+
+; Test1, but the argument has a different sized address-space
+declare void @test1a_as1(i8 addrspace(1)*)
+
+; This one is OK to perform
+define void @test1_as1(i32 addrspace(1)* %A) {
+; CHECK-LABEL: @test1_as1(
+; CHECK: %1 = bitcast i32 addrspace(1)* %A to i8 addrspace(1)*
+; CHECK: call void @test1a_as1(i8 addrspace(1)* %1)
+; CHECK: ret void
+ call void bitcast (void (i8 addrspace(1)*)* @test1a_as1 to void (i32 addrspace(1)*)*)(i32 addrspace(1)* %A )
+ ret void
+}
+
+; More complex case, translate argument because of resolution. This is safe
; because we have the body of the function
define void @test2a(i8 %A) {
- ret void
+; CHECK-LABEL: @test2a(
; CHECK: ret void
+ ret void
}
define i32 @test2(i32 %A) {
- call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
- ret i32 %A
-; CHECK: %1 = trunc i32 %A to i8
-; CHECK: call void @test2a(i8 %1)
+; CHECK-LABEL: @test2(
+; CHECK: call void bitcast
; CHECK: ret i32 %A
+ call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
+ ret i32 %A
}
-; Resolving this should insert a cast from sbyte to int, following the C
+; Resolving this should insert a cast from sbyte to int, following the C
; promotion rules.
define void @test3a(i8, ...) {unreachable }
define void @test3(i8 %A, i8 %B) {
- call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B
-)
- ret void
+; CHECK-LABEL: @test3(
; CHECK: %1 = zext i8 %B to i32
; CHECK: call void (i8, ...)* @test3a(i8 %A, i32 %1)
; CHECK: ret void
+ call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B)
+ ret void
}
-
; test conversion of return value...
define i8 @test4a() {
- ret i8 0
+; CHECK-LABEL: @test4a(
; CHECK: ret i8 0
+ ret i8 0
}
define i32 @test4() {
- %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; <i32> [#uses=1]
- ret i32 %X
-; CHECK: %X = call i8 @test4a()
-; CHECK: %1 = zext i8 %X to i32
-; CHECK: ret i32 %1
+; CHECK-LABEL: @test4(
+; CHECK: call i32 bitcast
+ %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; <i32> [#uses=1]
+ ret i32 %X
}
-
-; test conversion of return value... no value conversion occurs so we can do
+; test conversion of return value... no value conversion occurs so we can do
; this with just a prototype...
declare i32 @test5a()
define i32 @test5() {
- %X = call i32 @test5a( ) ; <i32> [#uses=1]
- ret i32 %X
+; CHECK-LABEL: @test5(
; CHECK: %X = call i32 @test5a()
; CHECK: ret i32 %X
+ %X = call i32 @test5a( ) ; <i32> [#uses=1]
+ ret i32 %X
}
-
; test addition of new arguments...
declare i32 @test6a(i32)
define i32 @test6() {
- %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( )
- ret i32 %X
+; CHECK-LABEL: @test6(
; CHECK: %X = call i32 @test6a(i32 0)
; CHECK: ret i32 %X
+ %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( )
+ ret i32 %X
}
-
; test removal of arguments, only can happen with a function body
define void @test7a() {
- ret void
+; CHECK-LABEL: @test7a(
; CHECK: ret void
+ ret void
}
define void @test7() {
- call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
- ret void
+; CHECK-LABEL: @test7(
; CHECK: call void @test7a()
; CHECK: ret void
+ call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
+ ret void
}
@@ -100,6 +124,11 @@ define void @test7() {
declare void @test8a()
define i8* @test8() {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: invoke void @test8a()
+; Don't turn this into "unreachable": the callee and caller don't agree in
+; calling conv, but the implementation of test8a may actually end up using the
+; right calling conv.
invoke void @test8a()
to label %invoke.cont unwind label %try.handler
@@ -114,23 +143,136 @@ try.handler: ; preds = %entry
declare i32 @__gxx_personality_v0(...)
-; Don't turn this into "unreachable": the callee and caller don't agree in
-; calling conv, but the implementation of test8a may actually end up using the
-; right calling conv.
-; CHECK: @test8() {
-; CHECK-NEXT: invoke void @test8a()
-
-
-; Don't turn this into a direct call, because test9x is just a prototype and
+; Don't turn this into a direct call, because test9x is just a prototype and
; doing so will make it varargs.
; rdar://9038601
declare i8* @test9x(i8*, i8*, ...) noredzone
define i8* @test9(i8* %arg, i8* %tmp3) nounwind ssp noredzone {
+; CHECK-LABEL: @test9
entry:
%call = call i8* bitcast (i8* (i8*, i8*, ...)* @test9x to i8* (i8*, i8*)*)(i8* %arg, i8* %tmp3) noredzone
ret i8* %call
-; CHECK: @test9(
+; CHECK-LABEL: @test9(
; CHECK: call i8* bitcast
}
+
+; Parameter that's a vector of pointers
+declare void @test10a(<2 x i8*>)
+
+define void @test10(<2 x i32*> %A) {
+; CHECK-LABEL: @test10(
+; CHECK: %1 = bitcast <2 x i32*> %A to <2 x i8*>
+; CHECK: call void @test10a(<2 x i8*> %1)
+; CHECK: ret void
+ call void bitcast (void (<2 x i8*>)* @test10a to void (<2 x i32*>)*)(<2 x i32*> %A)
+ ret void
+}
+
+; Don't transform because different address spaces
+declare void @test10a_mixed_as(<2 x i8 addrspace(1)*>)
+
+define void @test10_mixed_as(<2 x i8*> %A) {
+; CHECK-LABEL: @test10_mixed_as(
+; CHECK: call void bitcast
+ call void bitcast (void (<2 x i8 addrspace(1)*>)* @test10a_mixed_as to void (<2 x i8*>)*)(<2 x i8*> %A)
+ ret void
+}
+
+; Return type that's a pointer
+define i8* @test11a() {
+ ret i8* zeroinitializer
+}
+
+define i32* @test11() {
+; CHECK-LABEL: @test11(
+; CHECK: %X = call i8* @test11a()
+; CHECK: %1 = bitcast i8* %X to i32*
+ %X = call i32* bitcast (i8* ()* @test11a to i32* ()*)()
+ ret i32* %X
+}
+
+; Return type that's a pointer with a different address space
+define i8 addrspace(1)* @test11a_mixed_as() {
+ ret i8 addrspace(1)* zeroinitializer
+}
+
+define i8* @test11_mixed_as() {
+; CHECK-LABEL: @test11_mixed_as(
+; CHECK: call i8* bitcast
+ %X = call i8* bitcast (i8 addrspace(1)* ()* @test11a_mixed_as to i8* ()*)()
+ ret i8* %X
+}
+
+; Return type that's a vector of pointers
+define <2 x i8*> @test12a() {
+ ret <2 x i8*> zeroinitializer
+}
+
+define <2 x i32*> @test12() {
+; CHECK-LABEL: @test12(
+; CHECK: %X = call <2 x i8*> @test12a()
+; CHECK: %1 = bitcast <2 x i8*> %X to <2 x i32*>
+ %X = call <2 x i32*> bitcast (<2 x i8*> ()* @test12a to <2 x i32*> ()*)()
+ ret <2 x i32*> %X
+}
+
+define <2 x i8 addrspace(1)*> @test12a_mixed_as() {
+ ret <2 x i8 addrspace(1)*> zeroinitializer
+}
+
+define <2 x i8*> @test12_mixed_as() {
+; CHECK-LABEL: @test12_mixed_as(
+; CHECK: call <2 x i8*> bitcast
+ %X = call <2 x i8*> bitcast (<2 x i8 addrspace(1)*> ()* @test12a_mixed_as to <2 x i8*> ()*)()
+ ret <2 x i8*> %X
+}
+
+
+; Mix parameter that's a vector of integers and pointers of the same size
+declare void @test13a(<2 x i64>)
+
+define void @test13(<2 x i32*> %A) {
+; CHECK-LABEL: @test13(
+; CHECK: call void bitcast
+ call void bitcast (void (<2 x i64>)* @test13a to void (<2 x i32*>)*)(<2 x i32*> %A)
+ ret void
+}
+
+; Mix parameter that's a vector of integers and pointers of the same
+; size, but the other way around
+declare void @test14a(<2 x i8*>)
+
+define void @test14(<2 x i64> %A) {
+; CHECK-LABEL: @test14(
+; CHECK: call void bitcast
+ call void bitcast (void (<2 x i8*>)* @test14a to void (<2 x i64>)*)(<2 x i64> %A)
+ ret void
+}
+
+
+; Return type that's a vector
+define <2 x i16> @test15a() {
+ ret <2 x i16> zeroinitializer
+}
+
+define i32 @test15() {
+; CHECK-LABEL: @test15(
+; CHECK: %X = call <2 x i16> @test15a()
+; CHECK: %1 = bitcast <2 x i16> %X to i32
+ %X = call i32 bitcast (<2 x i16> ()* @test15a to i32 ()*)( )
+ ret i32 %X
+}
+
+define i32 @test16a() {
+ ret i32 0
+}
+
+define <2 x i16> @test16() {
+; CHECK-LABEL: @test16(
+; CHECK: %X = call i32 @test16a()
+; CHECK: %1 = bitcast i32 %X to <2 x i16>
+ %X = call <2 x i16> bitcast (i32 ()* @test16a to <2 x i16> ()*)( )
+ ret <2 x i16> %X
+}
diff --git a/test/Transforms/InstCombine/canonicalize_branch.ll b/test/Transforms/InstCombine/canonicalize_branch.ll
index 869546d57dcd..b62b143d9d51 100644
--- a/test/Transforms/InstCombine/canonicalize_branch.ll
+++ b/test/Transforms/InstCombine/canonicalize_branch.ll
@@ -5,7 +5,7 @@ define i32 @test0(i32 %X, i32 %Y) {
%C = icmp eq i32 %X, %Y
br i1 %C, label %T, label %F, !prof !0
-; CHECK: @test0
+; CHECK-LABEL: @test0(
; CHECK: %C = icmp eq i32 %X, %Y
; CHECK: br i1 %C, label %T, label %F
@@ -19,7 +19,7 @@ define i32 @test1(i32 %X, i32 %Y) {
%C = icmp ne i32 %X, %Y
br i1 %C, label %T, label %F, !prof !1
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %C = icmp eq i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T
@@ -33,7 +33,7 @@ define i32 @test2(i32 %X, i32 %Y) {
%C = icmp ule i32 %X, %Y
br i1 %C, label %T, label %F, !prof !2
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: %C = icmp ugt i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T
@@ -47,7 +47,7 @@ define i32 @test3(i32 %X, i32 %Y) {
%C = icmp uge i32 %X, %Y
br i1 %C, label %T, label %F, !prof !3
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: %C = icmp ult i32 %X, %Y
; CHECK: br i1 %C, label %F, label %T
diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll
index de738bb7c06d..cac0ec109163 100644
--- a/test/Transforms/InstCombine/cast.ll
+++ b/test/Transforms/InstCombine/cast.ll
@@ -1,6 +1,6 @@
; Tests to make sure elimination of casts is working correctly
; RUN: opt < %s -instcombine -S | FileCheck %s
-target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64"
+target datalayout = "E-p:64:64:64-p1:32:32:32-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64"
@inbuf = external global [32832 x i8] ; <[32832 x i8]*> [#uses=1]
@@ -326,7 +326,7 @@ define i16 @test39(i16 %a) {
%tmp.upgrd.32 = or i32 %tmp21, %tmp5
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16
ret i16 %tmp.upgrd.3
-; CHECK: @test39
+; CHECK-LABEL: @test39(
; CHECK: %tmp.upgrd.32 = call i16 @llvm.bswap.i16(i16 %a)
; CHECK: ret i16 %tmp.upgrd.32
}
@@ -338,7 +338,7 @@ define i16 @test40(i16 %a) {
%tmp.upgrd.32 = or i32 %tmp21, %tmp5
%tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16
ret i16 %tmp.upgrd.3
-; CHECK: @test40
+; CHECK-LABEL: @test40(
; CHECK: %tmp21 = lshr i16 %a, 9
; CHECK: %tmp5 = shl i16 %a, 8
; CHECK: %tmp.upgrd.32 = or i16 %tmp21, %tmp5
@@ -350,7 +350,7 @@ define i32* @test41(i32* %tmp1) {
%tmp64 = bitcast i32* %tmp1 to { i32 }*
%tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0
ret i32* %tmp65
-; CHECK: @test41
+; CHECK-LABEL: @test41(
; CHECK: ret i32* %tmp1
}
@@ -358,7 +358,7 @@ define i32 @test42(i32 %X) {
%Y = trunc i32 %X to i8 ; <i8> [#uses=1]
%Z = zext i8 %Y to i32 ; <i32> [#uses=1]
ret i32 %Z
-; CHECK: @test42
+; CHECK-LABEL: @test42(
; CHECK: %Z = and i32 %X, 255
}
@@ -368,7 +368,7 @@ define zeroext i64 @test43(i8 zeroext %on_off) nounwind readonly {
%B = add i32 %A, -1
%C = sext i32 %B to i64
ret i64 %C ;; Should be (add (zext i8 -> i64), -1)
-; CHECK: @test43
+; CHECK-LABEL: @test43(
; CHECK-NEXT: %A = zext i8 %on_off to i64
; CHECK-NEXT: %B = add i64 %A, -1
; CHECK-NEXT: ret i64 %B
@@ -379,7 +379,7 @@ define i64 @test44(i8 %T) {
%B = or i16 %A, 1234
%C = zext i16 %B to i64
ret i64 %C
-; CHECK: @test44
+; CHECK-LABEL: @test44(
; CHECK-NEXT: %A = zext i8 %T to i64
; CHECK-NEXT: %B = or i64 %A, 1234
; CHECK-NEXT: ret i64 %B
@@ -391,7 +391,7 @@ define i64 @test45(i8 %A, i64 %Q) {
%C = or i32 %B, %D
%E = zext i32 %C to i64
ret i64 %E
-; CHECK: @test45
+; CHECK-LABEL: @test45(
; CHECK-NEXT: %B = sext i8 %A to i64
; CHECK-NEXT: %C = or i64 %B, %Q
; CHECK-NEXT: %E = and i64 %C, 4294967295
@@ -405,7 +405,7 @@ define i64 @test46(i64 %A) {
%D = shl i32 %C, 8
%E = zext i32 %D to i64
ret i64 %E
-; CHECK: @test46
+; CHECK-LABEL: @test46(
; CHECK-NEXT: %C = shl i64 %A, 8
; CHECK-NEXT: %D = and i64 %C, 10752
; CHECK-NEXT: ret i64 %D
@@ -416,7 +416,7 @@ define i64 @test47(i8 %A) {
%C = or i32 %B, 42
%E = zext i32 %C to i64
ret i64 %E
-; CHECK: @test47
+; CHECK-LABEL: @test47(
; CHECK-NEXT: %B = sext i8 %A to i64
; CHECK-NEXT: %C = and i64 %B, 4294967253
; CHECK-NEXT: %E = or i64 %C, 42
@@ -430,7 +430,7 @@ define i64 @test48(i8 %A, i8 %a) {
%D = or i32 %C, %b
%E = zext i32 %D to i64
ret i64 %E
-; CHECK: @test48
+; CHECK-LABEL: @test48(
; CHECK-NEXT: %b = zext i8 %a to i64
; CHECK-NEXT: %B = zext i8 %A to i64
; CHECK-NEXT: %C = shl nuw nsw i64 %B, 8
@@ -443,7 +443,7 @@ define i64 @test49(i64 %A) {
%C = or i32 %B, 1
%D = sext i32 %C to i64
ret i64 %D
-; CHECK: @test49
+; CHECK-LABEL: @test49(
; CHECK-NEXT: %C = shl i64 %A, 32
; CHECK-NEXT: ashr exact i64 %C, 32
; CHECK-NEXT: %D = or i64 {{.*}}, 1
@@ -456,7 +456,7 @@ define i64 @test50(i64 %A) {
%D = add i32 %B, -1
%E = sext i32 %D to i64
ret i64 %E
-; CHECK: @test50
+; CHECK-LABEL: @test50(
; lshr+shl will be handled by DAGCombine.
; CHECK-NEXT: lshr i64 %A, 2
; CHECK-NEXT: shl i64 %a, 32
@@ -472,7 +472,7 @@ define i64 @test51(i64 %A, i1 %cond) {
%E = select i1 %cond, i32 %C, i32 %D
%F = sext i32 %E to i64
ret i64 %F
-; CHECK: @test51
+; CHECK-LABEL: @test51(
; CHECK-NEXT: %C = and i64 %A, 4294967294
; CHECK-NEXT: %D = or i64 %A, 1
; CHECK-NEXT: %E = select i1 %cond, i64 %C, i64 %D
@@ -487,7 +487,7 @@ define i32 @test52(i64 %A) {
%D = and i16 %C, -25350
%E = zext i16 %D to i32
ret i32 %E
-; CHECK: @test52
+; CHECK-LABEL: @test52(
; CHECK-NEXT: %B = trunc i64 %A to i32
; CHECK-NEXT: %C = and i32 %B, 7224
; CHECK-NEXT: %D = or i32 %C, 32962
@@ -500,7 +500,7 @@ define i64 @test53(i32 %A) {
%D = and i16 %C, -25350
%E = zext i16 %D to i64
ret i64 %E
-; CHECK: @test53
+; CHECK-LABEL: @test53(
; CHECK-NEXT: %B = zext i32 %A to i64
; CHECK-NEXT: %C = and i64 %B, 7224
; CHECK-NEXT: %D = or i64 %C, 32962
@@ -513,7 +513,7 @@ define i32 @test54(i64 %A) {
%D = and i16 %C, -25350
%E = sext i16 %D to i32
ret i32 %E
-; CHECK: @test54
+; CHECK-LABEL: @test54(
; CHECK-NEXT: %B = trunc i64 %A to i32
; CHECK-NEXT: %C = and i32 %B, 7224
; CHECK-NEXT: %D = or i32 %C, -32574
@@ -526,7 +526,7 @@ define i64 @test55(i32 %A) {
%D = and i16 %C, -25350
%E = sext i16 %D to i64
ret i64 %E
-; CHECK: @test55
+; CHECK-LABEL: @test55(
; CHECK-NEXT: %B = zext i32 %A to i64
; CHECK-NEXT: %C = and i64 %B, 7224
; CHECK-NEXT: %D = or i64 %C, -32574
@@ -538,7 +538,7 @@ define i64 @test56(i16 %A) nounwind {
%tmp354 = lshr i32 %tmp353, 5
%tmp355 = zext i32 %tmp354 to i64
ret i64 %tmp355
-; CHECK: @test56
+; CHECK-LABEL: @test56(
; CHECK-NEXT: %tmp353 = sext i16 %A to i64
; CHECK-NEXT: %tmp354 = lshr i64 %tmp353, 5
; CHECK-NEXT: %tmp355 = and i64 %tmp354, 134217727
@@ -550,7 +550,7 @@ define i64 @test57(i64 %A) nounwind {
%C = lshr i32 %B, 8
%E = zext i32 %C to i64
ret i64 %E
-; CHECK: @test57
+; CHECK-LABEL: @test57(
; CHECK-NEXT: %C = lshr i64 %A, 8
; CHECK-NEXT: %E = and i64 %C, 16777215
; CHECK-NEXT: ret i64 %E
@@ -563,7 +563,7 @@ define i64 @test58(i64 %A) nounwind {
%E = zext i32 %D to i64
ret i64 %E
-; CHECK: @test58
+; CHECK-LABEL: @test58(
; CHECK-NEXT: %C = lshr i64 %A, 8
; CHECK-NEXT: %D = and i64 %C, 16777087
; CHECK-NEXT: %E = or i64 %D, 128
@@ -579,7 +579,7 @@ define i64 @test59(i8 %A, i8 %B) nounwind {
%H = or i32 %G, %E
%I = zext i32 %H to i64
ret i64 %I
-; CHECK: @test59
+; CHECK-LABEL: @test59(
; CHECK-NEXT: %C = zext i8 %A to i64
; CHECK-NOT: i32
; CHECK: %F = zext i8 %B to i64
@@ -593,7 +593,7 @@ define <3 x i32> @test60(<4 x i32> %call4) nounwind {
%tmp10 = bitcast i96 %tmp9 to <3 x i32>
ret <3 x i32> %tmp10
-; CHECK: @test60
+; CHECK-LABEL: @test60(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
}
@@ -603,7 +603,7 @@ define <4 x i32> @test61(<3 x i32> %call4) nounwind {
%tmp9 = zext i96 %tmp11 to i128
%tmp10 = bitcast i128 %tmp9 to <4 x i32>
ret <4 x i32> %tmp10
-; CHECK: @test61
+; CHECK-LABEL: @test61(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
}
@@ -613,7 +613,7 @@ define <4 x i32> @test62(<3 x float> %call4) nounwind {
%tmp9 = zext i96 %tmp11 to i128
%tmp10 = bitcast i128 %tmp9 to <4 x i32>
ret <4 x i32> %tmp10
-; CHECK: @test62
+; CHECK-LABEL: @test62(
; CHECK-NEXT: bitcast
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
@@ -625,7 +625,7 @@ entry:
%a = bitcast i64 %tmp8 to <2 x i32>
%vcvt.i = uitofp <2 x i32> %a to <2 x float>
ret <2 x float> %vcvt.i
-; CHECK: @test63
+; CHECK-LABEL: @test63(
; CHECK: bitcast
; CHECK: uitofp
}
@@ -634,7 +634,7 @@ define <4 x float> @test64(<4 x float> %c) nounwind {
%t0 = bitcast <4 x float> %c to <4 x i32>
%t1 = bitcast <4 x i32> %t0 to <4 x float>
ret <4 x float> %t1
-; CHECK: @test64
+; CHECK-LABEL: @test64(
; CHECK-NEXT: ret <4 x float> %c
}
@@ -642,7 +642,7 @@ define <4 x float> @test65(<4 x float> %c) nounwind {
%t0 = bitcast <4 x float> %c to <2 x double>
%t1 = bitcast <2 x double> %t0 to <4 x float>
ret <4 x float> %t1
-; CHECK: @test65
+; CHECK-LABEL: @test65(
; CHECK-NEXT: ret <4 x float> %c
}
@@ -650,13 +650,13 @@ define <2 x float> @test66(<2 x float> %c) nounwind {
%t0 = bitcast <2 x float> %c to double
%t1 = bitcast double %t0 to <2 x float>
ret <2 x float> %t1
-; CHECK: @test66
+; CHECK-LABEL: @test66(
; CHECK-NEXT: ret <2 x float> %c
}
define float @test2c() {
ret float extractelement (<2 x float> bitcast (double bitcast (<2 x float> <float -1.000000e+00, float -1.000000e+00> to double) to <2 x float>), i32 0)
-; CHECK: @test2c
+; CHECK-LABEL: @test2c(
; CHECK-NOT: extractelement
}
@@ -665,7 +665,7 @@ define i64 @test_mmx(<2 x i32> %c) nounwind {
%B = bitcast x86_mmx %A to <2 x i32>
%C = bitcast <2 x i32> %B to i64
ret i64 %C
-; CHECK: @test_mmx
+; CHECK-LABEL: @test_mmx(
; CHECK-NOT: x86_mmx
}
@@ -674,7 +674,7 @@ define i64 @test_mmx_const(<2 x i32> %c) nounwind {
%B = bitcast x86_mmx %A to <2 x i32>
%C = bitcast <2 x i32> %B to i64
ret i64 %C
-; CHECK: @test_mmx_const
+; CHECK-LABEL: @test_mmx_const(
; CHECK-NOT: x86_mmx
}
@@ -689,14 +689,14 @@ define i1 @test67(i1 %a, i32 %b) {
%trunc = trunc i32 %conv.i.i to i8
%tobool.i = icmp eq i8 %trunc, 0
ret i1 %tobool.i
-; CHECK: @test67
+; CHECK-LABEL: @test67(
; CHECK: ret i1 false
}
%s = type { i32, i32, i32 }
define %s @test68(%s *%p, i64 %i) {
-; CHECK: @test68
+; CHECK-LABEL: @test68(
%o = mul i64 %i, 12
%q = bitcast %s* %p to i8*
%pp = getelementptr inbounds i8* %q, i64 %o
@@ -708,8 +708,21 @@ define %s @test68(%s *%p, i64 %i) {
; CHECK-NEXT: ret %s
}
+define %s @test68_as1(%s addrspace(1)* %p, i32 %i) {
+; CHECK-LABEL: @test68_as1(
+ %o = mul i32 %i, 12
+ %q = bitcast %s addrspace(1)* %p to i8 addrspace(1)*
+ %pp = getelementptr inbounds i8 addrspace(1)* %q, i32 %o
+; CHECK-NEXT: getelementptr %s addrspace(1)*
+ %r = bitcast i8 addrspace(1)* %pp to %s addrspace(1)*
+ %l = load %s addrspace(1)* %r
+; CHECK-NEXT: load %s addrspace(1)*
+ ret %s %l
+; CHECK-NEXT: ret %s
+}
+
define double @test69(double *%p, i64 %i) {
-; CHECK: @test69
+; CHECK-LABEL: @test69(
%o = shl nsw i64 %i, 3
%q = bitcast double* %p to i8*
%pp = getelementptr inbounds i8* %q, i64 %o
@@ -722,7 +735,7 @@ define double @test69(double *%p, i64 %i) {
}
define %s @test70(%s *%p, i64 %i) {
-; CHECK: @test70
+; CHECK-LABEL: @test70(
%o = mul nsw i64 %i, 36
; CHECK-NEXT: mul nsw i64 %i, 3
%q = bitcast %s* %p to i8*
@@ -736,7 +749,7 @@ define %s @test70(%s *%p, i64 %i) {
}
define double @test71(double *%p, i64 %i) {
-; CHECK: @test71
+; CHECK-LABEL: @test71(
%o = shl i64 %i, 5
; CHECK-NEXT: shl i64 %i, 2
%q = bitcast double* %p to i8*
@@ -750,7 +763,7 @@ define double @test71(double *%p, i64 %i) {
}
define double @test72(double *%p, i32 %i) {
-; CHECK: @test72
+; CHECK-LABEL: @test72(
%so = mul nsw i32 %i, 8
%o = sext i32 %so to i64
; CHECK-NEXT: sext i32 %i to i64
@@ -765,7 +778,7 @@ define double @test72(double *%p, i32 %i) {
}
define double @test73(double *%p, i128 %i) {
-; CHECK: @test73
+; CHECK-LABEL: @test73(
%lo = mul nsw i128 %i, 8
%o = trunc i128 %lo to i64
; CHECK-NEXT: trunc i128 %i to i64
@@ -780,7 +793,7 @@ define double @test73(double *%p, i128 %i) {
}
define double @test74(double *%p, i64 %i) {
-; CHECK: @test74
+; CHECK-LABEL: @test74(
%q = bitcast double* %p to i64*
%pp = getelementptr inbounds i64* %q, i64 %i
; CHECK-NEXT: getelementptr inbounds double*
@@ -792,7 +805,7 @@ define double @test74(double *%p, i64 %i) {
}
define i32* @test75(i32* %p, i32 %x) {
-; CHECK: @test75
+; CHECK-LABEL: @test75(
%y = shl i32 %x, 3
; CHECK-NEXT: shl i32 %x, 3
%z = sext i32 %y to i64
@@ -804,7 +817,7 @@ define i32* @test75(i32* %p, i32 %x) {
}
define %s @test76(%s *%p, i64 %i, i64 %j) {
-; CHECK: @test76
+; CHECK-LABEL: @test76(
%o = mul i64 %i, 12
%o2 = mul nsw i64 %o, %j
; CHECK-NEXT: %o2 = mul i64 %i, %j
@@ -819,7 +832,7 @@ define %s @test76(%s *%p, i64 %i, i64 %j) {
}
define %s @test77(%s *%p, i64 %i, i64 %j) {
-; CHECK: @test77
+; CHECK-LABEL: @test77(
%o = mul nsw i64 %i, 36
%o2 = mul nsw i64 %o, %j
; CHECK-NEXT: %o = mul nsw i64 %i, 3
@@ -835,7 +848,7 @@ define %s @test77(%s *%p, i64 %i, i64 %j) {
}
define %s @test78(%s *%p, i64 %i, i64 %j, i32 %k, i32 %l, i128 %m, i128 %n) {
-; CHECK: @test78
+; CHECK-LABEL: @test78(
%a = mul nsw i32 %k, 36
; CHECK-NEXT: mul nsw i32 %k, 3
%b = mul nsw i32 %a, %l
@@ -863,7 +876,7 @@ define %s @test78(%s *%p, i64 %i, i64 %j, i32 %k, i32 %l, i128 %m, i128 %n) {
}
define %s @test79(%s *%p, i64 %i, i32 %j) {
-; CHECK: @test79
+; CHECK-LABEL: @test79(
%a = mul nsw i64 %i, 36
; CHECK: mul nsw i64 %i, 36
%b = trunc i64 %a to i32
@@ -877,7 +890,7 @@ define %s @test79(%s *%p, i64 %i, i32 %j) {
}
define double @test80([100 x double]* %p, i32 %i) {
-; CHECK: @test80
+; CHECK-LABEL: @test80(
%tmp = mul nsw i32 %i, 8
; CHECK-NEXT: sext i32 %i to i64
%q = bitcast [100 x double]* %p to i8*
@@ -890,6 +903,20 @@ define double @test80([100 x double]* %p, i32 %i) {
; CHECK-NEXT: ret double
}
+define double @test80_as1([100 x double] addrspace(1)* %p, i16 %i) {
+; CHECK-LABEL: @test80_as1(
+ %tmp = mul nsw i16 %i, 8
+; CHECK-NEXT: sext i16 %i to i32
+ %q = bitcast [100 x double] addrspace(1)* %p to i8 addrspace(1)*
+ %pp = getelementptr i8 addrspace(1)* %q, i16 %tmp
+; CHECK-NEXT: getelementptr [100 x double] addrspace(1)*
+ %r = bitcast i8 addrspace(1)* %pp to double addrspace(1)*
+ %l = load double addrspace(1)* %r
+; CHECK-NEXT: load double addrspace(1)*
+ ret double %l
+; CHECK-NEXT: ret double
+}
+
define double @test81(double *%p, float %f) {
%i = fptosi float %f to i64
%q = bitcast double* %p to i8*
@@ -898,3 +925,31 @@ define double @test81(double *%p, float %f) {
%l = load double* %r
ret double %l
}
+
+define i64 @test82(i64 %A) nounwind {
+ %B = trunc i64 %A to i32
+ %C = lshr i32 %B, 8
+ %D = shl i32 %C, 9
+ %E = zext i32 %D to i64
+ ret i64 %E
+
+; CHECK-LABEL: @test82(
+; CHECK-NEXT: [[REG:%[0-9]*]] = shl i64 %A, 1
+; CHECK-NEXT: %E = and i64 [[REG]], 4294966784
+; CHECK-NEXT: ret i64 %E
+}
+
+; PR15959
+define i64 @test83(i16 %a, i64 %k) {
+ %conv = sext i16 %a to i32
+ %sub = add nsw i64 %k, -1
+ %sh_prom = trunc i64 %sub to i32
+ %shl = shl i32 %conv, %sh_prom
+ %sh_prom1 = zext i32 %shl to i64
+ ret i64 %sh_prom1
+
+; CHECK-LABEL: @test83(
+; CHECK: %sub = add nsw i64 %k, 4294967295
+; CHECK: %sh_prom = trunc i64 %sub to i32
+; CHECK: %shl = shl i32 %conv, %sh_prom
+}
diff --git a/test/Transforms/InstCombine/cast_ptr.ll b/test/Transforms/InstCombine/cast_ptr.ll
index 09910fbc8481..23006a84604b 100644
--- a/test/Transforms/InstCombine/cast_ptr.ll
+++ b/test/Transforms/InstCombine/cast_ptr.ll
@@ -1,12 +1,12 @@
; Tests to make sure elimination of casts is working correctly
; RUN: opt < %s -instcombine -S | FileCheck %s
-target datalayout = "p:32:32"
+target datalayout = "p:32:32-p1:32:32-p2:16:16"
; This shouldn't convert to getelementptr because the relationship
; between the arithmetic and the layout of allocated memory is
; entirely unknown.
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ptrtoint
; CHECK: add
; CHECK: inttoptr
@@ -18,7 +18,7 @@ define i8* @test1(i8* %t) {
}
; These casts should be folded away.
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: icmp eq i8* %a, %b
define i1 @test2(i8* %a, i8* %b) {
%tmpa = ptrtoint i8* %a to i32 ; <i32> [#uses=1]
@@ -27,8 +27,28 @@ define i1 @test2(i8* %a, i8* %b) {
ret i1 %r
}
+; These casts should be folded away.
+; CHECK-LABEL: @test2_as2_same_int(
+; CHECK: icmp eq i8 addrspace(2)* %a, %b
+define i1 @test2_as2_same_int(i8 addrspace(2)* %a, i8 addrspace(2)* %b) {
+ %tmpa = ptrtoint i8 addrspace(2)* %a to i16
+ %tmpb = ptrtoint i8 addrspace(2)* %b to i16
+ %r = icmp eq i16 %tmpa, %tmpb
+ ret i1 %r
+}
+
+; These casts should be folded away.
+; CHECK-LABEL: @test2_as2_larger(
+; CHECK: icmp eq i8 addrspace(2)* %a, %b
+define i1 @test2_as2_larger(i8 addrspace(2)* %a, i8 addrspace(2)* %b) {
+ %tmpa = ptrtoint i8 addrspace(2)* %a to i32
+ %tmpb = ptrtoint i8 addrspace(2)* %b to i32
+ %r = icmp eq i32 %tmpa, %tmpb
+ ret i1 %r
+}
+
; These casts should also be folded away.
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: icmp eq i8* %a, @global
@global = global i8 0
define i1 @test3(i8* %a) {
@@ -41,13 +61,22 @@ define i1 @test4(i32 %A) {
%B = inttoptr i32 %A to i8*
%C = icmp eq i8* %B, null
ret i1 %C
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: %C = icmp eq i32 %A, 0
-; CHECK-NEXT: ret i1 %C
+; CHECK-NEXT: ret i1 %C
}
+define i1 @test4_as2(i16 %A) {
+; CHECK-LABEL: @test4_as2(
+; CHECK-NEXT: %C = icmp eq i16 %A, 0
+; CHECK-NEXT: ret i1 %C
+ %B = inttoptr i16 %A to i8 addrspace(2)*
+ %C = icmp eq i8 addrspace(2)* %B, null
+ ret i1 %C
+}
-; Pulling the cast out of the load allows us to eliminate the load, and then
+
+; Pulling the cast out of the load allows us to eliminate the load, and then
; the whole array.
%op = type { float }
@@ -60,7 +89,7 @@ define %unop* @test5(%op* %O) {
%tmp = load %unop* (%op*)** bitcast ([1 x %op* (%op*)*]* @Array to %unop* (%op*)**); <%unop* (%op*)*> [#uses=1]
%tmp.2 = call %unop* %tmp( %op* %O ) ; <%unop*> [#uses=1]
ret %unop* %tmp.2
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: call %op* @foo(%op* %O)
}
@@ -69,11 +98,11 @@ define %unop* @test5(%op* %O) {
; InstCombine can not 'load (cast P)' -> cast (load P)' if the cast changes
; the address space.
-define i8 @test6(i8 addrspace(1)* %source) {
-entry:
- %arrayidx223 = bitcast i8 addrspace(1)* %source to i8*
+define i8 @test6(i8 addrspace(1)* %source) {
+entry:
+ %arrayidx223 = addrspacecast i8 addrspace(1)* %source to i8*
%tmp4 = load i8* %arrayidx223
ret i8 %tmp4
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: load i8* %arrayidx223
-}
+}
diff --git a/test/Transforms/InstCombine/compare-signs.ll b/test/Transforms/InstCombine/compare-signs.ll
index 72db66e3ab0f..62cd5b3f94d5 100644
--- a/test/Transforms/InstCombine/compare-signs.ll
+++ b/test/Transforms/InstCombine/compare-signs.ll
@@ -22,11 +22,11 @@
;}
define i32 @test3(i32 %a, i32 %b) nounwind readnone {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
entry:
-; CHECK: xor i32 %a, %b
-; CHECK: lshr i32 %0, 31
-; CHECK: xor i32 %1, 1
+; CHECK: [[XOR1:%.*]] = xor i32 %a, %b
+; CHECK: [[SHIFT:%.*]] = lshr i32 [[XOR1]], 31
+; CHECK: [[XOR2:%.*]] = xor i32 [[SHIFT]], 1
%0 = lshr i32 %a, 31 ; <i32> [#uses=1]
%1 = lshr i32 %b, 31 ; <i32> [#uses=1]
%2 = icmp eq i32 %0, %1 ; <i1> [#uses=1]
@@ -34,13 +34,13 @@ entry:
ret i32 %3
; CHECK-NOT: icmp
; CHECK-NOT: zext
-; CHECK: ret i32 %2
+; CHECK: ret i32 [[XOR2]]
}
; Variation on @test3: checking the 2nd bit in a situation where the 5th bit
; is one, not zero.
define i32 @test3i(i32 %a, i32 %b) nounwind readnone {
-; CHECK: @test3i
+; CHECK-LABEL: @test3i(
entry:
; CHECK: xor i32 %a, %b
; CHECK: lshr i32 %0, 31
diff --git a/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll b/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll
new file mode 100644
index 000000000000..9f21d5419b72
--- /dev/null
+++ b/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll
@@ -0,0 +1,232 @@
+; RUN: opt -S -instcombine %s -o - | FileCheck %s
+target datalayout = "e-p:32:32:32-p1:64:64:64-p2:8:8:8-p3:16:16:16-p4:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
+
+@g = addrspace(3) global i32 89
+
+@const_zero_i8_as1 = addrspace(1) constant i8 0
+@const_zero_i32_as1 = addrspace(1) constant i32 0
+
+@const_zero_i8_as2 = addrspace(2) constant i8 0
+@const_zero_i32_as2 = addrspace(2) constant i32 0
+
+@const_zero_i8_as3 = addrspace(3) constant i8 0
+@const_zero_i32_as3 = addrspace(3) constant i32 0
+
+; Test constant folding of inttoptr (ptrtoint constantexpr)
+; The intermediate integer size is the same as the pointer size
+define i32 addrspace(3)* @test_constant_fold_inttoptr_as_pointer_same_size() {
+; CHECK-LABEL: @test_constant_fold_inttoptr_as_pointer_same_size(
+; CHECK-NEXT: ret i32 addrspace(3)* @const_zero_i32_as3
+ %x = ptrtoint i32 addrspace(3)* @const_zero_i32_as3 to i32
+ %y = inttoptr i32 %x to i32 addrspace(3)*
+ ret i32 addrspace(3)* %y
+}
+
+; The intermediate integer size is larger than the pointer size
+define i32 addrspace(2)* @test_constant_fold_inttoptr_as_pointer_smaller() {
+; CHECK-LABEL: @test_constant_fold_inttoptr_as_pointer_smaller(
+; CHECK-NEXT: ret i32 addrspace(2)* @const_zero_i32_as2
+ %x = ptrtoint i32 addrspace(2)* @const_zero_i32_as2 to i16
+ %y = inttoptr i16 %x to i32 addrspace(2)*
+ ret i32 addrspace(2)* %y
+}
+
+; Different address spaces that are the same size, but they are
+; different so nothing should happen
+define i32 addrspace(4)* @test_constant_fold_inttoptr_as_pointer_smaller_different_as() {
+; CHECK-LABEL: @test_constant_fold_inttoptr_as_pointer_smaller_different_as(
+; CHECK-NEXT: ret i32 addrspace(4)* inttoptr (i16 ptrtoint (i32 addrspace(3)* @const_zero_i32_as3 to i16) to i32 addrspace(4)*)
+ %x = ptrtoint i32 addrspace(3)* @const_zero_i32_as3 to i16
+ %y = inttoptr i16 %x to i32 addrspace(4)*
+ ret i32 addrspace(4)* %y
+}
+
+; Make sure we don't introduce a bitcast between different sized
+; address spaces when folding this
+define i32 addrspace(2)* @test_constant_fold_inttoptr_as_pointer_smaller_different_size_as() {
+; CHECK-LABEL: @test_constant_fold_inttoptr_as_pointer_smaller_different_size_as(
+; CHECK-NEXT: ret i32 addrspace(2)* inttoptr (i32 ptrtoint (i32 addrspace(3)* @const_zero_i32_as3 to i32) to i32 addrspace(2)*)
+ %x = ptrtoint i32 addrspace(3)* @const_zero_i32_as3 to i32
+ %y = inttoptr i32 %x to i32 addrspace(2)*
+ ret i32 addrspace(2)* %y
+}
+
+; The intermediate integer size is too small, nothing should happen
+define i32 addrspace(3)* @test_constant_fold_inttoptr_as_pointer_larger() {
+; CHECK-LABEL: @test_constant_fold_inttoptr_as_pointer_larger(
+; CHECK-NEXT: ret i32 addrspace(3)* inttoptr (i8 ptrtoint (i32 addrspace(3)* @const_zero_i32_as3 to i8) to i32 addrspace(3)*)
+ %x = ptrtoint i32 addrspace(3)* @const_zero_i32_as3 to i8
+ %y = inttoptr i8 %x to i32 addrspace(3)*
+ ret i32 addrspace(3)* %y
+}
+
+define i8 @const_fold_ptrtoint() {
+; CHECK-LABEL: @const_fold_ptrtoint(
+; CHECK-NEXT: ret i8 4
+ ret i8 ptrtoint (i32 addrspace(2)* inttoptr (i4 4 to i32 addrspace(2)*) to i8)
+}
+
+; Test that mask happens when the destination pointer is smaller than
+; the original
+define i8 @const_fold_ptrtoint_mask() {
+; CHECK-LABEL: @const_fold_ptrtoint_mask(
+; CHECK-NEXT: ret i8 1
+ ret i8 ptrtoint (i32 addrspace(3)* inttoptr (i32 257 to i32 addrspace(3)*) to i8)
+}
+
+; Address space 0 is too small for the correct mask, should mask with
+; 64-bits instead of 32
+define i64 @const_fold_ptrtoint_mask_small_as0() {
+; CHECK-LABEL: @const_fold_ptrtoint_mask_small_as0(
+; CHECK: ret i64 -1
+ ret i64 ptrtoint (i32 addrspace(1)* inttoptr (i128 -1 to i32 addrspace(1)*) to i64)
+}
+
+define i32 addrspace(3)* @const_inttoptr() {
+; CHECK-LABEL: @const_inttoptr(
+; CHECK-NEXT: ret i32 addrspace(3)* inttoptr (i16 4 to i32 addrspace(3)*)
+ %p = inttoptr i16 4 to i32 addrspace(3)*
+ ret i32 addrspace(3)* %p
+}
+
+define i16 @const_ptrtoint() {
+; CHECK-LABEL: @const_ptrtoint(
+; CHECK-NEXT: ret i16 ptrtoint (i32 addrspace(3)* @g to i16)
+ %i = ptrtoint i32 addrspace(3)* @g to i16
+ ret i16 %i
+}
+
+define i16 @const_inttoptr_ptrtoint() {
+; CHECK-LABEL: @const_inttoptr_ptrtoint(
+; CHECK-NEXT: ret i16 9
+ ret i16 ptrtoint (i32 addrspace(3)* inttoptr (i16 9 to i32 addrspace(3)*) to i16)
+}
+
+define i1 @constant_fold_cmp_constantexpr_inttoptr() {
+; CHECK-LABEL: @constant_fold_cmp_constantexpr_inttoptr(
+; CHECK-NEXT: ret i1 true
+ %x = icmp eq i32 addrspace(3)* inttoptr (i16 0 to i32 addrspace(3)*), null
+ ret i1 %x
+}
+
+define i1 @constant_fold_inttoptr_null(i16 %i) {
+; CHECK-LABEL: @constant_fold_inttoptr_null(
+; CHECK-NEXT: ret i1 false
+ %x = icmp eq i32 addrspace(3)* inttoptr (i16 99 to i32 addrspace(3)*), inttoptr (i16 0 to i32 addrspace(3)*)
+ ret i1 %x
+}
+
+define i1 @constant_fold_ptrtoint_null() {
+; CHECK-LABEL: @constant_fold_ptrtoint_null(
+; CHECK-NEXT: ret i1 false
+ %x = icmp eq i16 ptrtoint (i32 addrspace(3)* @g to i16), ptrtoint (i32 addrspace(3)* null to i16)
+ ret i1 %x
+}
+
+define i1 @constant_fold_ptrtoint_null_2() {
+; CHECK-LABEL: @constant_fold_ptrtoint_null_2(
+; CHECK-NEXT: ret i1 false
+ %x = icmp eq i16 ptrtoint (i32 addrspace(3)* null to i16), ptrtoint (i32 addrspace(3)* @g to i16)
+ ret i1 %x
+}
+
+define i1 @constant_fold_ptrtoint() {
+; CHECK-LABEL: @constant_fold_ptrtoint(
+; CHECK-NEXT: ret i1 true
+ %x = icmp eq i16 ptrtoint (i32 addrspace(3)* @g to i16), ptrtoint (i32 addrspace(3)* @g to i16)
+ ret i1 %x
+}
+
+define i1 @constant_fold_inttoptr() {
+; CHECK-LABEL: @constant_fold_inttoptr(
+; CHECK-NEXT: ret i1 false
+ %x = icmp eq i32 addrspace(3)* inttoptr (i16 99 to i32 addrspace(3)*), inttoptr (i16 27 to i32 addrspace(3)*)
+ ret i1 %x
+}
+
+@g_float_as3 = addrspace(3) global float zeroinitializer
+@g_v4f_as3 = addrspace(3) global <4 x float> zeroinitializer
+
+define float @constant_fold_bitcast_ftoi_load() {
+; CHECK-LABEL: @constant_fold_bitcast_ftoi_load(
+; CHECK: load float addrspace(3)* bitcast (i32 addrspace(3)* @g to float addrspace(3)*), align 4
+ %a = load float addrspace(3)* bitcast (i32 addrspace(3)* @g to float addrspace(3)*), align 4
+ ret float %a
+}
+
+define i32 @constant_fold_bitcast_itof_load() {
+; CHECK-LABEL: @constant_fold_bitcast_itof_load(
+; CHECK: load i32 addrspace(3)* bitcast (float addrspace(3)* @g_float_as3 to i32 addrspace(3)*), align 4
+ %a = load i32 addrspace(3)* bitcast (float addrspace(3)* @g_float_as3 to i32 addrspace(3)*), align 4
+ ret i32 %a
+}
+
+define <4 x i32> @constant_fold_bitcast_vector_as() {
+; CHECK-LABEL: @constant_fold_bitcast_vector_as(
+; CHECK: load <4 x float> addrspace(3)* @g_v4f_as3, align 16
+; CHECK: bitcast <4 x float> %1 to <4 x i32>
+ %a = load <4 x i32> addrspace(3)* bitcast (<4 x float> addrspace(3)* @g_v4f_as3 to <4 x i32> addrspace(3)*), align 4
+ ret <4 x i32> %a
+}
+
+@i32_array_as3 = addrspace(3) global [10 x i32] zeroinitializer
+
+define i32 @test_cast_gep_small_indices_as() {
+; CHECK-LABEL: @test_cast_gep_small_indices_as(
+; CHECK: load i32 addrspace(3)* getelementptr inbounds ([10 x i32] addrspace(3)* @i32_array_as3, i16 0, i16 0), align 16
+ %p = getelementptr [10 x i32] addrspace(3)* @i32_array_as3, i7 0, i7 0
+ %x = load i32 addrspace(3)* %p, align 4
+ ret i32 %x
+}
+
+%struct.foo = type { float, float, [4 x i32], i32 addrspace(3)* }
+
+@constant_fold_global_ptr = addrspace(3) global %struct.foo {
+ float 0.0,
+ float 0.0,
+ [4 x i32] zeroinitializer,
+ i32 addrspace(3)* getelementptr ([10 x i32] addrspace(3)* @i32_array_as3, i64 0, i64 0)
+}
+
+define i32 @test_cast_gep_large_indices_as() {
+; CHECK-LABEL: @test_cast_gep_large_indices_as(
+; CHECK: load i32 addrspace(3)* getelementptr inbounds ([10 x i32] addrspace(3)* @i32_array_as3, i16 0, i16 0), align 16
+ %p = getelementptr [10 x i32] addrspace(3)* @i32_array_as3, i64 0, i64 0
+ %x = load i32 addrspace(3)* %p, align 4
+ ret i32 %x
+}
+
+define i32 @test_constant_cast_gep_struct_indices_as() {
+; CHECK-LABEL: @test_constant_cast_gep_struct_indices_as(
+; CHECK: load i32 addrspace(3)* getelementptr inbounds (%struct.foo addrspace(3)* @constant_fold_global_ptr, i16 0, i32 2, i16 2), align 8
+ %x = getelementptr %struct.foo addrspace(3)* @constant_fold_global_ptr, i18 0, i32 2, i12 2
+ %y = load i32 addrspace(3)* %x, align 4
+ ret i32 %y
+}
+
+@constant_data_as3 = addrspace(3) constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
+
+define i32 @test_read_data_from_global_as3() {
+; CHECK-LABEL: @test_read_data_from_global_as3(
+; CHECK-NEXT: ret i32 2
+ %x = getelementptr [5 x i32] addrspace(3)* @constant_data_as3, i32 0, i32 1
+ %y = load i32 addrspace(3)* %x, align 4
+ ret i32 %y
+}
+
+@a = addrspace(1) constant i32 9
+@b = addrspace(1) constant i32 23
+@c = addrspace(1) constant i32 34
+@d = addrspace(1) constant i32 99
+
+@ptr_array = addrspace(2) constant [4 x i32 addrspace(1)*] [ i32 addrspace(1)* @a, i32 addrspace(1)* @b, i32 addrspace(1)* @c, i32 addrspace(1)* @d]
+@indirect = addrspace(0) constant i32 addrspace(1)* addrspace(2)* getelementptr inbounds ([4 x i32 addrspace(1)*] addrspace(2)* @ptr_array, i1 0, i32 2)
+
+define i32 @constant_through_array_as_ptrs() {
+; CHECK-LABEL: @constant_through_array_as_ptrs(
+; CHECK-NEXT: ret i32 34
+ %p = load i32 addrspace(1)* addrspace(2)* addrspace(0)* @indirect, align 4
+ %a = load i32 addrspace(1)* addrspace(2)* %p, align 4
+ %b = load i32 addrspace(1)* %a, align 4
+ ret i32 %b
+}
diff --git a/test/Transforms/InstCombine/constant-fold-gep.ll b/test/Transforms/InstCombine/constant-fold-gep.ll
index e5b16ea0ffdc..5fb56023a4f6 100644
--- a/test/Transforms/InstCombine/constant-fold-gep.ll
+++ b/test/Transforms/InstCombine/constant-fold-gep.ll
@@ -1,5 +1,5 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
+target datalayout = "E-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
; Constant folding should fix notionally out-of-bounds indices
; and add inbounds keywords.
@@ -56,7 +56,7 @@ define void @frob() {
; PR8883 - Constant fold exotic gep subtract
-; CHECK: @test2
+; CHECK-LABEL: @test2(
@X = global [1000 x i8] zeroinitializer, align 16
define i64 @test2() {
@@ -72,3 +72,21 @@ entry:
ret i64 %E
; CHECK: ret i64 1000
}
+
+@X_as1 = addrspace(1) global [1000 x i8] zeroinitializer, align 16
+
+define i16 @test2_as1() {
+; CHECK-LABEL: @test2_as1(
+ ; CHECK: ret i16 1000
+
+entry:
+ %A = bitcast i8 addrspace(1)* getelementptr inbounds ([1000 x i8] addrspace(1)* @X_as1, i64 1, i64 0) to i8 addrspace(1)*
+ %B = bitcast i8 addrspace(1)* getelementptr inbounds ([1000 x i8] addrspace(1)* @X_as1, i64 0, i64 0) to i8 addrspace(1)*
+
+ %B2 = ptrtoint i8 addrspace(1)* %B to i16
+ %C = sub i16 0, %B2
+ %D = getelementptr i8 addrspace(1)* %A, i16 %C
+ %E = ptrtoint i8 addrspace(1)* %D to i16
+
+ ret i16 %E
+}
diff --git a/test/Transforms/InstCombine/cos-1.ll b/test/Transforms/InstCombine/cos-1.ll
index b92e448abd9f..c2e9a0db4053 100644
--- a/test/Transforms/InstCombine/cos-1.ll
+++ b/test/Transforms/InstCombine/cos-1.ll
@@ -10,7 +10,7 @@ declare double @cos(double)
; Check cos(-x) -> cos(x);
define double @test_simplify1(double %d) {
-; NO-FLOAT-SHRINK: @test_simplify1
+; NO-FLOAT-SHRINK-LABEL: @test_simplify1(
%neg = fsub double -0.000000e+00, %d
%cos = call double @cos(double %neg)
; NO-FLOAT-SHRINK: call double @cos(double %d)
@@ -18,7 +18,7 @@ define double @test_simplify1(double %d) {
}
define float @test_simplify2(float %f) {
-; DO-FLOAT-SHRINK: @test_simplify2
+; DO-FLOAT-SHRINK-LABEL: @test_simplify2(
%conv1 = fpext float %f to double
%neg = fsub double -0.000000e+00, %conv1
%cos = call double @cos(double %neg)
@@ -28,7 +28,7 @@ define float @test_simplify2(float %f) {
}
define float @test_simplify3(float %f) {
-; NO-FLOAT-SHRINK: @test_simplify3
+; NO-FLOAT-SHRINK-LABEL: @test_simplify3(
%conv1 = fpext float %f to double
%neg = fsub double -0.000000e+00, %conv1
%cos = call double @cos(double %neg)
diff --git a/test/Transforms/InstCombine/cos-2.ll b/test/Transforms/InstCombine/cos-2.ll
index 2f2dfafe484d..c9a9c7c07712 100644
--- a/test/Transforms/InstCombine/cos-2.ll
+++ b/test/Transforms/InstCombine/cos-2.ll
@@ -9,7 +9,7 @@ declare float @cos(double)
; Check that cos functions with the wrong prototype aren't simplified.
define float @test_no_simplify1(double %d) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%neg = fsub double -0.000000e+00, %d
%cos = call float @cos(double %neg)
; CHECK: call float @cos(double %neg)
diff --git a/test/Transforms/InstCombine/debug-line.ll b/test/Transforms/InstCombine/debug-line.ll
index 084efdc989f9..2e3785fe597e 100644
--- a/test/Transforms/InstCombine/debug-line.ll
+++ b/test/Transforms/InstCombine/debug-line.ll
@@ -11,14 +11,18 @@ define void @foo() nounwind ssp {
declare i32 @printf(i8*, ...)
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!10}
!llvm.dbg.sp = !{!0}
-!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ]
-!1 = metadata !{i32 589865, metadata !"m.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ]
-!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"m.c", metadata !"/private/tmp", metadata !"clang", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
-!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
+!0 = metadata !{i32 589870, metadata !8, metadata !1, metadata !"foo", metadata !"foo", metadata !"", i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, void ()* @foo, null, null, null, i32 0} ; [ DW_TAG_subprogram ]
+!1 = metadata !{i32 589865, metadata !8} ; [ DW_TAG_file_type ]
+!2 = metadata !{i32 589841, metadata !8, i32 12, metadata !"clang", i1 true, metadata !"", i32 0, metadata !4, metadata !4, metadata !9, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
+!3 = metadata !{i32 589845, metadata !8, metadata !1, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!4 = metadata !{null}
!5 = metadata !{i32 5, i32 2, metadata !6, null}
-!6 = metadata !{i32 589835, metadata !0, i32 4, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ]
+!6 = metadata !{i32 589835, metadata !8, metadata !0, i32 4, i32 12, i32 0} ; [ DW_TAG_lexical_block ]
!7 = metadata !{i32 6, i32 1, metadata !6, null}
-
+!8 = metadata !{metadata !"m.c", metadata !"/private/tmp"}
+!9 = metadata !{metadata !0}
+!10 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
diff --git a/test/Transforms/InstCombine/debuginfo.ll b/test/Transforms/InstCombine/debuginfo.ll
index a9e3de3b3f7b..75082dcae055 100644
--- a/test/Transforms/InstCombine/debuginfo.ll
+++ b/test/Transforms/InstCombine/debuginfo.ll
@@ -2,7 +2,7 @@
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
-declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readnone
+declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) nounwind readnone
declare i8* @foo(i8*, i32, i64, i64) nounwind
@@ -23,34 +23,37 @@ entry:
%tmp1 = load i32* %__val.addr, align 4, !dbg !21
%tmp2 = load i64* %__len.addr, align 8, !dbg !21
%tmp3 = load i8** %__dest.addr, align 8, !dbg !21
- %0 = call i64 @llvm.objectsize.i64(i8* %tmp3, i1 false), !dbg !21
+ %0 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp3, i1 false), !dbg !21
%call = call i8* @foo(i8* %tmp, i32 %tmp1, i64 %tmp2, i64 %0), !dbg !21
ret i8* %call, !dbg !21
}
!llvm.dbg.cu = !{!3}
+!llvm.module.flags = !{!30}
!0 = metadata !{i32 786689, metadata !1, metadata !"__dest", metadata !2, i32 16777294, metadata !6, i32 0, null} ; [ DW_TAG_arg_variable ]
-!1 = metadata !{i32 786478, metadata !2, metadata !"foobar", metadata !"foobar", metadata !"", metadata !2, i32 79, metadata !4, i1 true, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i8* (i8*, i32, i64)* @foobar, null, null, metadata !25, i32 79} ; [ DW_TAG_subprogram ]
+!1 = metadata !{i32 786478, metadata !27, metadata !2, metadata !"foobar", metadata !"foobar", metadata !"", i32 79, metadata !4, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 true, i8* (i8*, i32, i64)* @foobar, null, null, metadata !25, i32 79} ; [ DW_TAG_subprogram ] [line 79] [local] [def] [foobar]
!2 = metadata !{i32 786473, metadata !27} ; [ DW_TAG_file_type ]
-!3 = metadata !{i32 786449, i32 0, i32 12, metadata !26, metadata !"clang version 3.0 (trunk 127710)", i1 true, metadata !"", i32 0, null, null, metadata !24, null, null} ; [ DW_TAG_compile_unit ]
-!4 = metadata !{i32 786453, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !5, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
+!3 = metadata !{i32 786449, metadata !28, i32 12, metadata !"clang version 3.0 (trunk 127710)", i1 true, metadata !"", i32 0, metadata !29, metadata !29, metadata !24, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
+!4 = metadata !{i32 786453, metadata !27, metadata !2, metadata !"", i32 0, i64 0, i64 0, i32 0, i32 0, null, metadata !5, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!5 = metadata !{metadata !6}
-!6 = metadata !{i32 786447, metadata !3, metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ]
+!6 = metadata !{i32 786447, null, metadata !3, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ]
!7 = metadata !{i32 786689, metadata !1, metadata !"__val", metadata !2, i32 33554510, metadata !8, i32 0, null} ; [ DW_TAG_arg_variable ]
-!8 = metadata !{i32 786468, metadata !3, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
+!8 = metadata !{i32 786468, null, metadata !3, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
!9 = metadata !{i32 786689, metadata !1, metadata !"__len", metadata !2, i32 50331726, metadata !10, i32 0, null} ; [ DW_TAG_arg_variable ]
-!10 = metadata !{i32 589846, metadata !3, metadata !"size_t", metadata !2, i32 80, i64 0, i64 0, i64 0, i32 0, metadata !11} ; [ DW_TAG_typedef ]
-!11 = metadata !{i32 589846, metadata !3, metadata !"__darwin_size_t", metadata !2, i32 90, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_typedef ]
-!12 = metadata !{i32 786468, metadata !3, metadata !"long unsigned int", null, i32 0, i64 64, i64 64, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ]
+!10 = metadata !{i32 589846, metadata !27, metadata !3, metadata !"size_t", i32 80, i64 0, i64 0, i64 0, i32 0, metadata !11} ; [ DW_TAG_typedef ]
+!11 = metadata !{i32 589846, metadata !27, metadata !3, metadata !"__darwin_size_t", i32 90, i64 0, i64 0, i64 0, i32 0, metadata !12} ; [ DW_TAG_typedef ]
+!12 = metadata !{i32 786468, null, metadata !3, metadata !"long unsigned int", i32 0, i64 64, i64 64, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ]
!16 = metadata !{i32 78, i32 28, metadata !1, null}
!18 = metadata !{i32 78, i32 40, metadata !1, null}
!20 = metadata !{i32 78, i32 54, metadata !1, null}
!21 = metadata !{i32 80, i32 3, metadata !22, null}
-!22 = metadata !{i32 786443, metadata !23, i32 80, i32 3, metadata !2, i32 7} ; [ DW_TAG_lexical_block ]
-!23 = metadata !{i32 786443, metadata !1, i32 79, i32 1, metadata !2, i32 6} ; [ DW_TAG_lexical_block ]
+!22 = metadata !{i32 786443, metadata !27, metadata !23, i32 80, i32 3, i32 7} ; [ DW_TAG_lexical_block ]
+!23 = metadata !{i32 786443, metadata !27, metadata !1, i32 79, i32 1, i32 6} ; [ DW_TAG_lexical_block ]
!24 = metadata !{metadata !1}
!25 = metadata !{metadata !0, metadata !7, metadata !9}
!26 = metadata !{i32 786473, metadata !28} ; [ DW_TAG_file_type ]
!27 = metadata !{metadata !"string.h", metadata !"Game"}
!28 = metadata !{metadata !"bits.c", metadata !"Game"}
+!29 = metadata !{i32 0}
+!30 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
diff --git a/test/Transforms/InstCombine/disable-simplify-libcalls.ll b/test/Transforms/InstCombine/disable-simplify-libcalls.ll
index c2c29368b1a8..665278861791 100644
--- a/test/Transforms/InstCombine/disable-simplify-libcalls.ll
+++ b/test/Transforms/InstCombine/disable-simplify-libcalls.ll
@@ -51,42 +51,42 @@ declare i32 @printf(i8*)
declare i32 @sprintf(i8*, i8*)
define double @t1(double %x) {
-; CHECK: @t1
+; CHECK-LABEL: @t1(
%ret = call double @ceil(double %x)
ret double %ret
; CHECK: call double @ceil
}
define double @t2(double %x, double %y) {
-; CHECK: @t2
+; CHECK-LABEL: @t2(
%ret = call double @copysign(double %x, double %y)
ret double %ret
; CHECK: call double @copysign
}
define double @t3(double %x) {
-; CHECK: @t3
+; CHECK-LABEL: @t3(
%call = call double @cos(double %x)
ret double %call
; CHECK: call double @cos
}
define double @t4(double %x) {
-; CHECK: @t4
+; CHECK-LABEL: @t4(
%ret = call double @fabs(double %x)
ret double %ret
; CHECK: call double @fabs
}
define double @t5(double %x) {
-; CHECK: @t5
+; CHECK-LABEL: @t5(
%ret = call double @floor(double %x)
ret double %ret
; CHECK: call double @floor
}
define i8* @t6(i8* %x) {
-; CHECK: @t6
+; CHECK-LABEL: @t6(
%empty = getelementptr [1 x i8]* @empty, i32 0, i32 0
%ret = call i8* @strcat(i8* %x, i8* %empty)
ret i8* %ret
@@ -94,7 +94,7 @@ define i8* @t6(i8* %x) {
}
define i8* @t7(i8* %x) {
-; CHECK: @t7
+; CHECK-LABEL: @t7(
%empty = getelementptr [1 x i8]* @empty, i32 0, i32 0
%ret = call i8* @strncat(i8* %x, i8* %empty, i32 1)
ret i8* %ret
@@ -102,7 +102,7 @@ define i8* @t7(i8* %x) {
}
define i8* @t8() {
-; CHECK: @t8
+; CHECK-LABEL: @t8(
%x = getelementptr inbounds [13 x i8]* @.str1, i32 0, i32 0
%ret = call i8* @strchr(i8* %x, i32 119)
ret i8* %ret
@@ -110,7 +110,7 @@ define i8* @t8() {
}
define i8* @t9() {
-; CHECK: @t9
+; CHECK-LABEL: @t9(
%x = getelementptr inbounds [13 x i8]* @.str1, i32 0, i32 0
%ret = call i8* @strrchr(i8* %x, i32 119)
ret i8* %ret
@@ -118,7 +118,7 @@ define i8* @t9() {
}
define i32 @t10() {
-; CHECK: @t10
+; CHECK-LABEL: @t10(
%x = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%y = getelementptr inbounds [4 x i8]* @.str3, i32 0, i32 0
%ret = call i32 @strcmp(i8* %x, i8* %y)
@@ -127,7 +127,7 @@ define i32 @t10() {
}
define i32 @t11() {
-; CHECK: @t11
+; CHECK-LABEL: @t11(
%x = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%y = getelementptr inbounds [4 x i8]* @.str3, i32 0, i32 0
%ret = call i32 @strncmp(i8* %x, i8* %y, i64 3)
@@ -136,7 +136,7 @@ define i32 @t11() {
}
define i8* @t12(i8* %x) {
-; CHECK: @t12
+; CHECK-LABEL: @t12(
%y = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%ret = call i8* @strcpy(i8* %x, i8* %y)
ret i8* %ret
@@ -144,7 +144,7 @@ define i8* @t12(i8* %x) {
}
define i8* @t13(i8* %x) {
-; CHECK: @t13
+; CHECK-LABEL: @t13(
%y = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%ret = call i8* @stpcpy(i8* %x, i8* %y)
ret i8* %ret
@@ -152,7 +152,7 @@ define i8* @t13(i8* %x) {
}
define i8* @t14(i8* %x) {
-; CHECK: @t14
+; CHECK-LABEL: @t14(
%y = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%ret = call i8* @strncpy(i8* %x, i8* %y, i64 3)
ret i8* %ret
@@ -160,7 +160,7 @@ define i8* @t14(i8* %x) {
}
define i64 @t15() {
-; CHECK: @t15
+; CHECK-LABEL: @t15(
%x = getelementptr inbounds [4 x i8]* @.str2, i32 0, i32 0
%ret = call i64 @strlen(i8* %x)
ret i64 %ret
@@ -168,7 +168,7 @@ define i64 @t15() {
}
define i8* @t16(i8* %x) {
-; CHECK: @t16
+; CHECK-LABEL: @t16(
%y = getelementptr inbounds [1 x i8]* @.str, i32 0, i32 0
%ret = call i8* @strpbrk(i8* %x, i8* %y)
ret i8* %ret
@@ -176,7 +176,7 @@ define i8* @t16(i8* %x) {
}
define i64 @t17(i8* %x) {
-; CHECK: @t17
+; CHECK-LABEL: @t17(
%y = getelementptr inbounds [1 x i8]* @.str, i32 0, i32 0
%ret = call i64 @strspn(i8* %x, i8* %y)
ret i64 %ret
@@ -184,7 +184,7 @@ define i64 @t17(i8* %x) {
}
define double @t18(i8** %y) {
-; CHECK: @t18
+; CHECK-LABEL: @t18(
%x = getelementptr inbounds [6 x i8]* @.str4, i64 0, i64 0
%ret = call double @strtod(i8* %x, i8** %y)
ret double %ret
@@ -192,7 +192,7 @@ define double @t18(i8** %y) {
}
define float @t19(i8** %y) {
-; CHECK: @t19
+; CHECK-LABEL: @t19(
%x = getelementptr inbounds [6 x i8]* @.str4, i64 0, i64 0
%ret = call float @strtof(i8* %x, i8** %y)
ret float %ret
@@ -200,7 +200,7 @@ define float @t19(i8** %y) {
}
define x86_fp80 @t20(i8** %y) {
-; CHECK: @t20
+; CHECK-LABEL: @t20(
%x = getelementptr inbounds [6 x i8]* @.str4, i64 0, i64 0
%ret = call x86_fp80 @strtold(i8* %x, i8** %y)
ret x86_fp80 %ret
@@ -208,7 +208,7 @@ define x86_fp80 @t20(i8** %y) {
}
define i64 @t21(i8** %y) {
-; CHECK: @t21
+; CHECK-LABEL: @t21(
%x = getelementptr inbounds [5 x i8]* @.str5, i64 0, i64 0
%ret = call i64 @strtol(i8* %x, i8** %y, i32 10)
ret i64 %ret
@@ -216,7 +216,7 @@ define i64 @t21(i8** %y) {
}
define i64 @t22(i8** %y) {
-; CHECK: @t22
+; CHECK-LABEL: @t22(
%x = getelementptr inbounds [5 x i8]* @.str5, i64 0, i64 0
%ret = call i64 @strtoll(i8* %x, i8** %y, i32 10)
ret i64 %ret
@@ -224,7 +224,7 @@ define i64 @t22(i8** %y) {
}
define i64 @t23(i8** %y) {
-; CHECK: @t23
+; CHECK-LABEL: @t23(
%x = getelementptr inbounds [5 x i8]* @.str5, i64 0, i64 0
%ret = call i64 @strtoul(i8* %x, i8** %y, i32 10)
ret i64 %ret
@@ -232,7 +232,7 @@ define i64 @t23(i8** %y) {
}
define i64 @t24(i8** %y) {
-; CHECK: @t24
+; CHECK-LABEL: @t24(
%x = getelementptr inbounds [5 x i8]* @.str5, i64 0, i64 0
%ret = call i64 @strtoull(i8* %x, i8** %y, i32 10)
ret i64 %ret
@@ -240,7 +240,7 @@ define i64 @t24(i8** %y) {
}
define i64 @t25(i8* %y) {
-; CHECK: @t25
+; CHECK-LABEL: @t25(
%x = getelementptr [1 x i8]* @empty, i32 0, i32 0
%ret = call i64 @strcspn(i8* %x, i8* %y)
ret i64 %ret
@@ -248,35 +248,35 @@ define i64 @t25(i8* %y) {
}
define i32 @t26(i32 %y) {
-; CHECK: @t26
+; CHECK-LABEL: @t26(
%ret = call i32 @abs(i32 %y)
ret i32 %ret
; CHECK: call i32 @abs
}
define i32 @t27(i32 %y) {
-; CHECK: @t27
+; CHECK-LABEL: @t27(
%ret = call i32 @ffs(i32 %y)
ret i32 %ret
; CHECK: call i32 @ffs
}
define i32 @t28(i64 %y) {
-; CHECK: @t28
+; CHECK-LABEL: @t28(
%ret = call i32 @ffsl(i64 %y)
ret i32 %ret
; CHECK: call i32 @ffsl
}
define i32 @t29(i64 %y) {
-; CHECK: @t29
+; CHECK-LABEL: @t29(
%ret = call i32 @ffsll(i64 %y)
ret i32 %ret
; CHECK: call i32 @ffsll
}
define void @t30() {
-; CHECK: @t30
+; CHECK-LABEL: @t30(
%x = getelementptr inbounds [13 x i8]* @.str1, i32 0, i32 0
call i32 @fprintf(i8* null, i8* %x)
ret void
@@ -284,42 +284,42 @@ define void @t30() {
}
define i32 @t31(i32 %y) {
-; CHECK: @t31
+; CHECK-LABEL: @t31(
%ret = call i32 @isascii(i32 %y)
ret i32 %ret
; CHECK: call i32 @isascii
}
define i32 @t32(i32 %y) {
-; CHECK: @t32
+; CHECK-LABEL: @t32(
%ret = call i32 @isdigit(i32 %y)
ret i32 %ret
; CHECK: call i32 @isdigit
}
define i32 @t33(i32 %y) {
-; CHECK: @t33
+; CHECK-LABEL: @t33(
%ret = call i32 @toascii(i32 %y)
ret i32 %ret
; CHECK: call i32 @toascii
}
define i64 @t34(i64 %y) {
-; CHECK: @t34
+; CHECK-LABEL: @t34(
%ret = call i64 @labs(i64 %y)
ret i64 %ret
; CHECK: call i64 @labs
}
define i64 @t35(i64 %y) {
-; CHECK: @t35
+; CHECK-LABEL: @t35(
%ret = call i64 @llabs(i64 %y)
ret i64 %ret
; CHECK: call i64 @llabs
}
define void @t36() {
-; CHECK: @t36
+; CHECK-LABEL: @t36(
%x = getelementptr inbounds [1 x i8]* @empty, i32 0, i32 0
call i32 @printf(i8* %x)
ret void
@@ -327,7 +327,7 @@ define void @t36() {
}
define void @t37(i8* %x) {
-; CHECK: @t37
+; CHECK-LABEL: @t37(
%y = getelementptr inbounds [13 x i8]* @.str1, i32 0, i32 0
call i32 @sprintf(i8* %x, i8* %y)
ret void
diff --git a/test/Transforms/InstCombine/div-shift-crash.ll b/test/Transforms/InstCombine/div-shift-crash.ll
new file mode 100644
index 000000000000..a61972456403
--- /dev/null
+++ b/test/Transforms/InstCombine/div-shift-crash.ll
@@ -0,0 +1,101 @@
+; RUN: opt -instcombine < %s
+target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+%struct.S0.0.1.2.3.4.13.22.31.44.48.53.54.55.56.58.59.60.66.68.70.74.77.106.107.108.109.110.113.117.118.128.129 = type <{ i64 }>
+
+; Function Attrs: nounwind
+define void @main() #0 {
+entry:
+ %l_819.i.i = alloca %struct.S0.0.1.2.3.4.13.22.31.44.48.53.54.55.56.58.59.60.66.68.70.74.77.106.107.108.109.110.113.117.118.128.129, align 8
+ br i1 undef, label %land.lhs.true, label %for.cond.i
+
+land.lhs.true: ; preds = %entry
+ br label %for.cond.i
+
+for.cond.i: ; preds = %land.lhs.true, %entry
+ %0 = getelementptr inbounds %struct.S0.0.1.2.3.4.13.22.31.44.48.53.54.55.56.58.59.60.66.68.70.74.77.106.107.108.109.110.113.117.118.128.129* %l_819.i.i, i64 0, i32 0
+ br label %for.cond.i6.i.i
+
+for.cond.i6.i.i: ; preds = %for.body.i8.i.i, %for.cond.i
+ br i1 undef, label %for.body.i8.i.i, label %lbl_707.i.i.i
+
+for.body.i8.i.i: ; preds = %for.cond.i6.i.i
+ br label %for.cond.i6.i.i
+
+lbl_707.i.i.i: ; preds = %for.cond.i6.i.i
+ br i1 undef, label %lor.rhs.i.i.i, label %lor.end.i.i.i
+
+lor.rhs.i.i.i: ; preds = %lbl_707.i.i.i
+ br label %lor.end.i.i.i
+
+lor.end.i.i.i: ; preds = %lor.rhs.i.i.i, %lbl_707.i.i.i
+ br label %for.cond1.i.i.i.i
+
+for.cond1.i.i.i.i: ; preds = %for.body4.i.i.i.i, %lor.end.i.i.i
+ br i1 undef, label %for.body4.i.i.i.i, label %func_39.exit.i.i
+
+for.body4.i.i.i.i: ; preds = %for.cond1.i.i.i.i
+ br label %for.cond1.i.i.i.i
+
+func_39.exit.i.i: ; preds = %for.cond1.i.i.i.i
+ %l_8191.sroa.0.0.copyload.i.i = load i64* %0, align 1
+ br label %for.cond1.i.i.i
+
+for.cond1.i.i.i: ; preds = %safe_div_func_uint32_t_u_u.exit.i.i.i, %func_39.exit.i.i
+ br i1 undef, label %for.cond7.i.i.i, label %func_11.exit.i
+
+for.cond7.i.i.i: ; preds = %for.end30.i.i.i, %for.cond1.i.i.i
+ %storemerge.i.i.i = phi i32 [ %sub.i.i.i, %for.end30.i.i.i ], [ 4, %for.cond1.i.i.i ]
+ br i1 undef, label %for.cond22.i.i.i, label %for.end32.i.i.i
+
+for.cond22.i.i.i: ; preds = %for.body25.i.i.i, %for.cond7.i.i.i
+ br i1 undef, label %for.body25.i.i.i, label %for.end30.i.i.i
+
+for.body25.i.i.i: ; preds = %for.cond22.i.i.i
+ br label %for.cond22.i.i.i
+
+for.end30.i.i.i: ; preds = %for.cond22.i.i.i
+ %sub.i.i.i = add nsw i32 0, -1
+ br label %for.cond7.i.i.i
+
+for.end32.i.i.i: ; preds = %for.cond7.i.i.i
+ %conv33.i.i.i = trunc i64 %l_8191.sroa.0.0.copyload.i.i to i32
+ %xor.i.i.i.i = xor i32 %storemerge.i.i.i, -701565022
+ %sub.i.i.i.i = sub nsw i32 0, %storemerge.i.i.i
+ %xor3.i.i.i.i = xor i32 %sub.i.i.i.i, %storemerge.i.i.i
+ %and4.i.i.i.i = and i32 %xor.i.i.i.i, %xor3.i.i.i.i
+ %cmp.i.i.i.i = icmp slt i32 %and4.i.i.i.i, 0
+ %sub5.i.i.i.i = sub nsw i32 -701565022, %storemerge.i.i.i
+ %.sub5.i.i.i.i = select i1 %cmp.i.i.i.i, i32 -701565022, i32 %sub5.i.i.i.i
+ br i1 undef, label %safe_div_func_uint32_t_u_u.exit.i.i.i, label %cond.false.i.i.i.i
+
+cond.false.i.i.i.i: ; preds = %for.end32.i.i.i
+ %div.i.i.i.i = udiv i32 %conv33.i.i.i, %.sub5.i.i.i.i
+ br label %safe_div_func_uint32_t_u_u.exit.i.i.i
+
+safe_div_func_uint32_t_u_u.exit.i.i.i: ; preds = %cond.false.i.i.i.i, %for.end32.i.i.i
+ %cond.i.i.i.i = phi i32 [ %div.i.i.i.i, %cond.false.i.i.i.i ], [ %conv33.i.i.i, %for.end32.i.i.i ]
+ %cmp35.i.i.i = icmp ne i32 %cond.i.i.i.i, -7
+ br label %for.cond1.i.i.i
+
+func_11.exit.i: ; preds = %for.cond1.i.i.i
+ br i1 undef, label %for.body, label %for.end
+
+for.body: ; preds = %func_11.exit.i
+ unreachable
+
+for.end: ; preds = %func_11.exit.i
+ br label %for.cond15
+
+for.cond15: ; preds = %for.cond19, %for.end
+ br i1 undef, label %for.cond19, label %for.end45
+
+for.cond19: ; preds = %for.cond15
+ br label %for.cond15
+
+for.end45: ; preds = %for.cond15
+ unreachable
+}
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
diff --git a/test/Transforms/InstCombine/div-shift.ll b/test/Transforms/InstCombine/div-shift.ll
index e0372ebac184..3350f1940554 100644
--- a/test/Transforms/InstCombine/div-shift.ll
+++ b/test/Transforms/InstCombine/div-shift.ll
@@ -35,3 +35,41 @@ define i64 @t3(i64 %x, i32 %y) nounwind {
%3 = udiv i64 %x, %2
ret i64 %3
}
+
+define i32 @t4(i32 %x, i32 %y) nounwind {
+; CHECK: t4
+; CHECK-NOT: udiv
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 %y, 5
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 5, i32 %y
+; CHECK-NEXT: [[SHR:%.*]] = lshr i32 %x, [[SEL]]
+; CHECK-NEXT: ret i32 [[SHR]]
+ %1 = shl i32 1, %y
+ %2 = icmp ult i32 %1, 32
+ %3 = select i1 %2, i32 32, i32 %1
+ %4 = udiv i32 %x, %3
+ ret i32 %4
+}
+
+define i32 @t5(i1 %x, i1 %y, i32 %V) nounwind {
+; CHECK: t5
+; CHECK-NOT: udiv
+; CHECK-NEXT: [[SEL1:%.*]] = select i1 %x, i32 5, i32 6
+; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 %V, [[SEL1]]
+; CHECK-NEXT: [[SEL2:%.*]] = select i1 %y, i32 [[LSHR]], i32 0
+; CHECK-NEXT: ret i32 [[SEL2]]
+ %1 = shl i32 1, %V
+ %2 = select i1 %x, i32 32, i32 64
+ %3 = select i1 %y, i32 %2, i32 %1
+ %4 = udiv i32 %V, %3
+ ret i32 %4
+}
+
+define i32 @t6(i32 %x, i32 %z) nounwind{
+; CHECK: t6
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 0
+; CHECK-NOT: udiv i32 %z, %x
+ %x_is_zero = icmp eq i32 %x, 0
+ %divisor = select i1 %x_is_zero, i32 1, i32 %x
+ %y = udiv i32 %z, %divisor
+ ret i32 %y
+}
diff --git a/test/Transforms/InstCombine/div.ll b/test/Transforms/InstCombine/div.ll
index 8a0897b972de..f67fd1c51be3 100644
--- a/test/Transforms/InstCombine/div.ll
+++ b/test/Transforms/InstCombine/div.ll
@@ -5,7 +5,7 @@
define i32 @test1(i32 %A) {
%B = sdiv i32 %A, 1 ; <i32> [#uses=1]
ret i32 %B
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: ret i32 %A
}
@@ -13,7 +13,7 @@ define i32 @test2(i32 %A) {
; => Shift
%B = udiv i32 %A, 8 ; <i32> [#uses=1]
ret i32 %B
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: lshr i32 %A, 3
}
@@ -21,7 +21,7 @@ define i32 @test3(i32 %A) {
; => 0, don't need to keep traps
%B = sdiv i32 0, %A ; <i32> [#uses=1]
ret i32 %B
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: ret i32 0
}
@@ -29,7 +29,7 @@ define i32 @test4(i32 %A) {
; 0-A
%B = sdiv i32 %A, -1 ; <i32> [#uses=1]
ret i32 %B
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: sub i32 0, %A
}
@@ -37,7 +37,7 @@ define i32 @test5(i32 %A) {
%B = udiv i32 %A, -16 ; <i32> [#uses=1]
%C = udiv i32 %B, -4 ; <i32> [#uses=1]
ret i32 %C
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: ret i32 0
}
@@ -46,7 +46,7 @@ define i1 @test6(i32 %A) {
; A < 123
%C = icmp eq i32 %B, 0 ; <i1> [#uses=1]
ret i1 %C
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: icmp ult i32 %A, 123
}
@@ -55,7 +55,7 @@ define i1 @test7(i32 %A) {
; A >= 20 && A < 30
%C = icmp eq i32 %B, 2 ; <i1> [#uses=1]
ret i1 %C
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: add i32 %A, -20
; CHECK-NEXT: icmp ult i32
}
@@ -65,7 +65,7 @@ define i1 @test8(i8 %A) {
; A >= 246
%C = icmp eq i8 %B, 2 ; <i1> [#uses=1]
ret i1 %C
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NEXT: icmp ugt i8 %A, -11
}
@@ -74,7 +74,7 @@ define i1 @test9(i8 %A) {
; A < 246
%C = icmp ne i8 %B, 2 ; <i1> [#uses=1]
ret i1 %C
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: icmp ult i8 %A, -10
}
@@ -82,7 +82,7 @@ define i32 @test10(i32 %X, i1 %C) {
%V = select i1 %C, i32 64, i32 8 ; <i32> [#uses=1]
%R = udiv i32 %X, %V ; <i32> [#uses=1]
ret i32 %R
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK-NEXT: select i1 %C, i32 6, i32 3
; CHECK-NEXT: lshr i32 %X
}
@@ -91,7 +91,7 @@ define i32 @test11(i32 %X, i1 %C) {
%A = select i1 %C, i32 1024, i32 32 ; <i32> [#uses=1]
%B = udiv i32 %X, %A ; <i32> [#uses=1]
ret i32 %B
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK-NEXT: select i1 %C, i32 10, i32 5
; CHECK-NEXT: lshr i32 %X
}
@@ -100,14 +100,14 @@ define i32 @test11(i32 %X, i1 %C) {
define i32 @test12(i32 %x) nounwind {
%tmp3 = udiv i32 %x, %x ; 1
ret i32 %tmp3
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NEXT: ret i32 1
}
define i32 @test13(i32 %x) nounwind {
%tmp3 = sdiv i32 %x, %x ; 1
ret i32 %tmp3
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK-NEXT: ret i32 1
}
@@ -115,7 +115,7 @@ define i32 @test14(i8 %x) nounwind {
%zext = zext i8 %x to i32
%div = udiv i32 %zext, 257 ; 0
ret i32 %div
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK-NEXT: ret i32 0
}
@@ -125,7 +125,7 @@ define i32 @test15(i32 %a, i32 %b) nounwind {
%div = lshr i32 %shl, 2
%div2 = udiv i32 %a, %div
ret i32 %div2
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK-NEXT: add i32 %b, -2
; CHECK-NEXT: lshr i32 %a,
; CHECK-NEXT: ret i32
diff --git a/test/Transforms/InstCombine/double-float-shrink-1.ll b/test/Transforms/InstCombine/double-float-shrink-1.ll
index e5448ee00765..5cacb591e006 100644
--- a/test/Transforms/InstCombine/double-float-shrink-1.ll
+++ b/test/Transforms/InstCombine/double-float-shrink-1.ll
@@ -263,6 +263,7 @@ define double @sin_test2(float %f) nounwind readnone {
ret double %call
; CHECK: call double @sin(double %conv)
}
+
define float @sqrt_test(float %f) nounwind readnone {
; CHECK: sqrt_test
%conv = fpext float %f to double
@@ -272,6 +273,15 @@ define float @sqrt_test(float %f) nounwind readnone {
; CHECK: call float @sqrtf(float %f)
}
+define float @sqrt_int_test(float %f) nounwind readnone {
+; CHECK: sqrt_int_test
+ %conv = fpext float %f to double
+ %call = call double @llvm.sqrt.f64(double %conv)
+ %conv1 = fptrunc double %call to float
+ ret float %conv1
+; CHECK: call float @llvm.sqrt.f32(float %f)
+}
+
define double @sqrt_test2(float %f) nounwind readnone {
; CHECK: sqrt_test2
%conv = fpext float %f to double
@@ -331,3 +341,6 @@ declare double @acos(double) nounwind readnone
declare double @acosh(double) nounwind readnone
declare double @asin(double) nounwind readnone
declare double @asinh(double) nounwind readnone
+
+declare double @llvm.sqrt.f64(double) nounwind readnone
+
diff --git a/test/Transforms/InstCombine/enforce-known-alignment.ll b/test/Transforms/InstCombine/enforce-known-alignment.ll
index 6645d99035fa..46bb60569fe2 100644
--- a/test/Transforms/InstCombine/enforce-known-alignment.ll
+++ b/test/Transforms/InstCombine/enforce-known-alignment.ll
@@ -1,8 +1,12 @@
-; RUN: opt < %s -instcombine -S | grep alloca | grep "align 16"
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+; RUN: opt -instcombine -S %s | FileCheck %s
+
+target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin9.6"
define void @foo(i32) {
+; CHECK-LABEL: @foo(
+; CHECK: alloca
+; CHECK: align 16
%2 = alloca [3 x <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>], align 16 ; <[3 x <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>]*> [#uses=1]
%3 = getelementptr [3 x <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>]* %2, i32 0, i32 0 ; <<{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>*> [#uses=1]
%4 = getelementptr <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>* %3, i32 0, i32 0 ; <{ { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } }*> [#uses=1]
@@ -11,8 +15,24 @@ define void @foo(i32) {
%7 = getelementptr { [8 x i16] }* %6, i32 0, i32 0 ; <[8 x i16]*> [#uses=1]
%8 = getelementptr [8 x i16]* %7, i32 0, i32 0 ; <i16*> [#uses=1]
store i16 0, i16* %8, align 16
- call void @bar(i16* %8)
+ call void @bar(i16* %8)
ret void
}
declare void @bar(i16*)
+
+define void @foo_as1(i32 %a, [3 x <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>] addrspace(1)* %b) {
+; CHECK-LABEL: @foo_as1(
+; CHECK: align 16
+ %1 = getelementptr [3 x <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>] addrspace(1)* %b, i32 0, i32 0 ; <<{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }>*> [#uses=1]
+ %2 = getelementptr <{ { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } }> addrspace(1)* %1, i32 0, i32 0 ; <{ { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } }*> [#uses=1]
+ %3 = getelementptr { { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } } addrspace(1)* %2, i32 0, i32 0 ; <{ [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 }*> [#uses=1]
+ %4 = bitcast { [2 x { { i32 } }], [2 x i8], { i16 }, [2 x i8], i8, i8 } addrspace(1)* %3 to { [8 x i16] } addrspace(1)* ; <{ [8 x i16] }*> [#uses=1]
+ %5 = getelementptr { [8 x i16] } addrspace(1)* %4, i32 0, i32 0 ; <[8 x i16]*> [#uses=1]
+ %6 = getelementptr [8 x i16] addrspace(1)* %5, i32 0, i32 0 ; <i16*> [#uses=1]
+ store i16 0, i16 addrspace(1)* %6, align 16
+ call void @bar_as1(i16 addrspace(1)* %6)
+ ret void
+}
+
+declare void @bar_as1(i16 addrspace(1)*)
diff --git a/test/Transforms/InstCombine/err-rep-cold.ll b/test/Transforms/InstCombine/err-rep-cold.ll
new file mode 100644
index 000000000000..0cbafc43e0f6
--- /dev/null
+++ b/test/Transforms/InstCombine/err-rep-cold.ll
@@ -0,0 +1,77 @@
+; Test the static branch probability heuristics for error-reporting functions.
+; RUN: opt < %s -instcombine -S | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
+%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
+
+@stdout = external global %struct._IO_FILE*
+@stderr = external global %struct._IO_FILE*
+@.str = private unnamed_addr constant [13 x i8] c"an error: %d\00", align 1
+@.str1 = private unnamed_addr constant [9 x i8] c"an error\00", align 1
+
+define i32 @test1(i32 %a) #0 {
+; CHECK-LABEL: @test1
+entry:
+ %cmp = icmp sgt i32 %a, 8
+ br i1 %cmp, label %if.then, label %return
+
+if.then: ; preds = %entry
+ %0 = load %struct._IO_FILE** @stderr, align 8
+ %call = tail call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf(%struct._IO_FILE* %0, i8* getelementptr inbounds ([13 x i8]* @.str, i64 0, i64 0), i32 %a) #1
+ br label %return
+
+; CHECK: %call = tail call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf(%struct._IO_FILE* %0, i8* getelementptr inbounds ([13 x i8]* @.str, i64 0, i64 0), i32 %a) #[[AT1:[0-9]+]]
+
+return: ; preds = %entry, %if.then
+ %retval.0 = phi i32 [ 1, %if.then ], [ 0, %entry ]
+ ret i32 %retval.0
+}
+
+declare i32 @fprintf(%struct._IO_FILE* nocapture, i8* nocapture readonly, ...) #1
+
+define i32 @test2(i32 %a) #0 {
+; CHECK-LABEL: @test2
+entry:
+ %cmp = icmp sgt i32 %a, 8
+ br i1 %cmp, label %if.then, label %return
+
+if.then: ; preds = %entry
+ %0 = load %struct._IO_FILE** @stderr, align 8
+ %1 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8]* @.str1, i64 0, i64 0), i64 8, i64 1, %struct._IO_FILE* %0)
+ br label %return
+
+; CHECK: tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8]* @.str1, i64 0, i64 0), i64 8, i64 1, %struct._IO_FILE* %0) #[[AT2:[0-9]+]]
+
+return: ; preds = %entry, %if.then
+ %retval.0 = phi i32 [ 1, %if.then ], [ 0, %entry ]
+ ret i32 %retval.0
+}
+
+declare i64 @fwrite(i8* nocapture, i64, i64, %struct._IO_FILE* nocapture) #1
+
+define i32 @test3(i32 %a) #0 {
+; CHECK-LABEL: @test3
+entry:
+ %cmp = icmp sgt i32 %a, 8
+ br i1 %cmp, label %if.then, label %return
+
+if.then: ; preds = %entry
+ %0 = load %struct._IO_FILE** @stdout, align 8
+ %1 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8]* @.str1, i64 0, i64 0), i64 8, i64 1, %struct._IO_FILE* %0)
+ br label %return
+
+; CHECK-NOT: tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8]* @.str1, i64 0, i64 0), i64 8, i64 1, %struct._IO_FILE* %0) #[[AT2]]
+
+return: ; preds = %entry, %if.then
+ %retval.0 = phi i32 [ 1, %if.then ], [ 0, %entry ]
+ ret i32 %retval.0
+}
+
+attributes #0 = { nounwind uwtable }
+attributes #1 = { nounwind }
+
+; CHECK: attributes #[[AT1]] = { cold nounwind }
+; CHECK: attributes #[[AT2]] = { cold }
+
diff --git a/test/Transforms/InstCombine/exact.ll b/test/Transforms/InstCombine/exact.ll
index 88ca88c3b927..868d60ac46b1 100644
--- a/test/Transforms/InstCombine/exact.ll
+++ b/test/Transforms/InstCombine/exact.ll
@@ -1,20 +1,20 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: @sdiv1
+; CHECK-LABEL: @sdiv1(
; CHECK: sdiv i32 %x, 8
define i32 @sdiv1(i32 %x) {
%y = sdiv i32 %x, 8
ret i32 %y
}
-; CHECK: @sdiv2
+; CHECK-LABEL: @sdiv2(
; CHECK: ashr exact i32 %x, 3
define i32 @sdiv2(i32 %x) {
%y = sdiv exact i32 %x, 8
ret i32 %y
}
-; CHECK: @sdiv3
+; CHECK-LABEL: @sdiv3(
; CHECK: %y = srem i32 %x, 3
; CHECK: %z = sub i32 %x, %y
; CHECK: ret i32 %z
@@ -24,7 +24,7 @@ define i32 @sdiv3(i32 %x) {
ret i32 %z
}
-; CHECK: @sdiv4
+; CHECK-LABEL: @sdiv4(
; CHECK: ret i32 %x
define i32 @sdiv4(i32 %x) {
%y = sdiv exact i32 %x, 3
@@ -42,7 +42,7 @@ define i32 @sdiv5(i32 %x) {
ret i32 %z
}
-; CHECK: @sdiv6
+; CHECK-LABEL: @sdiv6(
; CHECK: %z = sub i32 0, %x
; CHECK: ret i32 %z
define i32 @sdiv6(i32 %x) {
@@ -51,7 +51,7 @@ define i32 @sdiv6(i32 %x) {
ret i32 %z
}
-; CHECK: @udiv1
+; CHECK-LABEL: @udiv1(
; CHECK: ret i32 %x
define i32 @udiv1(i32 %x, i32 %w) {
%y = udiv exact i32 %x, %w
@@ -59,7 +59,7 @@ define i32 @udiv1(i32 %x, i32 %w) {
ret i32 %z
}
-; CHECK: @udiv2
+; CHECK-LABEL: @udiv2(
; CHECK: %z = lshr exact i32 %x, %w
; CHECK: ret i32 %z
define i32 @udiv2(i32 %x, i32 %w) {
@@ -68,7 +68,7 @@ define i32 @udiv2(i32 %x, i32 %w) {
ret i32 %z
}
-; CHECK: @ashr1
+; CHECK-LABEL: @ashr1(
; CHECK: %B = ashr exact i64 %A, 2
; CHECK: ret i64 %B
define i64 @ashr1(i64 %X) nounwind {
@@ -78,7 +78,7 @@ define i64 @ashr1(i64 %X) nounwind {
}
; PR9120
-; CHECK: @ashr_icmp1
+; CHECK-LABEL: @ashr_icmp1(
; CHECK: %B = icmp eq i64 %X, 0
; CHECK: ret i1 %B
define i1 @ashr_icmp1(i64 %X) nounwind {
@@ -87,7 +87,7 @@ define i1 @ashr_icmp1(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @ashr_icmp2
+; CHECK-LABEL: @ashr_icmp2(
; CHECK: %Z = icmp slt i64 %X, 16
; CHECK: ret i1 %Z
define i1 @ashr_icmp2(i64 %X) nounwind {
@@ -98,7 +98,7 @@ define i1 @ashr_icmp2(i64 %X) nounwind {
; PR9998
; Make sure we don't transform the ashr here into an sdiv
-; CHECK: @pr9998
+; CHECK-LABEL: @pr9998(
; CHECK: [[BIT:%[A-Za-z0-9.]+]] = and i32 %V, 1
; CHECK-NEXT: [[CMP:%[A-Za-z0-9.]+]] = icmp ne i32 [[BIT]], 0
; CHECK-NEXT: ret i1 [[CMP]]
@@ -113,7 +113,7 @@ entry:
-; CHECK: @udiv_icmp1
+; CHECK-LABEL: @udiv_icmp1(
; CHECK: icmp ne i64 %X, 0
define i1 @udiv_icmp1(i64 %X) nounwind {
%A = udiv exact i64 %X, 5 ; X/5
@@ -121,7 +121,7 @@ define i1 @udiv_icmp1(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp1
+; CHECK-LABEL: @sdiv_icmp1(
; CHECK: icmp eq i64 %X, 0
define i1 @sdiv_icmp1(i64 %X) nounwind {
%A = sdiv exact i64 %X, 5 ; X/5 == 0 --> x == 0
@@ -129,7 +129,7 @@ define i1 @sdiv_icmp1(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp2
+; CHECK-LABEL: @sdiv_icmp2(
; CHECK: icmp eq i64 %X, 5
define i1 @sdiv_icmp2(i64 %X) nounwind {
%A = sdiv exact i64 %X, 5 ; X/5 == 1 --> x == 5
@@ -137,7 +137,7 @@ define i1 @sdiv_icmp2(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp3
+; CHECK-LABEL: @sdiv_icmp3(
; CHECK: icmp eq i64 %X, -5
define i1 @sdiv_icmp3(i64 %X) nounwind {
%A = sdiv exact i64 %X, 5 ; X/5 == -1 --> x == -5
@@ -145,7 +145,7 @@ define i1 @sdiv_icmp3(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp4
+; CHECK-LABEL: @sdiv_icmp4(
; CHECK: icmp eq i64 %X, 0
define i1 @sdiv_icmp4(i64 %X) nounwind {
%A = sdiv exact i64 %X, -5 ; X/-5 == 0 --> x == 0
@@ -153,7 +153,7 @@ define i1 @sdiv_icmp4(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp5
+; CHECK-LABEL: @sdiv_icmp5(
; CHECK: icmp eq i64 %X, -5
define i1 @sdiv_icmp5(i64 %X) nounwind {
%A = sdiv exact i64 %X, -5 ; X/-5 == 1 --> x == -5
@@ -161,7 +161,7 @@ define i1 @sdiv_icmp5(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @sdiv_icmp6
+; CHECK-LABEL: @sdiv_icmp6(
; CHECK: icmp eq i64 %X, 5
define i1 @sdiv_icmp6(i64 %X) nounwind {
%A = sdiv exact i64 %X, -5 ; X/-5 == 1 --> x == 5
diff --git a/test/Transforms/InstCombine/exp2-1.ll b/test/Transforms/InstCombine/exp2-1.ll
index 1b0ad5000412..99fb9ecfd2b2 100644
--- a/test/Transforms/InstCombine/exp2-1.ll
+++ b/test/Transforms/InstCombine/exp2-1.ll
@@ -10,7 +10,7 @@ declare float @exp2f(float)
; Check exp2(sitofp(x)) -> ldexp(1.0, sext(x)).
define double @test_simplify1(i32 %x) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%conv = sitofp i32 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @ldexp
@@ -18,7 +18,7 @@ define double @test_simplify1(i32 %x) {
}
define double @test_simplify2(i16 signext %x) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%conv = sitofp i16 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @ldexp
@@ -26,7 +26,7 @@ define double @test_simplify2(i16 signext %x) {
}
define double @test_simplify3(i8 signext %x) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%conv = sitofp i8 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @ldexp
@@ -34,7 +34,7 @@ define double @test_simplify3(i8 signext %x) {
}
define float @test_simplify4(i32 %x) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%conv = sitofp i32 %x to float
%ret = call float @exp2f(float %conv)
; CHECK: call float @ldexpf
@@ -44,7 +44,7 @@ define float @test_simplify4(i32 %x) {
; Check exp2(uitofp(x)) -> ldexp(1.0, zext(x)).
define double @test_no_simplify1(i32 %x) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%conv = uitofp i32 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @exp2
@@ -52,7 +52,7 @@ define double @test_no_simplify1(i32 %x) {
}
define double @test_simplify6(i16 zeroext %x) {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%conv = uitofp i16 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @ldexp
@@ -60,7 +60,7 @@ define double @test_simplify6(i16 zeroext %x) {
}
define double @test_simplify7(i8 zeroext %x) {
-; CHECK: @test_simplify7
+; CHECK-LABEL: @test_simplify7(
%conv = uitofp i8 %x to double
%ret = call double @exp2(double %conv)
; CHECK: call double @ldexp
@@ -68,7 +68,7 @@ define double @test_simplify7(i8 zeroext %x) {
}
define float @test_simplify8(i8 zeroext %x) {
-; CHECK: @test_simplify8
+; CHECK-LABEL: @test_simplify8(
%conv = uitofp i8 %x to float
%ret = call float @exp2f(float %conv)
; CHECK: call float @ldexpf
diff --git a/test/Transforms/InstCombine/exp2-2.ll b/test/Transforms/InstCombine/exp2-2.ll
index bed063798e29..19368dc48c6b 100644
--- a/test/Transforms/InstCombine/exp2-2.ll
+++ b/test/Transforms/InstCombine/exp2-2.ll
@@ -9,7 +9,7 @@ declare float @exp2(double)
; Check that exp2 functions with the wrong prototype aren't simplified.
define float @test_no_simplify1(i32 %x) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%conv = sitofp i32 %x to double
%ret = call float @exp2(double %conv)
; CHECK: call float @exp2(double %conv)
diff --git a/test/Transforms/InstCombine/extractvalue.ll b/test/Transforms/InstCombine/extractvalue.ll
index 5e4c67778224..04c7ffa219da 100644
--- a/test/Transforms/InstCombine/extractvalue.ll
+++ b/test/Transforms/InstCombine/extractvalue.ll
@@ -3,7 +3,7 @@
declare void @bar({i32, i32} %a)
declare i32 @baz(i32 %a)
-; CHECK: define i32 @foo
+; CHECK-LABEL: define i32 @foo(
; CHECK-NOT: extractvalue
define i32 @foo(i32 %a, i32 %b) {
; Instcombine should fold various combinations of insertvalue and extractvalue
@@ -39,7 +39,7 @@ define i32 @foo(i32 %a, i32 %b) {
ret i32 %v5
}
-; CHECK: define i32 @extract2gep
+; CHECK-LABEL: define i32 @extract2gep(
; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* %pair, i32 0, i32 1
; CHECK-NEXT: [[LOAD:%[A-Za-z0-9]+]] = load i32* [[GEP]]
; CHECK-NEXT: store
@@ -67,7 +67,7 @@ end:
ret i32 %E
}
-; CHECK: define i32 @doubleextract2gep
+; CHECK-LABEL: define i32 @doubleextract2gep(
; CHECK-NEXT: [[GEP:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* %arg, i32 0, i32 1, i32 1
; CHECK-NEXT: [[LOAD:%[A-Za-z0-9]+]] = load i32* [[GEP]]
; CHECK-NEXT: ret i32 [[LOAD]]
diff --git a/test/Transforms/InstCombine/fast-math.ll b/test/Transforms/InstCombine/fast-math.ll
index edcbcc71dfb4..d8ba2a59ff5e 100644
--- a/test/Transforms/InstCombine/fast-math.ll
+++ b/test/Transforms/InstCombine/fast-math.ll
@@ -6,14 +6,14 @@ define float @fold(float %a) {
%mul = fmul fast float %a, 0x3FF3333340000000
%mul1 = fmul fast float %mul, 0x4002666660000000
ret float %mul1
-; CHECK: @fold
+; CHECK-LABEL: @fold(
; CHECK: fmul fast float %a, 0x4006147AE0000000
}
; Same testing-case as the one used in fold() except that the operators have
; fixed FP mode.
define float @notfold(float %a) {
-; CHECK: @notfold
+; CHECK-LABEL: @notfold(
; CHECK: %mul = fmul fast float %a, 0x3FF3333340000000
%mul = fmul fast float %a, 0x3FF3333340000000
%mul1 = fmul float %mul, 0x4002666660000000
@@ -21,7 +21,7 @@ define float @notfold(float %a) {
}
define float @fold2(float %a) {
-; CHECK: @fold2
+; CHECK-LABEL: @fold2(
; CHECK: fmul fast float %a, 0x4006147AE0000000
%mul = fmul float %a, 0x3FF3333340000000
%mul1 = fmul fast float %mul, 0x4002666660000000
@@ -33,7 +33,7 @@ define double @fold3(double %f1) {
%t1 = fmul fast double 2.000000e+00, %f1
%t2 = fadd fast double %f1, %t1
ret double %t2
-; CHECK: @fold3
+; CHECK-LABEL: @fold3(
; CHECK: fmul fast double %f1, 3.000000e+00
}
@@ -43,7 +43,7 @@ define float @fold4(float %f1, float %f2) {
%sub1 = fsub float 5.000000e+00, %f2
%add = fadd fast float %sub, %sub1
ret float %add
-; CHECK: @fold4
+; CHECK-LABEL: @fold4(
; CHECK: %1 = fadd fast float %f1, %f2
; CHECK: fsub fast float 9.000000e+00, %1
}
@@ -53,7 +53,7 @@ define float @fold5(float %f1, float %f2) {
%add = fadd float %f1, 4.000000e+00
%add1 = fadd fast float %add, 5.000000e+00
ret float %add1
-; CHECK: @fold5
+; CHECK-LABEL: @fold5(
; CHECK: fadd fast float %f1, 9.000000e+00
}
@@ -62,7 +62,7 @@ define float @fold6(float %f1) {
%t1 = fadd fast float %f1, %f1
%t2 = fadd fast float %f1, %t1
ret float %t2
-; CHECK: @fold6
+; CHECK-LABEL: @fold6(
; CHECK: fmul fast float %f1, 3.000000e+00
}
@@ -72,7 +72,7 @@ define float @fold7(float %f1) {
%t2 = fadd fast float %f1, %f1
%t3 = fadd fast float %t1, %t2
ret float %t3
-; CHECK: @fold7
+; CHECK-LABEL: @fold7(
; CHECK: fmul fast float %f1, 7.000000e+00
}
@@ -92,7 +92,7 @@ define float @fold9(float %f1, float %f2) {
%t3 = fsub fast float %f1, %t1
ret float %t3
-; CHECK: @fold9
+; CHECK-LABEL: @fold9(
; CHECK: fsub fast float 0.000000e+00, %f2
}
@@ -106,7 +106,7 @@ define float @fold10(float %f1, float %f2) {
%t2 = fsub fast float %f2, 3.000000e+00
%t3 = fadd fast float %t1, %t2
ret float %t3
-; CHECK: @fold10
+; CHECK-LABEL: @fold10(
; CHECK: %t3 = fadd fast float %t2, -1.000000e+00
; CHECK: ret float %t3
}
@@ -117,7 +117,7 @@ define float @fail1(float %f1, float %f2) {
%add = fadd fast float %conv3, %conv3
%add2 = fadd fast float %add, %conv3
ret float %add2
-; CHECK: @fail1
+; CHECK-LABEL: @fail1(
; CHECK: ret
}
@@ -126,7 +126,7 @@ define double @fail2(double %f1, double %f2) {
%t2 = fadd fast double %f1, %f2
%t3 = fsub fast double %t1, %t2
ret double %t3
-; CHECK: @fail2
+; CHECK-LABEL: @fail2(
; CHECK: ret
}
@@ -152,7 +152,7 @@ define float @fmul_distribute1(float %f1) {
%t2 = fadd float %t1, 2.0e+3
%t3 = fmul fast float %t2, 5.0e+3
ret float %t3
-; CHECK: @fmul_distribute1
+; CHECK-LABEL: @fmul_distribute1(
; CHECK: %1 = fmul fast float %f1, 3.000000e+07
; CHECK: %t3 = fadd fast float %1, 1.000000e+07
}
@@ -165,7 +165,7 @@ define double @fmul_distribute2(double %f1, double %f2) {
%t3 = fmul fast double %t2, 0x10000000000000
ret double %t3
-; CHECK: @fmul_distribute2
+; CHECK-LABEL: @fmul_distribute2(
; CHECK: %1 = fdiv fast double %f1, 0x7FE8000000000000
; CHECK: fadd fast double %1, 0x69000000000000
}
@@ -178,7 +178,7 @@ define double @fmul_distribute3(double %f1) {
%t3 = fmul fast double %t2, 0x10000000000000
ret double %t3
-; CHECK: @fmul_distribute3
+; CHECK-LABEL: @fmul_distribute3(
; CHECK: fmul fast double %t2, 0x10000000000000
}
@@ -188,7 +188,7 @@ define float @fmul_distribute4(float %f1) {
%t2 = fsub float 2.0e+3, %t1
%t3 = fmul fast float %t2, 5.0e+3
ret float %t3
-; CHECK: @fmul_distribute4
+; CHECK-LABEL: @fmul_distribute4(
; CHECK: %1 = fmul fast float %f1, 3.000000e+07
; CHECK: %t3 = fsub fast float 1.000000e+07, %1
}
@@ -198,16 +198,28 @@ define float @fmul2(float %f1) {
%t1 = fdiv float 2.0e+3, %f1
%t3 = fmul fast float %t1, 6.0e+3
ret float %t3
-; CHECK: @fmul2
+; CHECK-LABEL: @fmul2(
; CHECK: fdiv fast float 1.200000e+07, %f1
}
+; X/C1 * C2 => X * (C2/C1) is disabled if X/C1 has multiple uses
+@fmul2_external = external global float
+define float @fmul2_disable(float %f1) {
+ %div = fdiv fast float 1.000000e+00, %f1
+ store float %div, float* @fmul2_external
+ %mul = fmul fast float %div, 2.000000e+00
+ ret float %mul
+; CHECK-LABEL: @fmul2_disable
+; CHECK: store
+; CHECK: fmul fast
+}
+
; X/C1 * C2 => X * (C2/C1) (if C2/C1 is normal Fp)
define float @fmul3(float %f1, float %f2) {
%t1 = fdiv float %f1, 2.0e+3
%t3 = fmul fast float %t1, 6.0e+3
ret float %t3
-; CHECK: @fmul3
+; CHECK-LABEL: @fmul3(
; CHECK: fmul fast float %f1, 3.000000e+00
}
@@ -218,7 +230,7 @@ define float @fmul4(float %f1, float %f2) {
%t1 = fdiv float %f1, 2.0e+3
%t3 = fmul fast float %t1, 0x3810000000000000
ret float %t3
-; CHECK: @fmul4
+; CHECK-LABEL: @fmul4(
; CHECK: fmul fast float %t1, 0x3810000000000000
}
@@ -229,7 +241,7 @@ define float @fmul5(float %f1, float %f2) {
%t1 = fdiv float %f1, 3.0e+0
%t3 = fmul fast float %t1, 0x3810000000000000
ret float %t3
-; CHECK: @fmul5
+; CHECK-LABEL: @fmul5(
; CHECK: fdiv fast float %f1, 0x47E8000000000000
}
@@ -238,7 +250,7 @@ define float @fmul6(float %f1, float %f2) {
%mul = fmul float %f1, %f2
%mul1 = fmul fast float %mul, %f1
ret float %mul1
-; CHECK: @fmul6
+; CHECK-LABEL: @fmul6(
; CHECK: fmul fast float %f1, %f1
}
@@ -248,7 +260,7 @@ define float @fmul7(float %f1, float %f2) {
%mul1 = fmul fast float %mul, %f1
%add = fadd float %mul1, %mul
ret float %add
-; CHECK: @fmul7
+; CHECK-LABEL: @fmul7(
; CHECK: fmul fast float %mul, %f1
}
@@ -262,7 +274,7 @@ define float @fneg1(float %f1, float %f2) {
%sub1 = fsub nsz float 0.000000e+00, %f2
%mul = fmul float %sub, %sub1
ret float %mul
-; CHECK: @fneg1
+; CHECK-LABEL: @fneg1(
; CHECK: fmul float %f1, %f2
}
@@ -280,7 +292,7 @@ define float @fdiv1(float %x) {
; 0x3FF3333340000000 = 1.2f
; 0x4002666660000000 = 2.3f
; 0x3FD7303B60000000 = 0.36231884057971014492
-; CHECK: @fdiv1
+; CHECK-LABEL: @fdiv1(
; CHECK: fmul fast float %x, 0x3FD7303B60000000
}
@@ -293,7 +305,7 @@ define float @fdiv2(float %x) {
; 0x3FF3333340000000 = 1.2f
; 0x4002666660000000 = 2.3f
; 0x3FE0B21660000000 = 0.52173918485641479492
-; CHECK: @fdiv2
+; CHECK-LABEL: @fdiv2(
; CHECK: fmul fast float %x, 0x3FE0B21660000000
}
@@ -303,7 +315,7 @@ define float @fdiv3(float %x) {
%div = fdiv float %x, 0x47EFFFFFE0000000
%div1 = fdiv fast float %div, 0x4002666660000000
ret float %div1
-; CHECK: @fdiv3
+; CHECK-LABEL: @fdiv3(
; CHECK: fdiv float %x, 0x47EFFFFFE0000000
}
@@ -312,7 +324,7 @@ define float @fdiv4(float %x) {
%mul = fmul float %x, 0x47EFFFFFE0000000
%div = fdiv float %mul, 0x3FC99999A0000000
ret float %div
-; CHECK: @fdiv4
+; CHECK-LABEL: @fdiv4(
; CHECK: fmul float %x, 0x47EFFFFFE0000000
}
@@ -321,7 +333,7 @@ define float @fdiv5(float %f1, float %f2, float %f3) {
%t1 = fdiv float %f1, %f2
%t2 = fdiv fast float %t1, %f3
ret float %t2
-; CHECK: @fdiv5
+; CHECK-LABEL: @fdiv5(
; CHECK: fmul float %f2, %f3
}
@@ -330,7 +342,7 @@ define float @fdiv6(float %f1, float %f2, float %f3) {
%t1 = fdiv float %f1, %f2
%t2 = fdiv fast float %f3, %t1
ret float %t2
-; CHECK: @fdiv6
+; CHECK-LABEL: @fdiv6(
; CHECK: fmul float %f3, %f2
}
@@ -339,7 +351,7 @@ define float @fdiv7(float %x) {
%t1 = fmul float %x, 3.0e0
%t2 = fdiv fast float 15.0e0, %t1
ret float %t2
-; CHECK: @fdiv7
+; CHECK-LABEL: @fdiv7(
; CHECK: fdiv fast float 5.000000e+00, %x
}
@@ -348,7 +360,7 @@ define float @fdiv8(float %x) {
%t1 = fdiv float %x, 3.0e0
%t2 = fdiv fast float 15.0e0, %t1
ret float %t2
-; CHECK: @fdiv8
+; CHECK-LABEL: @fdiv8(
; CHECK: fdiv fast float 4.500000e+01, %x
}
@@ -357,7 +369,7 @@ define float @fdiv9(float %x) {
%t1 = fdiv float 3.0e0, %x
%t2 = fdiv fast float 15.0e0, %t1
ret float %t2
-; CHECK: @fdiv9
+; CHECK-LABEL: @fdiv9(
; CHECK: fmul fast float %x, 5.000000e+00
}
@@ -372,7 +384,7 @@ define float @fact_mul1(float %x, float %y, float %z) {
%t2 = fmul fast float %y, %z
%t3 = fadd fast float %t1, %t2
ret float %t3
-; CHECK: @fact_mul1
+; CHECK-LABEL: @fact_mul1(
; CHECK: fmul fast float %1, %z
}
@@ -382,7 +394,7 @@ define float @fact_mul2(float %x, float %y, float %z) {
%t2 = fmul fast float %y, %z
%t3 = fsub fast float %t1, %t2
ret float %t3
-; CHECK: @fact_mul2
+; CHECK-LABEL: @fact_mul2(
; CHECK: fmul fast float %1, %z
}
@@ -392,7 +404,7 @@ define float @fact_mul3(float %x, float %y, float %z) {
%t1 = fmul fast float %z, %x
%t3 = fsub fast float %t1, %t2
ret float %t3
-; CHECK: @fact_mul3
+; CHECK-LABEL: @fact_mul3(
; CHECK: fmul fast float %1, %z
}
@@ -402,7 +414,7 @@ define float @fact_mul4(float %x, float %y, float %z) {
%t2 = fmul fast float %z, %y
%t3 = fsub fast float %t1, %t2
ret float %t3
-; CHECK: @fact_mul4
+; CHECK-LABEL: @fact_mul4(
; CHECK: fmul fast float %1, %z
}
diff --git a/test/Transforms/InstCombine/fcmp.ll b/test/Transforms/InstCombine/fcmp.ll
index 376fa079d24c..afc6782a0122 100644
--- a/test/Transforms/InstCombine/fcmp.ll
+++ b/test/Transforms/InstCombine/fcmp.ll
@@ -5,7 +5,7 @@ define i1 @test1(float %x, float %y) nounwind {
%ext2 = fpext float %y to double
%cmp = fcmp ogt double %ext1, %ext2
ret i1 %cmp
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: fcmp ogt float %x, %y
}
@@ -13,7 +13,7 @@ define i1 @test2(float %a) nounwind {
%ext = fpext float %a to double
%cmp = fcmp ogt double %ext, 1.000000e+00
ret i1 %cmp
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: fcmp ogt float %a, 1.0
}
@@ -21,7 +21,7 @@ define i1 @test3(float %a) nounwind {
%ext = fpext float %a to double
%cmp = fcmp ogt double %ext, 0x3FF0000000000001 ; more precision than float.
ret i1 %cmp
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: fpext float %a to double
}
@@ -29,7 +29,7 @@ define i1 @test4(float %a) nounwind {
%ext = fpext float %a to double
%cmp = fcmp ogt double %ext, 0x36A0000000000000 ; denormal in float.
ret i1 %cmp
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: fpext float %a to double
}
@@ -37,7 +37,7 @@ define i1 @test5(float %a) nounwind {
%neg = fsub float -0.000000e+00, %a
%cmp = fcmp ogt float %neg, 1.000000e+00
ret i1 %cmp
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: fcmp olt float %a, -1.0
}
@@ -46,7 +46,7 @@ define i1 @test6(float %x, float %y) nounwind {
%neg2 = fsub float -0.000000e+00, %y
%cmp = fcmp olt float %neg1, %neg2
ret i1 %cmp
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: fcmp ogt float %x, %y
}
@@ -54,7 +54,7 @@ define i1 @test7(float %x) nounwind readnone ssp noredzone {
%ext = fpext float %x to ppc_fp128
%cmp = fcmp ogt ppc_fp128 %ext, 0xM00000000000000000000000000000000
ret i1 %cmp
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: fcmp ogt float %x, 0.000000e+00
}
@@ -65,7 +65,7 @@ define float @test8(float %x) nounwind readnone optsize ssp {
%conv2 = sitofp i32 %conv1 to float
ret float %conv2
; Float comparison to zero shouldn't cast to double.
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NEXT: fcmp olt float %x, 0.000000e+00
}
@@ -76,7 +76,7 @@ define i32 @test9(double %a) nounwind {
%cmp = fcmp olt double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NOT: fabs
; CHECK: ret i32 0
}
@@ -86,7 +86,7 @@ define i32 @test10(double %a) nounwind {
%cmp = fcmp ole double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK-NOT: fabs
; CHECK: fcmp oeq double %a, 0.000000e+00
}
@@ -96,7 +96,7 @@ define i32 @test11(double %a) nounwind {
%cmp = fcmp ogt double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK-NOT: fabs
; CHECK: fcmp one double %a, 0.000000e+00
}
@@ -106,7 +106,7 @@ define i32 @test12(double %a) nounwind {
%cmp = fcmp oge double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NOT: fabs
; CHECK: fcmp ord double %a, 0.000000e+00
}
@@ -116,7 +116,7 @@ define i32 @test13(double %a) nounwind {
%cmp = fcmp une double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK-NOT: fabs
; CHECK: fcmp une double %a, 0.000000e+00
}
@@ -126,7 +126,7 @@ define i32 @test14(double %a) nounwind {
%cmp = fcmp oeq double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK-NOT: fabs
; CHECK: fcmp oeq double %a, 0.000000e+00
}
@@ -136,7 +136,7 @@ define i32 @test15(double %a) nounwind {
%cmp = fcmp one double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK-NOT: fabs
; CHECK: fcmp one double %a, 0.000000e+00
}
@@ -146,7 +146,7 @@ define i32 @test16(double %a) nounwind {
%cmp = fcmp ueq double %call, 0.000000e+00
%conv = zext i1 %cmp to i32
ret i32 %conv
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK-NOT: fabs
; CHECK: fcmp ueq double %a, 0.000000e+00
}
diff --git a/test/Transforms/InstCombine/fdiv.ll b/test/Transforms/InstCombine/fdiv.ll
index a2cce016e188..1edbc5ecd60b 100644
--- a/test/Transforms/InstCombine/fdiv.ll
+++ b/test/Transforms/InstCombine/fdiv.ll
@@ -4,7 +4,7 @@ define float @test1(float %x) nounwind readnone ssp {
%div = fdiv float %x, 0x3810000000000000
ret float %div
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: fmul float %x, 0x47D0000000000000
}
@@ -12,7 +12,7 @@ define float @test2(float %x) nounwind readnone ssp {
%div = fdiv float %x, 0x47E0000000000000
ret float %div
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: fdiv float %x, 0x47E0000000000000
}
@@ -20,6 +20,6 @@ define float @test3(float %x) nounwind readnone ssp {
%div = fdiv float %x, 0x36A0000000000000
ret float %div
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: fdiv float %x, 0x36A0000000000000
}
diff --git a/test/Transforms/InstCombine/ffs-1.ll b/test/Transforms/InstCombine/ffs-1.ll
index 0510df3d24b9..1dec11da0eb0 100644
--- a/test/Transforms/InstCombine/ffs-1.ll
+++ b/test/Transforms/InstCombine/ffs-1.ll
@@ -1,7 +1,7 @@
; Test that the ffs* library call simplifier works correctly.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
-; RUN: opt < %s -mtriple i386-pc-linux -instcombine -S | FileCheck %s -check-prefix=LINUX
+; RUN: opt < %s -mtriple i386-pc-linux -instcombine -S | FileCheck %s -check-prefix=CHECK-LINUX
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
@@ -12,21 +12,21 @@ declare i32 @ffsll(i64)
; Check ffs(0) -> 0.
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @ffs(i32 0)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify2() {
-; CHECK-LINUX: @test_simplify2
+; CHECK-LINUX-LABEL: @test_simplify2(
%ret = call i32 @ffsl(i32 0)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 0
}
define i32 @test_simplify3() {
-; CHECK-LINUX: @test_simplify3
+; CHECK-LINUX-LABEL: @test_simplify3(
%ret = call i32 @ffsll(i64 0)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 0
@@ -35,63 +35,63 @@ define i32 @test_simplify3() {
; Check ffs(c) -> cttz(c) + 1, where 'c' is a constant.
define i32 @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%ret = call i32 @ffs(i32 1)
ret i32 %ret
; CHECK-NEXT: ret i32 1
}
define i32 @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%ret = call i32 @ffs(i32 2048)
ret i32 %ret
; CHECK-NEXT: ret i32 12
}
define i32 @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%ret = call i32 @ffs(i32 65536)
ret i32 %ret
; CHECK-NEXT: ret i32 17
}
define i32 @test_simplify7() {
-; CHECK-LINUX: @test_simplify7
+; CHECK-LINUX-LABEL: @test_simplify7(
%ret = call i32 @ffsl(i32 65536)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 17
}
define i32 @test_simplify8() {
-; CHECK-LINUX: @test_simplify8
+; CHECK-LINUX-LABEL: @test_simplify8(
%ret = call i32 @ffsll(i64 1024)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 11
}
define i32 @test_simplify9() {
-; CHECK-LINUX: @test_simplify9
+; CHECK-LINUX-LABEL: @test_simplify9(
%ret = call i32 @ffsll(i64 65536)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 17
}
define i32 @test_simplify10() {
-; CHECK-LINUX: @test_simplify10
+; CHECK-LINUX-LABEL: @test_simplify10(
%ret = call i32 @ffsll(i64 17179869184)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 35
}
define i32 @test_simplify11() {
-; CHECK-LINUX: @test_simplify11
+; CHECK-LINUX-LABEL: @test_simplify11(
%ret = call i32 @ffsll(i64 281474976710656)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 49
}
define i32 @test_simplify12() {
-; CHECK-LINUX: @test_simplify12
+; CHECK-LINUX-LABEL: @test_simplify12(
%ret = call i32 @ffsll(i64 1152921504606846976)
ret i32 %ret
; CHECK-LINUX-NEXT: ret i32 61
@@ -100,7 +100,7 @@ define i32 @test_simplify12() {
; Check ffs(x) -> x != 0 ? (i32)llvm.cttz(x) + 1 : 0.
define i32 @test_simplify13(i32 %x) {
-; CHECK: @test_simplify13
+; CHECK-LABEL: @test_simplify13(
%ret = call i32 @ffs(i32 %x)
; CHECK-NEXT: [[CTTZ:%[a-z0-9]+]] = call i32 @llvm.cttz.i32(i32 %x, i1 false)
; CHECK-NEXT: [[INC:%[a-z0-9]+]] = add i32 [[CTTZ]], 1
@@ -111,7 +111,7 @@ define i32 @test_simplify13(i32 %x) {
}
define i32 @test_simplify14(i32 %x) {
-; CHECK-LINUX: @test_simplify14
+; CHECK-LINUX-LABEL: @test_simplify14(
%ret = call i32 @ffsl(i32 %x)
; CHECK-LINUX-NEXT: [[CTTZ:%[a-z0-9]+]] = call i32 @llvm.cttz.i32(i32 %x, i1 false)
; CHECK-LINUX-NEXT: [[INC:%[a-z0-9]+]] = add i32 [[CTTZ]], 1
@@ -122,7 +122,7 @@ define i32 @test_simplify14(i32 %x) {
}
define i32 @test_simplify15(i64 %x) {
-; CHECK-LINUX: @test_simplify15
+; CHECK-LINUX-LABEL: @test_simplify15(
%ret = call i32 @ffsll(i64 %x)
; CHECK-LINUX-NEXT: [[CTTZ:%[a-z0-9]+]] = call i64 @llvm.cttz.i64(i64 %x, i1 false)
; CHECK-LINUX-NEXT: [[INC:%[a-z0-9]+]] = add i64 [[CTTZ]], 1
diff --git a/test/Transforms/InstCombine/float-shrink-compare.ll b/test/Transforms/InstCombine/float-shrink-compare.ll
new file mode 100644
index 000000000000..26f77a7f702b
--- /dev/null
+++ b/test/Transforms/InstCombine/float-shrink-compare.ll
@@ -0,0 +1,179 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.8.0"
+
+define i32 @test1(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @ceil(double %1) nounwind readnone
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: %ceilf = call float @ceilf(float %x)
+; CHECK-NEXT: fcmp oeq float %ceilf, %y
+}
+
+define i32 @test2(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @fabs(double %1) nounwind readnone
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: %fabsf = call float @fabsf(float %x)
+; CHECK-NEXT: fcmp oeq float %fabsf, %y
+}
+
+define i32 @test3(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @floor(double %1) nounwind readnone
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: %floorf = call float @floorf(float %x)
+; CHECK-NEXT: fcmp oeq float %floorf, %y
+}
+
+define i32 @test4(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @nearbyint(double %1) nounwind
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x)
+; CHECK-NEXT: fcmp oeq float %nearbyintf, %y
+}
+
+define i32 @test5(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @rint(double %1) nounwind
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: %rintf = call float @rintf(float %x)
+; CHECK-NEXT: fcmp oeq float %rintf, %y
+}
+
+define i32 @test6(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @round(double %1) nounwind readnone
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: %roundf = call float @roundf(float %x)
+; CHECK-NEXT: fcmp oeq float %roundf, %y
+}
+
+define i32 @test7(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %x to double
+ %2 = call double @trunc(double %1) nounwind
+ %3 = fpext float %y to double
+ %4 = fcmp oeq double %2, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: %truncf = call float @truncf(float %x)
+; CHECK-NEXT: fcmp oeq float %truncf, %y
+}
+
+define i32 @test8(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @ceil(double %2) nounwind readnone
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: %ceilf = call float @ceilf(float %x)
+; CHECK-NEXT: fcmp oeq float %ceilf, %y
+}
+
+define i32 @test9(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @fabs(double %2) nounwind readnone
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test9(
+; CHECK-NEXT: %fabsf = call float @fabsf(float %x)
+; CHECK-NEXT: fcmp oeq float %fabsf, %y
+}
+
+define i32 @test10(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @floor(double %2) nounwind readnone
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test10(
+; CHECK-NEXT: %floorf = call float @floorf(float %x)
+; CHECK-NEXT: fcmp oeq float %floorf, %y
+}
+
+define i32 @test11(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @nearbyint(double %2) nounwind
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test11(
+; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x)
+; CHECK-NEXT: fcmp oeq float %nearbyintf, %y
+}
+
+define i32 @test12(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @rint(double %2) nounwind
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test12(
+; CHECK-NEXT: %rintf = call float @rintf(float %x)
+; CHECK-NEXT: fcmp oeq float %rintf, %y
+}
+
+define i32 @test13(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @round(double %2) nounwind readnone
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test13(
+; CHECK-NEXT: %roundf = call float @roundf(float %x)
+; CHECK-NEXT: fcmp oeq float %roundf, %y
+}
+
+define i32 @test14(float %x, float %y) nounwind uwtable {
+ %1 = fpext float %y to double
+ %2 = fpext float %x to double
+ %3 = call double @trunc(double %2) nounwind
+ %4 = fcmp oeq double %1, %3
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+; CHECK-LABEL: @test14(
+; CHECK-NEXT: %truncf = call float @truncf(float %x)
+; CHECK-NEXT: fcmp oeq float %truncf, %y
+}
+
+declare double @fabs(double) nounwind readnone
+declare double @ceil(double) nounwind readnone
+declare double @floor(double) nounwind readnone
+declare double @nearbyint(double) nounwind readnone
+declare double @rint(double) nounwind readnone
+declare double @round(double) nounwind readnone
+declare double @trunc(double) nounwind readnone
diff --git a/test/Transforms/InstCombine/fmul.ll b/test/Transforms/InstCombine/fmul.ll
index 3671b4c6991c..402ee52e624a 100644
--- a/test/Transforms/InstCombine/fmul.ll
+++ b/test/Transforms/InstCombine/fmul.ll
@@ -6,7 +6,7 @@ define float @test1(float %x) {
%mul = fmul float %sub, 2.0e+1
ret float %mul
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: fmul float %x, -2.000000e+01
}
@@ -16,7 +16,7 @@ define float @test2(float %x) {
%mul = fmul float %sub, 2.0e+1
ret float %mul
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: fmul float %x, -2.000000e+01
}
@@ -26,7 +26,7 @@ define float @test3(float %x, float %y) {
%sub2 = fsub float -0.000000e+00, %y
%mul = fmul float %sub1, %sub2
ret float %mul
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: fmul float %x, %y
}
@@ -36,7 +36,7 @@ define float @test4(float %x, float %y) {
%sub2 = fsub nsz float 0.000000e+00, %y
%mul = fmul float %sub1, %sub2
ret float %mul
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: fmul float %x, %y
}
@@ -45,7 +45,7 @@ define float @test5(float %x, float %y) {
%sub1 = fsub float -0.000000e+00, %x
%mul = fmul float %sub1, %y
ret float %mul
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %1 = fmul float %x, %y
; CHECK: %mul = fsub float -0.000000e+00, %1
}
@@ -55,7 +55,7 @@ define float @test6(float %x, float %y) {
%sub1 = fsub nsz float 0.000000e+00, %x
%mul = fmul float %sub1, %y
ret float %mul
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: %1 = fmul float %x, %y
; CHECK: %mul = fsub float -0.000000e+00, %1
}
@@ -67,6 +67,29 @@ define float @test7(float %x, float %y) {
%mul = fmul float %sub1, %y
%mul2 = fmul float %mul, %sub1
ret float %mul2
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: fsub float -0.000000e+00, %x
}
+
+; Don't crash when attempting to cast a constant FMul to an instruction.
+define void @test8(i32* %inout) {
+entry:
+ %0 = load i32* %inout, align 4
+ %conv = uitofp i32 %0 to float
+ %vecinit = insertelement <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float undef>, float %conv, i32 3
+ %sub = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %vecinit
+ %1 = shufflevector <4 x float> %sub, <4 x float> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+ %mul = fmul <4 x float> zeroinitializer, %1
+ br label %for.cond
+
+for.cond: ; preds = %for.body, %entry
+ %local_var_7.0 = phi <4 x float> [ %mul, %entry ], [ %2, %for.body ]
+ br i1 undef, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ %2 = insertelement <4 x float> %local_var_7.0, float 0.000000e+00, i32 2
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret void
+}
diff --git a/test/Transforms/InstCombine/fneg-ext.ll b/test/Transforms/InstCombine/fneg-ext.ll
new file mode 100644
index 000000000000..922d26a465b7
--- /dev/null
+++ b/test/Transforms/InstCombine/fneg-ext.ll
@@ -0,0 +1,23 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+; CHECK: test1
+define double @test1(float %a, double %b) nounwind readnone ssp uwtable {
+; CHECK-NOT: fsub
+; CHECK: fpext
+; CHECK: fadd
+ %1 = fsub float -0.000000e+00, %a
+ %2 = fpext float %1 to double
+ %3 = fsub double %b, %2
+ ret double %3
+}
+
+; CHECK: test2
+define double @test2(float %a, double %b) nounwind readnone ssp uwtable {
+; CHECK-NOT: fsub
+; CHECK: fpext
+; CHECK: fadd fast
+ %1 = fsub float -0.000000e+00, %a
+ %2 = fpext float %1 to double
+ %3 = fsub fast double %b, %2
+ ret double %3
+}
diff --git a/test/Transforms/InstCombine/fold-bin-operand.ll b/test/Transforms/InstCombine/fold-bin-operand.ll
index a8bad0df5960..d3303262be3f 100644
--- a/test/Transforms/InstCombine/fold-bin-operand.ll
+++ b/test/Transforms/InstCombine/fold-bin-operand.ll
@@ -2,14 +2,14 @@
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
define i1 @f(i1 %x) {
-; CHECK: @f
+; CHECK-LABEL: @f(
; CHECK: ret i1 false
%b = and i1 %x, icmp eq (i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 2 to i8*))
ret i1 %b
}
define i32 @g(i32 %x) {
-; CHECK: @g
+; CHECK-LABEL: @g(
; CHECK: ret i32 %x
%b = add i32 %x, zext (i1 icmp eq (i8* inttoptr (i32 1000000 to i8*), i8* inttoptr (i32 2000000 to i8*)) to i32)
ret i32 %b
diff --git a/test/Transforms/InstCombine/fold-calls.ll b/test/Transforms/InstCombine/fold-calls.ll
index 504f874beaeb..1a9a9fd2e9ee 100644
--- a/test/Transforms/InstCombine/fold-calls.ll
+++ b/test/Transforms/InstCombine/fold-calls.ll
@@ -1,7 +1,7 @@
; RUN: opt -instcombine -S < %s | FileCheck %s
; This shouldn't fold, because sin(inf) is invalid.
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK: %t = call double @sin(double 0x7FF0000000000000)
define double @foo() {
%t = call double @sin(double 0x7FF0000000000000)
@@ -9,7 +9,7 @@ define double @foo() {
}
; This should fold.
-; CHECK: @bar
+; CHECK-LABEL: @bar(
; CHECK: ret double 0.0
define double @bar() {
%t = call double @sin(double 0.0)
diff --git a/test/Transforms/InstCombine/fold-fops-into-selects.ll b/test/Transforms/InstCombine/fold-fops-into-selects.ll
new file mode 100644
index 000000000000..07aebb13eff3
--- /dev/null
+++ b/test/Transforms/InstCombine/fold-fops-into-selects.ll
@@ -0,0 +1,71 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+define float @test1(i1 %A) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float 0.000000e+00
+ %op = fsub float 1.000000e+00, %cf
+ ret float %op
+; CHECK-LABEL: @test1(
+; CHECK: select i1 %A, float 0.000000e+00, float 1.000000e+00
+}
+
+define float @test2(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fadd float 2.000000e+00, %cf
+ ret float %op
+; CHECK-LABEL: @test2(
+; CHECK: [[OP:%.*]] = fadd float %B, 2.000000e+00
+; CHECK: select i1 %A, float 3.000000e+00, float [[OP]]
+}
+
+define float @test3(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fsub float 2.000000e+00, %cf
+ ret float %op
+; CHECK-LABEL: @test3(
+; CHECK: [[OP:%.*]] = fsub float 2.000000e+00, %B
+; CHECK: select i1 %A, float 1.000000e+00, float [[OP]]
+}
+
+define float @test4(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fmul float 2.000000e+00, %cf
+ ret float %op
+; CHECK-LABEL: @test4(
+; CHECK: [[OP:%.*]] = fmul float %B, 2.000000e+00
+; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
+}
+
+define float @test5(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fdiv float 2.000000e+00, %cf
+ ret float %op
+; CHECK-LABEL: @test5(
+; CHECK: [[OP:%.*]] = fdiv float 2.000000e+00, %B
+; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
+}
+
+define float @test6(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fdiv float %cf, 2.000000e+00
+ ret float %op
+; CHECK-LABEL: @test6(
+; CHECK: [[OP:%.*]] = fmul float %B, 5.000000e-01
+; CHECK: select i1 %A, float 5.000000e-01, float [[OP]]
+}
+
+define float @test7(i1 %A, float %B) {
+EntryBlock:
+ %cf = select i1 %A, float 1.000000e+00, float %B
+ %op = fdiv float %cf, 3.000000e+00
+ ret float %op
+; CHECK-LABEL: @test7(
+; CHECK: [[OP:%.*]] = fdiv float %B, 3.000000e+00
+; CHECK: select i1 %A, float 0x3FD5555560000000, float [[OP]]
+}
+
diff --git a/test/Transforms/InstCombine/fold-vector-select.ll b/test/Transforms/InstCombine/fold-vector-select.ll
index 2cb970bf4177..b58d9dc90acc 100644
--- a/test/Transforms/InstCombine/fold-vector-select.ll
+++ b/test/Transforms/InstCombine/fold-vector-select.ll
@@ -1,4 +1,6 @@
-; RUN: opt < %s -instcombine -S | not grep select
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; CHECK-NOT: select
define void @foo(<4 x i32> *%A, <4 x i32> *%B, <4 x i32> *%C, <4 x i32> *%D,
<4 x i32> *%E, <4 x i32> *%F, <4 x i32> *%G, <4 x i32> *%H,
diff --git a/test/Transforms/InstCombine/fpcast.ll b/test/Transforms/InstCombine/fpcast.ll
index 09f053289dc1..05d1b48d5996 100644
--- a/test/Transforms/InstCombine/fpcast.ll
+++ b/test/Transforms/InstCombine/fpcast.ll
@@ -31,4 +31,16 @@ define half @test4(float %a) {
ret half %c
}
+; CHECK: test5
+define half @test5(float %a, float %b, float %c) {
+; CHECK: fcmp ogt
+; CHECK: fptrunc
+; CHECK: select
+; CHECK: half 0xH3C00
+ %d = fcmp ogt float %a, %b
+ %e = select i1 %d, float %c, float 1.0
+ %f = fptrunc float %e to half
+ ret half %f
+}
+
declare float @llvm.fabs.f32(float) nounwind readonly
diff --git a/test/Transforms/InstCombine/fprintf-1.ll b/test/Transforms/InstCombine/fprintf-1.ll
index e1dc191bd700..3f6a314e3472 100644
--- a/test/Transforms/InstCombine/fprintf-1.ll
+++ b/test/Transforms/InstCombine/fprintf-1.ll
@@ -1,7 +1,7 @@
; Test that the fprintf library call simplifier works correctly.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
-; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=IPRINTF
+; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=CHECK-IPRINTF
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
@@ -18,7 +18,7 @@ declare i32 @fprintf(%FILE*, i8*, ...)
; Check fprintf(fp, "foo") -> fwrite("foo", 3, 1, fp).
define void @test_simplify1(%FILE* %fp) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%fmt = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt)
; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([13 x i8]* @hello_world, i32 0, i32 0), i32 12, i32 1, %FILE* %fp)
@@ -29,7 +29,7 @@ define void @test_simplify1(%FILE* %fp) {
; Check fprintf(fp, "%c", chr) -> fputc(chr, fp).
define void @test_simplify2(%FILE* %fp) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%fmt = getelementptr [3 x i8]* @percent_c, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt, i8 104)
; CHECK-NEXT: call i32 @fputc(i32 104, %FILE* %fp)
@@ -41,7 +41,7 @@ define void @test_simplify2(%FILE* %fp) {
; NOTE: The fputs simplifier simplifies this further to fwrite.
define void @test_simplify3(%FILE* %fp) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%fmt = getelementptr [3 x i8]* @percent_s, i32 0, i32 0
%str = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt, i8* %str)
@@ -53,7 +53,7 @@ define void @test_simplify3(%FILE* %fp) {
; Check fprintf(fp, fmt, ...) -> fiprintf(fp, fmt, ...) if no floating point.
define void @test_simplify4(%FILE* %fp) {
-; CHECK-IPRINTF: @test_simplify4
+; CHECK-IPRINTF-LABEL: @test_simplify4(
%fmt = getelementptr [3 x i8]* @percent_d, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt, i32 187)
; CHECK-NEXT-IPRINTF: call i32 (%FILE*, i8*, ...)* @fiprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8]* @percent_d, i32 0, i32 0), i32 187)
@@ -62,7 +62,7 @@ define void @test_simplify4(%FILE* %fp) {
}
define void @test_no_simplify1(%FILE* %fp) {
-; CHECK-IPRINTF: @test_no_simplify1
+; CHECK-IPRINTF-LABEL: @test_no_simplify1(
%fmt = getelementptr [3 x i8]* @percent_f, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt, double 1.87)
; CHECK-NEXT-IPRINTF: call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
@@ -71,7 +71,7 @@ define void @test_no_simplify1(%FILE* %fp) {
}
define void @test_no_simplify2(%FILE* %fp, double %d) {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%fmt = getelementptr [3 x i8]* @percent_f, i32 0, i32 0
call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt, double %d)
; CHECK-NEXT: call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* getelementptr inbounds ([3 x i8]* @percent_f, i32 0, i32 0), double %d)
@@ -80,7 +80,7 @@ define void @test_no_simplify2(%FILE* %fp, double %d) {
}
define i32 @test_no_simplify3(%FILE* %fp) {
-; CHECK: @test_no_simplify3
+; CHECK-LABEL: @test_no_simplify3(
%fmt = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
%1 = call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* %fmt)
; CHECK-NEXT: call i32 (%FILE*, i8*, ...)* @fprintf(%FILE* %fp, i8* getelementptr inbounds ([13 x i8]* @hello_world, i32 0, i32 0))
diff --git a/test/Transforms/InstCombine/fputs-1.ll b/test/Transforms/InstCombine/fputs-1.ll
index c7c5becfd038..473610e6120a 100644
--- a/test/Transforms/InstCombine/fputs-1.ll
+++ b/test/Transforms/InstCombine/fputs-1.ll
@@ -15,7 +15,7 @@ declare i32 @fputs(i8*, %FILE*)
; Check fputs(str, fp) --> fwrite(str, 1, strlen(s), fp).
define void @test_simplify1(%FILE* %fp) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%str = getelementptr [1 x i8]* @empty, i32 0, i32 0
call i32 @fputs(i8* %str, %FILE* %fp)
ret void
@@ -25,7 +25,7 @@ define void @test_simplify1(%FILE* %fp) {
; NOTE: The fwrite simplifier simplifies this further to fputc.
define void @test_simplify2(%FILE* %fp) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%str = getelementptr [2 x i8]* @A, i32 0, i32 0
call i32 @fputs(i8* %str, %FILE* %fp)
; CHECK-NEXT: call i32 @fputc(i32 65, %FILE* %fp)
@@ -34,7 +34,7 @@ define void @test_simplify2(%FILE* %fp) {
}
define void @test_simplify3(%FILE* %fp) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr [7 x i8]* @hello, i32 0, i32 0
call i32 @fputs(i8* %str, %FILE* %fp)
; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([7 x i8]* @hello, i32 0, i32 0), i32 6, i32 1, %FILE* %fp)
diff --git a/test/Transforms/InstCombine/fwrite-1.ll b/test/Transforms/InstCombine/fwrite-1.ll
index 528cdec217f7..6f9a8e463a8c 100644
--- a/test/Transforms/InstCombine/fwrite-1.ll
+++ b/test/Transforms/InstCombine/fwrite-1.ll
@@ -14,7 +14,7 @@ declare i64 @fwrite(i8*, i64, i64, %FILE *)
; Check fwrite(S, 1, 1, fp) -> fputc(S[0], fp).
define void @test_simplify1(%FILE* %fp) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%str = getelementptr inbounds [1 x i8]* @str, i64 0, i64 0
call i64 @fwrite(i8* %str, i64 1, i64 1, %FILE* %fp)
; CHECK-NEXT: call i32 @fputc(i32 0, %FILE* %fp)
@@ -23,7 +23,7 @@ define void @test_simplify1(%FILE* %fp) {
}
define void @test_simplify2(%FILE* %fp) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%str = getelementptr inbounds [0 x i8]* @empty, i64 0, i64 0
call i64 @fwrite(i8* %str, i64 1, i64 0, %FILE* %fp)
ret void
@@ -31,7 +31,7 @@ define void @test_simplify2(%FILE* %fp) {
}
define void @test_simplify3(%FILE* %fp) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr inbounds [0 x i8]* @empty, i64 0, i64 0
call i64 @fwrite(i8* %str, i64 0, i64 1, %FILE* %fp)
ret void
@@ -39,7 +39,7 @@ define void @test_simplify3(%FILE* %fp) {
}
define i64 @test_no_simplify1(%FILE* %fp) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%str = getelementptr inbounds [1 x i8]* @str, i64 0, i64 0
%ret = call i64 @fwrite(i8* %str, i64 1, i64 1, %FILE* %fp)
; CHECK-NEXT: call i64 @fwrite
@@ -48,7 +48,7 @@ define i64 @test_no_simplify1(%FILE* %fp) {
}
define void @test_no_simplify2(%FILE* %fp, i64 %size) {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%str = getelementptr inbounds [1 x i8]* @str, i64 0, i64 0
call i64 @fwrite(i8* %str, i64 %size, i64 1, %FILE* %fp)
; CHECK-NEXT: call i64 @fwrite
diff --git a/test/Transforms/InstCombine/gep-addrspace.ll b/test/Transforms/InstCombine/gep-addrspace.ll
index dfe12dbfaf7f..24c355d817e5 100644
--- a/test/Transforms/InstCombine/gep-addrspace.ll
+++ b/test/Transforms/InstCombine/gep-addrspace.ll
@@ -9,7 +9,7 @@ target triple = "x86_64-pc-win32"
define void @func(%myStruct addrspace(1)* nocapture %p) nounwind {
ST:
%A = getelementptr inbounds %myStruct addrspace(1)* %p, i64 0
- %B = bitcast %myStruct addrspace(1)* %A to %myStruct*
+ %B = addrspacecast %myStruct addrspace(1)* %A to %myStruct*
%C = getelementptr inbounds %myStruct* %B, i32 0, i32 1
%D = getelementptr inbounds [3 x float]* %C, i32 0, i32 2
%E = load float* %D, align 4
diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll
index bb07736ef803..c29a7dccb8ee 100644
--- a/test/Transforms/InstCombine/getelementptr.ll
+++ b/test/Transforms/InstCombine/getelementptr.ll
@@ -1,6 +1,7 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-target datalayout = "e-p:64:64"
+target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32"
+
%intstruct = type { i32 }
%pair = type { i32, i32 }
%struct.B = type { double }
@@ -8,20 +9,28 @@ target datalayout = "e-p:64:64"
@Global = constant [10 x i8] c"helloworld"
+@Global_as1 = addrspace(1) constant [10 x i8] c"helloworld"
; Test noop elimination
define i32* @test1(i32* %I) {
- %A = getelementptr i32* %I, i64 0
+ %A = getelementptr i32* %I, i64 0
ret i32* %A
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32* %I
}
+define i32 addrspace(1)* @test1_as1(i32 addrspace(1)* %I) {
+ %A = getelementptr i32 addrspace(1)* %I, i64 0
+ ret i32 addrspace(1)* %A
+; CHECK-LABEL: @test1_as1(
+; CHECK: ret i32 addrspace(1)* %I
+}
+
; Test noop elimination
define i32* @test2(i32* %I) {
%A = getelementptr i32* %I
ret i32* %A
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret i32* %I
}
@@ -30,52 +39,88 @@ define i32* @test3(i32* %I) {
%A = getelementptr i32* %I, i64 17
%B = getelementptr i32* %A, i64 4
ret i32* %B
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: getelementptr i32* %I, i64 21
}
; Test that two getelementptr insts fold
define i32* @test4({ i32 }* %I) {
- %A = getelementptr { i32 }* %I, i64 1
+ %A = getelementptr { i32 }* %I, i64 1
%B = getelementptr { i32 }* %A, i64 0, i32 0
ret i32* %B
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: getelementptr { i32 }* %I, i64 1, i32 0
}
define void @test5(i8 %B) {
; This should be turned into a constexpr instead of being an instruction
- %A = getelementptr [10 x i8]* @Global, i64 0, i64 4
+ %A = getelementptr [10 x i8]* @Global, i64 0, i64 4
store i8 %B, i8* %A
ret void
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: store i8 %B, i8* getelementptr inbounds ([10 x i8]* @Global, i64 0, i64 4)
}
+define void @test5_as1(i8 %B) {
+ ; This should be turned into a constexpr instead of being an instruction
+ %A = getelementptr [10 x i8] addrspace(1)* @Global_as1, i16 0, i16 4
+ store i8 %B, i8 addrspace(1)* %A
+ ret void
+; CHECK-LABEL: @test5_as1(
+; CHECK: store i8 %B, i8 addrspace(1)* getelementptr inbounds ([10 x i8] addrspace(1)* @Global_as1, i16 0, i16 4)
+}
+
+%as1_ptr_struct = type { i32 addrspace(1)* }
+%as2_ptr_struct = type { i32 addrspace(2)* }
+
+@global_as2 = addrspace(2) global i32 zeroinitializer
+@global_as1_as2_ptr = addrspace(1) global %as2_ptr_struct { i32 addrspace(2)* @global_as2 }
+
+; This should be turned into a constexpr instead of being an instruction
+define void @test_evaluate_gep_nested_as_ptrs(i32 addrspace(2)* %B) {
+; CHECK-LABEL: @test_evaluate_gep_nested_as_ptrs(
+; CHECK-NEXT: store i32 addrspace(2)* %B, i32 addrspace(2)* addrspace(1)* getelementptr inbounds (%as2_ptr_struct addrspace(1)* @global_as1_as2_ptr, i16 0, i32 0), align 8
+; CHECK-NEXT: ret void
+ %A = getelementptr %as2_ptr_struct addrspace(1)* @global_as1_as2_ptr, i16 0, i32 0
+ store i32 addrspace(2)* %B, i32 addrspace(2)* addrspace(1)* %A
+ ret void
+}
+
+@arst = addrspace(1) global [4 x i8 addrspace(2)*] zeroinitializer
+
+define void @test_evaluate_gep_as_ptrs_array(i8 addrspace(2)* %B) {
+; CHECK-LABEL: @test_evaluate_gep_as_ptrs_array(
+; CHECK-NEXT: store i8 addrspace(2)* %B, i8 addrspace(2)* addrspace(1)* getelementptr inbounds ([4 x i8 addrspace(2)*] addrspace(1)* @arst, i16 0, i16 2), align 4
+
+; CHECK-NEXT: ret void
+ %A = getelementptr [4 x i8 addrspace(2)*] addrspace(1)* @arst, i16 0, i16 2
+ store i8 addrspace(2)* %B, i8 addrspace(2)* addrspace(1)* %A
+ ret void
+}
define i32* @test7(i32* %I, i64 %C, i64 %D) {
- %A = getelementptr i32* %I, i64 %C
- %B = getelementptr i32* %A, i64 %D
+ %A = getelementptr i32* %I, i64 %C
+ %B = getelementptr i32* %A, i64 %D
ret i32* %B
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %A.sum = add i64 %C, %D
; CHECK: getelementptr i32* %I, i64 %A.sum
}
define i8* @test8([10 x i32]* %X) {
;; Fold into the cast.
- %A = getelementptr [10 x i32]* %X, i64 0, i64 0
- %B = bitcast i32* %A to i8*
+ %A = getelementptr [10 x i32]* %X, i64 0, i64 0
+ %B = bitcast i32* %A to i8*
ret i8* %B
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: bitcast [10 x i32]* %X to i8*
}
define i32 @test9() {
%A = getelementptr { i32, double }* null, i32 0, i32 1
- %B = ptrtoint double* %A to i32
+ %B = ptrtoint double* %A to i32
ret i32 %B
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: ret i32 8
}
@@ -83,17 +128,17 @@ define i1 @test10({ i32, i32 }* %x, { i32, i32 }* %y) {
%tmp.1 = getelementptr { i32, i32 }* %x, i32 0, i32 1
%tmp.3 = getelementptr { i32, i32 }* %y, i32 0, i32 1
;; seteq x, y
- %tmp.4 = icmp eq i32* %tmp.1, %tmp.3
+ %tmp.4 = icmp eq i32* %tmp.1, %tmp.3
ret i1 %tmp.4
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: icmp eq { i32, i32 }* %x, %y
}
define i1 @test11({ i32, i32 }* %X) {
- %P = getelementptr { i32, i32 }* %X, i32 0, i32 0
- %Q = icmp eq i32* %P, null
+ %P = getelementptr { i32, i32 }* %X, i32 0, i32 0
+ %Q = icmp eq i32* %P, null
ret i1 %Q
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: icmp eq { i32, i32 }* %X, null
}
@@ -105,13 +150,13 @@ entry:
store i32 10, i32* %g3, align 4
%g4 = getelementptr %struct.A* %a, i32 0, i32 0
-
+
%new_a = bitcast %struct.B* %g4 to %struct.A*
- %g5 = getelementptr %struct.A* %new_a, i32 0, i32 1
- %a_a = load i32* %g5, align 4
+ %g5 = getelementptr %struct.A* %new_a, i32 0, i32 1
+ %a_a = load i32* %g5, align 4
ret i32 %a_a
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK: getelementptr %struct.A* %a, i64 0, i32 1
; CHECK-NEXT: store i32 10, i32* %g3
; CHECK-NEXT: ret i32 10
@@ -125,17 +170,77 @@ define i1 @test13(i64 %X, %S* %P) {
%B = getelementptr inbounds %S* %P, i32 0, i32 0
%C = icmp eq i32* %A, %B
ret i1 %C
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: %C = icmp eq i64 %X, -1
}
+define <2 x i1> @test13_vector(<2 x i64> %X, <2 x %S*> %P) nounwind {
+; CHECK-LABEL: @test13_vector(
+; CHECK-NEXT: shl nuw <2 x i64> %X, <i64 2, i64 2>
+; CHECK-NEXT: add <2 x i64> %A.idx, <i64 4, i64 4>
+; CHECK-NEXT: icmp eq <2 x i64> %A.offs, zeroinitializer
+ %A = getelementptr inbounds <2 x %S*> %P, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 1>, <2 x i64> %X
+ %B = getelementptr inbounds <2 x %S*> %P, <2 x i64> <i64 0, i64 0>, <2 x i32> <i32 0, i32 0>
+ %C = icmp eq <2 x i32*> %A, %B
+ ret <2 x i1> %C
+}
+
+define i1 @test13_as1(i16 %X, %S addrspace(1)* %P) {
+; CHECK-LABEL: @test13_as1(
+; CHECK-NEXT: %C = icmp eq i16 %X, -1
+; CHECK-NEXT: ret i1 %C
+ %A = getelementptr inbounds %S addrspace(1)* %P, i16 0, i32 1, i16 %X
+ %B = getelementptr inbounds %S addrspace(1)* %P, i16 0, i32 0
+ %C = icmp eq i32 addrspace(1)* %A, %B
+ ret i1 %C
+}
+
+define <2 x i1> @test13_vector_as1(<2 x i16> %X, <2 x %S addrspace(1)*> %P) {
+; CHECK-LABEL: @test13_vector_as1(
+; CHECK-NEXT: shl nuw <2 x i16> %X, <i16 2, i16 2>
+; CHECK-NEXT: add <2 x i16> %A.idx, <i16 4, i16 4>
+; CHECK-NEXT: icmp eq <2 x i16> %A.offs, zeroinitializer
+; CHECK-NEXT: ret <2 x i1>
+ %A = getelementptr inbounds <2 x %S addrspace(1)*> %P, <2 x i16> <i16 0, i16 0>, <2 x i32> <i32 1, i32 1>, <2 x i16> %X
+ %B = getelementptr inbounds <2 x %S addrspace(1)*> %P, <2 x i16> <i16 0, i16 0>, <2 x i32> <i32 0, i32 0>
+ %C = icmp eq <2 x i32 addrspace(1)*> %A, %B
+ ret <2 x i1> %C
+}
+
+define i1 @test13_i32(i32 %X, %S* %P) {
+; CHECK-LABEL: @test13_i32(
+; CHECK: %C = icmp eq i32 %X, -1
+ %A = getelementptr inbounds %S* %P, i32 0, i32 1, i32 %X
+ %B = getelementptr inbounds %S* %P, i32 0, i32 0
+ %C = icmp eq i32* %A, %B
+ ret i1 %C
+}
+
+define i1 @test13_i16(i16 %X, %S* %P) {
+; CHECK-LABEL: @test13_i16(
+; CHECK: %C = icmp eq i16 %X, -1
+ %A = getelementptr inbounds %S* %P, i16 0, i32 1, i16 %X
+ %B = getelementptr inbounds %S* %P, i16 0, i32 0
+ %C = icmp eq i32* %A, %B
+ ret i1 %C
+}
+
+define i1 @test13_i128(i128 %X, %S* %P) {
+; CHECK-LABEL: @test13_i128(
+; CHECK: %C = icmp eq i64 %1, -1
+ %A = getelementptr inbounds %S* %P, i128 0, i32 1, i128 %X
+ %B = getelementptr inbounds %S* %P, i128 0, i32 0
+ %C = icmp eq i32* %A, %B
+ ret i1 %C
+}
+
-@G = external global [3 x i8]
+@G = external global [3 x i8]
define i8* @test14(i32 %Idx) {
%idx = zext i32 %Idx to i64
%tmp = getelementptr i8* getelementptr ([3 x i8]* @G, i32 0, i32 0), i64 %idx
ret i8* %tmp
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK: getelementptr [3 x i8]* @G, i64 0, i64 %idx
}
@@ -145,15 +250,15 @@ define i8* @test14(i32 %Idx) {
define i32 *@test15(i64 %X) {
%A = getelementptr i32* getelementptr ([40 x i32]* @Array, i64 0, i64 0), i64 %X
ret i32* %A
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK: getelementptr [40 x i32]* @Array, i64 0, i64 %X
}
define i32* @test16(i32* %X, i32 %Idx) {
- %R = getelementptr i32* %X, i32 %Idx
+ %R = getelementptr i32* %X, i32 %Idx
ret i32* %R
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK: sext i32 %Idx to i64
}
@@ -163,25 +268,74 @@ define i1 @test17(i16* %P, i32 %I, i32 %J) {
%Y = getelementptr inbounds i16* %P, i32 %J
%C = icmp ult i16* %X, %Y
ret i1 %C
-; CHECK: @test17
-; CHECK: %C = icmp slt i32 %I, %J
+; CHECK-LABEL: @test17(
+; CHECK: %C = icmp slt i32 %I, %J
}
define i1 @test18(i16* %P, i32 %I) {
%X = getelementptr inbounds i16* %P, i32 %I
%C = icmp ult i16* %X, %P
ret i1 %C
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: %C = icmp slt i32 %I, 0
}
+; Larger than the pointer size for a non-zero address space
+define i1 @test18_as1(i16 addrspace(1)* %P, i32 %I) {
+; CHECK-LABEL: @test18_as1(
+; CHECK-NEXT: %1 = trunc i32 %I to i16
+; CHECK-NEXT: %C = icmp slt i16 %1, 0
+; CHECK-NEXT: ret i1 %C
+ %X = getelementptr inbounds i16 addrspace(1)* %P, i32 %I
+ %C = icmp ult i16 addrspace(1)* %X, %P
+ ret i1 %C
+}
+
+; Smaller than the pointer size for a non-zero address space
+define i1 @test18_as1_i32(i16 addrspace(1)* %P, i32 %I) {
+; CHECK-LABEL: @test18_as1_i32(
+; CHECK-NEXT: %1 = trunc i32 %I to i16
+; CHECK-NEXT: %C = icmp slt i16 %1, 0
+; CHECK-NEXT: ret i1 %C
+ %X = getelementptr inbounds i16 addrspace(1)* %P, i32 %I
+ %C = icmp ult i16 addrspace(1)* %X, %P
+ ret i1 %C
+}
+
+; Smaller than pointer size
+define i1 @test18_i16(i16* %P, i16 %I) {
+; CHECK-LABEL: @test18_i16(
+; CHECK: %C = icmp slt i16 %I, 0
+ %X = getelementptr inbounds i16* %P, i16 %I
+ %C = icmp ult i16* %X, %P
+ ret i1 %C
+}
+
+; Same as pointer size
+define i1 @test18_i64(i16* %P, i64 %I) {
+; CHECK-LABEL: @test18_i64(
+; CHECK: %C = icmp slt i64 %I, 0
+ %X = getelementptr inbounds i16* %P, i64 %I
+ %C = icmp ult i16* %X, %P
+ ret i1 %C
+}
+
+; Larger than the pointer size
+define i1 @test18_i128(i16* %P, i128 %I) {
+; CHECK-LABEL: @test18_i128(
+; CHECK: %C = icmp slt i64 %1, 0
+ %X = getelementptr inbounds i16* %P, i128 %I
+ %C = icmp ult i16* %X, %P
+ ret i1 %C
+}
+
define i32 @test19(i32* %P, i32 %A, i32 %B) {
%tmp.4 = getelementptr inbounds i32* %P, i32 %A
%tmp.9 = getelementptr inbounds i32* %P, i32 %B
%tmp.10 = icmp eq i32* %tmp.4, %tmp.9
%tmp.11 = zext i1 %tmp.10 to i32
ret i32 %tmp.11
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK: icmp eq i32 %A, %B
}
@@ -190,10 +344,19 @@ define i32 @test20(i32* %P, i32 %A, i32 %B) {
%tmp.6 = icmp eq i32* %tmp.4, %P
%tmp.7 = zext i1 %tmp.6 to i32
ret i32 %tmp.7
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK: icmp eq i32 %A, 0
}
+define i32 @test20_as1(i32 addrspace(1)* %P, i32 %A, i32 %B) {
+ %tmp.4 = getelementptr inbounds i32 addrspace(1)* %P, i32 %A
+ %tmp.6 = icmp eq i32 addrspace(1)* %tmp.4, %P
+ %tmp.7 = zext i1 %tmp.6 to i32
+ ret i32 %tmp.7
+; CHECK-LABEL: @test20_as1(
+; CHECK: icmp eq i16 %1, 0
+}
+
define i32 @test21() {
%pbob1 = alloca %intstruct
@@ -201,7 +364,7 @@ define i32 @test21() {
%pbobel = getelementptr %intstruct* %pbob2, i64 0, i32 0
%rval = load i32* %pbobel
ret i32 %rval
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK: getelementptr %intstruct* %pbob1, i64 0, i32 0
}
@@ -210,10 +373,10 @@ define i32 @test21() {
@B = global i32 2 ; <i32*> [#uses=1]
define i1 @test22() {
- %C = icmp ult i32* getelementptr (i32* @A, i64 1),
- getelementptr (i32* @B, i64 2)
+ %C = icmp ult i32* getelementptr (i32* @A, i64 1),
+ getelementptr (i32* @B, i64 2)
ret i1 %C
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK: icmp ult (i32* getelementptr inbounds (i32* @A, i64 1), i32* getelementptr (i32* @B, i64 2))
}
@@ -224,7 +387,7 @@ define i1 @test23() {
%A = getelementptr %X* null, i64 0, i32 0, i64 0 ; <i32*> [#uses=1]
%B = icmp ne i32* %A, null ; <i1> [#uses=1]
ret i1 %B
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK: ret i1 false
}
@@ -239,7 +402,7 @@ entry:
%tmp27.i = sext i32 %sext to i64 ; <i64> [#uses=1]
tail call void @foo25( i32 0, i64 %tmp27.i )
unreachable
-; CHECK: @test25
+; CHECK-LABEL: @test25(
}
declare void @foo25(i32, i64)
@@ -251,7 +414,7 @@ define i1 @test26(i8* %arr) {
%Y = getelementptr i8* %arr, i32 1
%test = icmp uge i8* %X, %Y
ret i1 %test
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK: ret i1 true
}
@@ -262,48 +425,48 @@ define i1 @test26(i8* %arr) {
define i32 @test27(%struct.compat_siginfo* %to, %struct.siginfo_t* %from) {
entry:
- %from_addr = alloca %struct.siginfo_t*
- %tmp344 = load %struct.siginfo_t** %from_addr, align 8
+ %from_addr = alloca %struct.siginfo_t*
+ %tmp344 = load %struct.siginfo_t** %from_addr, align 8
%tmp345 = getelementptr %struct.siginfo_t* %tmp344, i32 0, i32 3
%tmp346 = getelementptr { { i32, i32, [0 x i8], %struct.sigval_t, i32 }, [88 x i8] }* %tmp345, i32 0, i32 0
- %tmp346347 = bitcast { i32, i32, [0 x i8], %struct.sigval_t, i32 }* %tmp346 to { i32, i32, %struct.sigval_t }*
+ %tmp346347 = bitcast { i32, i32, [0 x i8], %struct.sigval_t, i32 }* %tmp346 to { i32, i32, %struct.sigval_t }*
%tmp348 = getelementptr { i32, i32, %struct.sigval_t }* %tmp346347, i32 0, i32 2
%tmp349 = getelementptr %struct.sigval_t* %tmp348, i32 0, i32 0
%tmp349350 = bitcast i8** %tmp349 to i32*
- %tmp351 = load i32* %tmp349350, align 8
+ %tmp351 = load i32* %tmp349350, align 8
%tmp360 = call i32 asm sideeffect "...",
"=r,ir,*m,i,0,~{dirflag},~{fpsr},~{flags}"( i32 %tmp351,
%struct.__large_struct* null, i32 -14, i32 0 )
unreachable
-; CHECK: @test27
+; CHECK-LABEL: @test27(
}
; PR1978
%struct.x = type <{ i8 }>
-@.str = internal constant [6 x i8] c"Main!\00"
-@.str1 = internal constant [12 x i8] c"destroy %p\0A\00"
+@.str = internal constant [6 x i8] c"Main!\00"
+@.str1 = internal constant [12 x i8] c"destroy %p\0A\00"
define i32 @test28() nounwind {
entry:
%orientations = alloca [1 x [1 x %struct.x]]
- %tmp3 = call i32 @puts( i8* getelementptr ([6 x i8]* @.str, i32 0, i32 0) ) nounwind
+ %tmp3 = call i32 @puts( i8* getelementptr ([6 x i8]* @.str, i32 0, i32 0) ) nounwind
%tmp45 = getelementptr inbounds [1 x [1 x %struct.x]]* %orientations, i32 1, i32 0, i32 0
%orientations62 = getelementptr [1 x [1 x %struct.x]]* %orientations, i32 0, i32 0, i32 0
br label %bb10
bb10:
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb10 ]
- %tmp.0.reg2mem.0.rec = mul i32 %indvar, -1
- %tmp12.rec = add i32 %tmp.0.reg2mem.0.rec, -1
+ %tmp.0.reg2mem.0.rec = mul i32 %indvar, -1
+ %tmp12.rec = add i32 %tmp.0.reg2mem.0.rec, -1
%tmp12 = getelementptr inbounds %struct.x* %tmp45, i32 %tmp12.rec
%tmp16 = call i32 (i8*, ...)* @printf( i8* getelementptr ([12 x i8]* @.str1, i32 0, i32 0), %struct.x* %tmp12 ) nounwind
%tmp84 = icmp eq %struct.x* %tmp12, %orientations62
%indvar.next = add i32 %indvar, 1
br i1 %tmp84, label %bb17, label %bb10
-bb17:
+bb17:
ret i32 0
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; CHECK: icmp eq i32 %indvar, 0
}
@@ -318,7 +481,7 @@ declare i32 @printf(i8*, ...)
%T = type <{ i64, i64, i64 }>
define i32 @test29(i8* %start, i32 %X) nounwind {
entry:
- %tmp3 = load i64* null
+ %tmp3 = load i64* null
%add.ptr = getelementptr i8* %start, i64 %tmp3
%tmp158 = load i32* null
%add.ptr159 = getelementptr %T* null, i32 %tmp158
@@ -332,7 +495,7 @@ if.then216:
if.end363:
ret i32 0
-; CHECK: @test29
+; CHECK-LABEL: @test29(
}
@@ -345,7 +508,7 @@ entry:
%2 = getelementptr [0 x i32]* %1, i32 0, i32 %m
%3 = load i32* %2, align 4
ret i32 %3
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; CHECK: getelementptr i32
}
@@ -356,9 +519,9 @@ declare void @test30f(i32*)
define i1 @test31(i32* %A) {
%B = getelementptr i32* %A, i32 1
%C = getelementptr i32* %A, i64 1
- %V = icmp eq i32* %B, %C
+ %V = icmp eq i32* %B, %C
ret i1 %V
-; CHECK: @test31
+; CHECK-LABEL: @test31(
; CHECK: ret i1 true
}
@@ -372,10 +535,10 @@ define i8* @test32(i8* %v) {
%D = getelementptr { [16 x i8] }* %C, i32 0, i32 0, i32 8
%E = bitcast i8* %D to i8**
store i8* %v, i8** %E
- %F = getelementptr [4 x i8*]* %A, i32 0, i32 2
+ %F = getelementptr [4 x i8*]* %A, i32 0, i32 2
%G = load i8** %F
ret i8* %G
-; CHECK: @test32
+; CHECK-LABEL: @test32(
; CHECK: %D = getelementptr [4 x i8*]* %A, i64 0, i64 1
; CHECK: %F = getelementptr [4 x i8*]* %A, i64 0, i64 2
}
@@ -384,27 +547,50 @@ define i8* @test32(i8* %v) {
%struct.Key = type { { i32, i32 } }
%struct.anon = type <{ i8, [3 x i8], i32 }>
-define i32 *@test33(%struct.Key *%A) {
- %B = bitcast %struct.Key* %A to %struct.anon*
- %C = getelementptr %struct.anon* %B, i32 0, i32 2
- ret i32 *%C
-; CHECK: @test33
+define i32* @test33(%struct.Key* %A) {
+; CHECK-LABEL: @test33(
; CHECK: getelementptr %struct.Key* %A, i64 0, i32 0, i32 1
+ %B = bitcast %struct.Key* %A to %struct.anon*
+ %C = getelementptr %struct.anon* %B, i32 0, i32 2
+ ret i32* %C
}
+define i32 addrspace(1)* @test33_as1(%struct.Key addrspace(1)* %A) {
+; CHECK-LABEL: @test33_as1(
+; CHECK: getelementptr %struct.Key addrspace(1)* %A, i16 0, i32 0, i32 1
+ %B = bitcast %struct.Key addrspace(1)* %A to %struct.anon addrspace(1)*
+ %C = getelementptr %struct.anon addrspace(1)* %B, i32 0, i32 2
+ ret i32 addrspace(1)* %C
+}
+
+define i32 addrspace(1)* @test33_array_as1([10 x i32] addrspace(1)* %A) {
+; CHECK-LABEL: @test33_array_as1(
+; CHECK: getelementptr [10 x i32] addrspace(1)* %A, i16 0, i16 2
+ %B = bitcast [10 x i32] addrspace(1)* %A to [5 x i32] addrspace(1)*
+ %C = getelementptr [5 x i32] addrspace(1)* %B, i32 0, i32 2
+ ret i32 addrspace(1)* %C
+}
+; Make sure the GEP indices use the right pointer sized integer
+define i32 addrspace(1)* @test33_array_struct_as1([10 x %struct.Key] addrspace(1)* %A) {
+; CHECK-LABEL: @test33_array_struct_as1(
+; CHECK: getelementptr [10 x %struct.Key] addrspace(1)* %A, i16 0, i16 1, i32 0, i32 0
+ %B = bitcast [10 x %struct.Key] addrspace(1)* %A to [20 x i32] addrspace(1)*
+ %C = getelementptr [20 x i32] addrspace(1)* %B, i32 0, i32 2
+ ret i32 addrspace(1)* %C
+}
%T2 = type { i8*, i8 }
define i8* @test34(i8* %Val, i64 %V) nounwind {
entry:
- %A = alloca %T2, align 8
+ %A = alloca %T2, align 8
%mrv_gep = bitcast %T2* %A to i64*
%B = getelementptr %T2* %A, i64 0, i32 0
-
+
store i64 %V, i64* %mrv_gep
%C = load i8** %B, align 8
ret i8* %C
-; CHECK: @test34
+; CHECK-LABEL: @test34(
; CHECK: %V.c = inttoptr i64 %V to i8*
; CHECK: ret i8* %V.c
}
@@ -423,7 +609,7 @@ define i32 @test35() nounwind {
call i32 (i8*, ...)* @printf(i8* getelementptr ([17 x i8]* @"\01LC8", i32 0, i32 0),
i8* getelementptr (%t1* bitcast (%t0* @s to %t1*), i32 0, i32 1, i32 0)) nounwind
ret i32 0
-; CHECK: @test35
+; CHECK-LABEL: @test35(
; CHECK: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([17 x i8]* @"\01LC8", i64 0, i64 0), i8* getelementptr inbounds (%t0* @s, i64 0, i32 1, i64 0)) [[NUW:#[0-9]+]]
}
@@ -434,14 +620,14 @@ define i32 @test35() nounwind {
define i8* @test36() nounwind {
ret i8* getelementptr ([11 x i8]* @array, i32 0, i64 -1)
-; CHECK: @test36
+; CHECK-LABEL: @test36(
; CHECK: ret i8* getelementptr ([11 x i8]* @array, i64 1676976733973595601, i64 4)
}
; Instcombine shouldn't assume that gep(A,0,1) != gep(A,1,0).
@A37 = external constant [1 x i8]
define i1 @test37() nounwind {
-; CHECK: @test37
+; CHECK-LABEL: @test37(
; CHECK: ret i1 true
%t = icmp eq i8* getelementptr ([1 x i8]* @A37, i64 0, i64 1),
getelementptr ([1 x i8]* @A37, i64 1, i64 0)
@@ -452,7 +638,7 @@ define i1 @test37() nounwind {
define i32* @test38(i32* %I, i32 %n) {
%A = getelementptr i32* %I, i32 %n
ret i32* %A
-; CHECK: @test38
+; CHECK-LABEL: @test38(
; CHECK: = sext i32 %n to i64
; CHECK: %A = getelementptr i32* %I, i64 %
}
@@ -469,7 +655,7 @@ entry:
call void @pr10322_f3(i8** %tmp2) nounwind
ret void
-; CHECK: @pr10322_f1
+; CHECK-LABEL: @pr10322_f1(
; CHECK: %tmp2 = getelementptr inbounds %pr10322_t* %arrayidx8, i64 0, i32 0
}
@@ -485,7 +671,7 @@ define void @three_gep_f(%three_gep_t2* %x) {
%gep3 = getelementptr %three_gep_t* %gep2, i64 0, i32 0
call void @three_gep_g(i32* %gep3)
-; CHECK: @three_gep_f
+; CHECK-LABEL: @three_gep_f(
; CHECK: %gep3 = getelementptr %three_gep_t2* %gep1, i64 0, i32 0, i32 0
ret void
}
@@ -504,9 +690,103 @@ define void @test39(%struct.ham* %arg, i8 %arg1) nounwind {
store i8 %arg1, i8* %tmp4, align 8
ret void
-; CHECK: @test39
+; CHECK-LABEL: @test39(
; CHECK: getelementptr inbounds %struct.ham* %arg, i64 0, i32 2
; CHECK: getelementptr inbounds i8* %tmp3, i64 -8
}
+define i1 @pr16483([1 x i8]* %a, [1 x i8]* %b) {
+ %c = getelementptr [1 x i8]* %a, i32 0, i32 0
+ %d = getelementptr [1 x i8]* %b, i32 0, i32 0
+ %cmp = icmp ult i8* %c, %d
+ ret i1 %cmp
+
+; CHECK-LABEL: @pr16483(
+; CHECK-NEXT: icmp ult [1 x i8]* %a, %b
+}
+
+define i8 @test_gep_bitcast_as1(i32 addrspace(1)* %arr, i16 %N) {
+; CHECK-LABEL: @test_gep_bitcast_as1(
+; CHECK: getelementptr i32 addrspace(1)* %arr, i16 %N
+; CHECK: bitcast
+ %cast = bitcast i32 addrspace(1)* %arr to i8 addrspace(1)*
+ %V = mul i16 %N, 4
+ %t = getelementptr i8 addrspace(1)* %cast, i16 %V
+ %x = load i8 addrspace(1)* %t
+ ret i8 %x
+}
+
+; The element size of the array matches the element size of the pointer
+define i64 @test_gep_bitcast_array_same_size_element([100 x double]* %arr, i64 %N) {
+; CHECK-LABEL: @test_gep_bitcast_array_same_size_element(
+; CHECK: getelementptr [100 x double]* %arr, i64 0, i64 %V
+; CHECK: bitcast
+ %cast = bitcast [100 x double]* %arr to i64*
+ %V = mul i64 %N, 8
+ %t = getelementptr i64* %cast, i64 %V
+ %x = load i64* %t
+ ret i64 %x
+}
+
+; The element size of the array is different the element size of the pointer
+define i8 @test_gep_bitcast_array_different_size_element([100 x double]* %arr, i64 %N) {
+; CHECK-LABEL: @test_gep_bitcast_array_different_size_element(
+; CHECK: getelementptr [100 x double]* %arr, i64 0, i64 %N
+; CHECK: bitcast
+ %cast = bitcast [100 x double]* %arr to i8*
+ %V = mul i64 %N, 8
+ %t = getelementptr i8* %cast, i64 %V
+ %x = load i8* %t
+ ret i8 %x
+}
+
+define i64 @test_gep_bitcast_array_same_size_element_as1([100 x double] addrspace(1)* %arr, i16 %N) {
+; CHECK-LABEL: @test_gep_bitcast_array_same_size_element_as1(
+; CHECK: getelementptr [100 x double] addrspace(1)* %arr, i16 0, i16 %V
+; CHECK: bitcast
+ %cast = bitcast [100 x double] addrspace(1)* %arr to i64 addrspace(1)*
+ %V = mul i16 %N, 8
+ %t = getelementptr i64 addrspace(1)* %cast, i16 %V
+ %x = load i64 addrspace(1)* %t
+ ret i64 %x
+}
+
+define i8 @test_gep_bitcast_array_different_size_element_as1([100 x double] addrspace(1)* %arr, i16 %N) {
+; CHECK-LABEL: @test_gep_bitcast_array_different_size_element_as1(
+; CHECK: getelementptr [100 x double] addrspace(1)* %arr, i16 0, i16 %N
+; CHECK: bitcast
+ %cast = bitcast [100 x double] addrspace(1)* %arr to i8 addrspace(1)*
+ %V = mul i16 %N, 8
+ %t = getelementptr i8 addrspace(1)* %cast, i16 %V
+ %x = load i8 addrspace(1)* %t
+ ret i8 %x
+}
+
+define i64 @test40() {
+ %array = alloca [3 x i32], align 4
+ %gep = getelementptr inbounds [3 x i32]* %array, i64 0, i64 2
+ %gepi8 = bitcast i32* %gep to i8*
+ %p = ptrtoint [3 x i32]* %array to i64
+ %np = sub i64 0, %p
+ %gep2 = getelementptr i8* %gepi8, i64 %np
+ %ret = ptrtoint i8* %gep2 to i64
+ ret i64 %ret
+
+; CHECK-LABEL: @test40
+; CHECK-NEXT: ret i64 8
+}
+
+define i16 @test41([3 x i32] addrspace(1)* %array) {
+ %gep = getelementptr inbounds [3 x i32] addrspace(1)* %array, i16 0, i16 2
+ %gepi8 = bitcast i32 addrspace(1)* %gep to i8 addrspace(1)*
+ %p = ptrtoint [3 x i32] addrspace(1)* %array to i16
+ %np = sub i16 0, %p
+ %gep2 = getelementptr i8 addrspace(1)* %gepi8, i16 %np
+ %ret = ptrtoint i8 addrspace(1)* %gep2 to i16
+ ret i16 %ret
+
+; CHECK-LABEL: @test41(
+; CHECK-NEXT: ret i16 8
+}
+
; CHECK: attributes [[NUW]] = { nounwind }
diff --git a/test/Transforms/InstCombine/icmp-logical.ll b/test/Transforms/InstCombine/icmp-logical.ll
new file mode 100644
index 000000000000..d5d8cbc8c26e
--- /dev/null
+++ b/test/Transforms/InstCombine/icmp-logical.ll
@@ -0,0 +1,152 @@
+; RUN: opt -instcombine -S -o - %s | FileCheck %s
+
+define i1 @masked_and_notallzeroes(i32 %A) {
+; CHECK-LABEL: @masked_and_notallzeroes
+; CHECK: [[MASK:%.*]] = and i32 %A, 7
+; CHECK: icmp ne i32 [[MASK]], 0
+; CHECK-NOT: and i32 %A, 39
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp ne i32 %mask1, 0
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp ne i32 %mask2, 0
+
+ %res = and i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_or_allzeroes(i32 %A) {
+; CHECK-LABEL: @masked_or_allzeroes
+; CHECK: [[MASK:%.*]] = and i32 %A, 7
+; CHECK: icmp eq i32 [[MASK]], 0
+; CHECK-NOT: and i32 %A, 39
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp eq i32 %mask1, 0
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp eq i32 %mask2, 0
+
+ %res = or i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_and_notallones(i32 %A) {
+; CHECK-LABEL: @masked_and_notallones
+; CHECK: [[MASK:%.*]] = and i32 %A, 7
+; CHECK: icmp ne i32 [[MASK]], 7
+; CHECK-NOT: and i32 %A, 39
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp ne i32 %mask1, 7
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp ne i32 %mask2, 39
+
+ %res = and i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_or_allones(i32 %A) {
+; CHECK-LABEL: @masked_or_allones
+; CHECK: [[MASK:%.*]] = and i32 %A, 7
+; CHECK: icmp eq i32 [[MASK]], 7
+; CHECK-NOT: and i32 %A, 39
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp eq i32 %mask1, 7
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp eq i32 %mask2, 39
+
+ %res = or i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_and_notA(i32 %A) {
+; CHECK-LABEL: @masked_and_notA
+; CHECK: [[MASK:%.*]] = and i32 %A, 39
+; CHECK: icmp ne i32 [[MASK]], %A
+; CHECK-NOT: and i32 %A, 7
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp ne i32 %mask1, %A
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp ne i32 %mask2, %A
+
+ %res = and i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_or_A(i32 %A) {
+; CHECK-LABEL: @masked_or_A
+; CHECK: [[MASK:%.*]] = and i32 %A, 39
+; CHECK: icmp eq i32 [[MASK]], %A
+; CHECK-NOT: and i32 %A, 7
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 7
+ %tst1 = icmp eq i32 %mask1, %A
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp eq i32 %mask2, %A
+
+ %res = or i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @masked_or_allzeroes_notoptimised(i32 %A) {
+; CHECK-LABEL: @masked_or_allzeroes_notoptimised
+; CHECK: [[MASK:%.*]] = and i32 %A, 15
+; CHECK: icmp eq i32 [[MASK]], 0
+; CHECK: [[MASK:%.*]] = and i32 %A, 39
+; CHECK: icmp eq i32 [[MASK]], 0
+; CHECK: ret i1
+
+ %mask1 = and i32 %A, 15
+ %tst1 = icmp eq i32 %mask1, 0
+
+ %mask2 = and i32 %A, 39
+ %tst2 = icmp eq i32 %mask2, 0
+
+ %res = or i1 %tst1, %tst2
+ ret i1 %res
+}
+
+define i1 @nomask_lhs(i32 %in) {
+; CHECK-LABEL: @nomask_lhs
+; CHECK: [[MASK:%.*]] = and i32 %in, 1
+; CHECK: icmp eq i32 [[MASK]], 0
+; CHECK-NOT: icmp
+; CHECK: ret i1
+ %tst1 = icmp eq i32 %in, 0
+
+ %masked = and i32 %in, 1
+ %tst2 = icmp eq i32 %masked, 0
+
+ %val = or i1 %tst1, %tst2
+ ret i1 %val
+}
+
+
+define i1 @nomask_rhs(i32 %in) {
+; CHECK-LABEL: @nomask_rhs
+; CHECK: [[MASK:%.*]] = and i32 %in, 1
+; CHECK: icmp eq i32 [[MASK]], 0
+; CHECK-NOT: icmp
+; CHECK: ret i1
+ %masked = and i32 %in, 1
+ %tst1 = icmp eq i32 %masked, 0
+
+ %tst2 = icmp eq i32 %in, 0
+
+ %val = or i1 %tst1, %tst2
+ ret i1 %val
+}
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll
index c912a576c3d2..12a4744cc0fe 100644
--- a/test/Transforms/InstCombine/icmp.ll
+++ b/test/Transforms/InstCombine/icmp.ll
@@ -1,14 +1,14 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
target datalayout =
-"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+"e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
define i32 @test1(i32 %X) {
entry:
icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
zext i1 %0 to i32 ; <i32>:1 [#uses=1]
ret i32 %1
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: lshr i32 %X, 31
; CHECK-NEXT: ret i32
}
@@ -18,7 +18,7 @@ entry:
icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
zext i1 %0 to i32 ; <i32>:1 [#uses=1]
ret i32 %1
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: lshr i32 %X, 31
; CHECK-NEXT: xor i32
; CHECK-NEXT: ret i32
@@ -29,7 +29,7 @@ entry:
icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
sext i1 %0 to i32 ; <i32>:1 [#uses=1]
ret i32 %1
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ashr i32 %X, 31
; CHECK-NEXT: ret i32
}
@@ -39,7 +39,7 @@ entry:
icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
sext i1 %0 to i32 ; <i32>:1 [#uses=1]
ret i32 %1
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ashr i32 %X, 31
; CHECK-NEXT: xor i32
; CHECK-NEXT: ret i32
@@ -50,7 +50,7 @@ define <2 x i1> @test5(<2 x i64> %x) {
entry:
%V = icmp eq <2 x i64> %x, undef
ret <2 x i1> %V
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: ret <2 x i1> <i1 true, i1 true>
}
@@ -60,7 +60,7 @@ define i32 @test6(i32 %a, i32 %b) {
%e = sub i32 0, %d
%f = and i32 %e, %b
ret i32 %f
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: ashr i32 %a, 31
; CHECK-NEXT: %f = and i32 %e, %b
; CHECK-NEXT: ret i32 %f
@@ -72,37 +72,36 @@ entry:
%a = add i32 %x, -1
%b = icmp ult i32 %a, %x
ret i1 %b
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %b = icmp ne i32 %x, 0
; CHECK: ret i1 %b
}
define i1 @test8(i32 %x){
entry:
- %a = add i32 %x, -1
+ %a = add i32 %x, -1
%b = icmp eq i32 %a, %x
ret i1 %b
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: ret i1 false
}
define i1 @test9(i32 %x) {
entry:
%a = add i32 %x, -2
- %b = icmp ugt i32 %x, %a
+ %b = icmp ugt i32 %x, %a
ret i1 %b
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: icmp ugt i32 %x, 1
; CHECK: ret i1 %b
}
define i1 @test10(i32 %x){
entry:
- %a = add i32 %x, -1
- %b = icmp slt i32 %a, %x
+ %a = add i32 %x, -1
+ %b = icmp slt i32 %a, %x
ret i1 %b
-
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: %b = icmp ne i32 %x, -2147483648
; CHECK: ret i1 %b
}
@@ -111,7 +110,7 @@ define i1 @test11(i32 %x) {
%a = add nsw i32 %x, 8
%b = icmp slt i32 %x, %a
ret i1 %b
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: ret i1 true
}
@@ -120,7 +119,7 @@ define i1 @test12(i1 %A) {
%S = select i1 %A, i64 -4294967295, i64 8589934591
%B = icmp ne i64 bitcast (<2 x i32> <i32 1, i32 -1> to i64), %S
ret i1 %B
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NEXT: = xor i1 %A, true
; CHECK-NEXT: ret i1
}
@@ -130,7 +129,7 @@ define i1 @test13(i8 %X) nounwind readnone {
entry:
%cmp = icmp slt i8 undef, %X
ret i1 %cmp
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: ret i1 false
}
@@ -138,7 +137,7 @@ define i1 @test14(i8 %X) nounwind readnone {
entry:
%cmp = icmp slt i8 undef, -128
ret i1 %cmp
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK: ret i1 false
}
@@ -146,7 +145,7 @@ define i1 @test15() nounwind readnone {
entry:
%cmp = icmp eq i8 undef, -128
ret i1 %cmp
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK: ret i1 undef
}
@@ -154,7 +153,7 @@ define i1 @test16() nounwind readnone {
entry:
%cmp = icmp ne i8 undef, -128
ret i1 %cmp
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK: ret i1 undef
}
@@ -163,7 +162,7 @@ define i1 @test17(i32 %x) nounwind {
%and = and i32 %shl, 8
%cmp = icmp eq i32 %and, 0
ret i1 %cmp
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
}
@@ -173,7 +172,7 @@ define i1 @test18(i32 %x) nounwind {
%and = and i32 %sh, 1
%cmp = icmp eq i32 %and, 0
ret i1 %cmp
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
}
@@ -182,7 +181,7 @@ define i1 @test19(i32 %x) nounwind {
%and = and i32 %shl, 8
%cmp = icmp eq i32 %and, 8
ret i1 %cmp
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK-NEXT: %cmp = icmp eq i32 %x, 3
}
@@ -191,12 +190,12 @@ define i1 @test20(i32 %x) nounwind {
%and = and i32 %shl, 8
%cmp = icmp ne i32 %and, 0
ret i1 %cmp
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK-NEXT: %cmp = icmp eq i32 %x, 3
}
define i1 @test21(i8 %x, i8 %y) {
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK-NOT: or i8
; CHECK: icmp ugt
%A = or i8 %x, 1
@@ -205,7 +204,7 @@ define i1 @test21(i8 %x, i8 %y) {
}
define i1 @test22(i8 %x, i8 %y) {
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK-NOT: or i8
; CHECK: icmp ult
%A = or i8 %x, 1
@@ -214,7 +213,7 @@ define i1 @test22(i8 %x, i8 %y) {
}
; PR2740
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK: icmp sgt i32 %x, 1328634634
define i1 @test23(i32 %x) nounwind {
%i3 = sdiv i32 %x, -1328634635
@@ -225,7 +224,7 @@ define i1 @test23(i32 %x) nounwind {
@X = global [1000 x i32] zeroinitializer
; PR8882
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK: %cmp = icmp eq i64 %i, 1000
; CHECK: ret i1 %cmp
define i1 @test24(i64 %i) {
@@ -234,7 +233,19 @@ define i1 @test24(i64 %i) {
ret i1 %cmp
}
-; CHECK: @test25
+@X_as1 = addrspace(1) global [1000 x i32] zeroinitializer
+
+; CHECK: @test24_as1
+; CHECK: trunc i64 %i to i16
+; CHECK: %cmp = icmp eq i16 %1, 1000
+; CHECK: ret i1 %cmp
+define i1 @test24_as1(i64 %i) {
+ %p1 = getelementptr inbounds i32 addrspace(1)* getelementptr inbounds ([1000 x i32] addrspace(1)* @X_as1, i64 0, i64 0), i64 %i
+ %cmp = icmp eq i32 addrspace(1)* %p1, getelementptr inbounds ([1000 x i32] addrspace(1)* @X_as1, i64 1, i64 0)
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @test25(
; X + Z > Y + Z -> X > Y if there is no overflow.
; CHECK: %c = icmp sgt i32 %x, %y
; CHECK: ret i1 %c
@@ -245,7 +256,7 @@ define i1 @test25(i32 %x, i32 %y, i32 %z) {
ret i1 %c
}
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; X + Z > Y + Z -> X > Y if there is no overflow.
; CHECK: %c = icmp ugt i32 %x, %y
; CHECK: ret i1 %c
@@ -256,7 +267,7 @@ define i1 @test26(i32 %x, i32 %y, i32 %z) {
ret i1 %c
}
-; CHECK: @test27
+; CHECK-LABEL: @test27(
; X - Z > Y - Z -> X > Y if there is no overflow.
; CHECK: %c = icmp sgt i32 %x, %y
; CHECK: ret i1 %c
@@ -267,7 +278,7 @@ define i1 @test27(i32 %x, i32 %y, i32 %z) {
ret i1 %c
}
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; X - Z > Y - Z -> X > Y if there is no overflow.
; CHECK: %c = icmp ugt i32 %x, %y
; CHECK: ret i1 %c
@@ -278,7 +289,7 @@ define i1 @test28(i32 %x, i32 %y, i32 %z) {
ret i1 %c
}
-; CHECK: @test29
+; CHECK-LABEL: @test29(
; X + Y > X -> Y > 0 if there is no overflow.
; CHECK: %c = icmp sgt i32 %y, 0
; CHECK: ret i1 %c
@@ -288,7 +299,7 @@ define i1 @test29(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; X + Y > X -> Y > 0 if there is no overflow.
; CHECK: %c = icmp ne i32 %y, 0
; CHECK: ret i1 %c
@@ -298,7 +309,7 @@ define i1 @test30(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test31
+; CHECK-LABEL: @test31(
; X > X + Y -> 0 > Y if there is no overflow.
; CHECK: %c = icmp slt i32 %y, 0
; CHECK: ret i1 %c
@@ -308,7 +319,7 @@ define i1 @test31(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test32
+; CHECK-LABEL: @test32(
; X > X + Y -> 0 > Y if there is no overflow.
; CHECK: ret i1 false
define i1 @test32(i32 %x, i32 %y) {
@@ -317,7 +328,7 @@ define i1 @test32(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test33
+; CHECK-LABEL: @test33(
; X - Y > X -> 0 > Y if there is no overflow.
; CHECK: %c = icmp slt i32 %y, 0
; CHECK: ret i1 %c
@@ -327,7 +338,7 @@ define i1 @test33(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test34
+; CHECK-LABEL: @test34(
; X - Y > X -> 0 > Y if there is no overflow.
; CHECK: ret i1 false
define i1 @test34(i32 %x, i32 %y) {
@@ -336,7 +347,7 @@ define i1 @test34(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test35
+; CHECK-LABEL: @test35(
; X > X - Y -> Y > 0 if there is no overflow.
; CHECK: %c = icmp sgt i32 %y, 0
; CHECK: ret i1 %c
@@ -346,7 +357,7 @@ define i1 @test35(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test36
+; CHECK-LABEL: @test36(
; X > X - Y -> Y > 0 if there is no overflow.
; CHECK: %c = icmp ne i32 %y, 0
; CHECK: ret i1 %c
@@ -356,7 +367,7 @@ define i1 @test36(i32 %x, i32 %y) {
ret i1 %c
}
-; CHECK: @test37
+; CHECK-LABEL: @test37(
; X - Y > X - Z -> Z > Y if there is no overflow.
; CHECK: %c = icmp sgt i32 %z, %y
; CHECK: ret i1 %c
@@ -367,7 +378,7 @@ define i1 @test37(i32 %x, i32 %y, i32 %z) {
ret i1 %c
}
-; CHECK: @test38
+; CHECK-LABEL: @test38(
; X - Y > X - Z -> Z > Y if there is no overflow.
; CHECK: %c = icmp ugt i32 %z, %y
; CHECK: ret i1 %c
@@ -379,7 +390,7 @@ define i1 @test38(i32 %x, i32 %y, i32 %z) {
}
; PR9343 #1
-; CHECK: @test39
+; CHECK-LABEL: @test39(
; CHECK: %B = icmp eq i32 %X, 0
define i1 @test39(i32 %X, i32 %Y) {
%A = ashr exact i32 %X, %Y
@@ -387,7 +398,7 @@ define i1 @test39(i32 %X, i32 %Y) {
ret i1 %B
}
-; CHECK: @test40
+; CHECK-LABEL: @test40(
; CHECK: %B = icmp ne i32 %X, 0
define i1 @test40(i32 %X, i32 %Y) {
%A = lshr exact i32 %X, %Y
@@ -396,7 +407,7 @@ define i1 @test40(i32 %X, i32 %Y) {
}
; PR9343 #3
-; CHECK: @test41
+; CHECK-LABEL: @test41(
; CHECK: ret i1 true
define i1 @test41(i32 %X, i32 %Y) {
%A = urem i32 %X, %Y
@@ -404,7 +415,7 @@ define i1 @test41(i32 %X, i32 %Y) {
ret i1 %B
}
-; CHECK: @test42
+; CHECK-LABEL: @test42(
; CHECK: %B = icmp sgt i32 %Y, -1
define i1 @test42(i32 %X, i32 %Y) {
%A = srem i32 %X, %Y
@@ -412,7 +423,7 @@ define i1 @test42(i32 %X, i32 %Y) {
ret i1 %B
}
-; CHECK: @test43
+; CHECK-LABEL: @test43(
; CHECK: %B = icmp slt i32 %Y, 0
define i1 @test43(i32 %X, i32 %Y) {
%A = srem i32 %X, %Y
@@ -420,7 +431,7 @@ define i1 @test43(i32 %X, i32 %Y) {
ret i1 %B
}
-; CHECK: @test44
+; CHECK-LABEL: @test44(
; CHECK: %B = icmp sgt i32 %Y, -1
define i1 @test44(i32 %X, i32 %Y) {
%A = srem i32 %X, %Y
@@ -428,7 +439,7 @@ define i1 @test44(i32 %X, i32 %Y) {
ret i1 %B
}
-; CHECK: @test45
+; CHECK-LABEL: @test45(
; CHECK: %B = icmp slt i32 %Y, 0
define i1 @test45(i32 %X, i32 %Y) {
%A = srem i32 %X, %Y
@@ -437,7 +448,7 @@ define i1 @test45(i32 %X, i32 %Y) {
}
; PR9343 #4
-; CHECK: @test46
+; CHECK-LABEL: @test46(
; CHECK: %C = icmp ult i32 %X, %Y
define i1 @test46(i32 %X, i32 %Y, i32 %Z) {
%A = ashr exact i32 %X, %Z
@@ -447,7 +458,7 @@ define i1 @test46(i32 %X, i32 %Y, i32 %Z) {
}
; PR9343 #5
-; CHECK: @test47
+; CHECK-LABEL: @test47(
; CHECK: %C = icmp ugt i32 %X, %Y
define i1 @test47(i32 %X, i32 %Y, i32 %Z) {
%A = ashr exact i32 %X, %Z
@@ -457,7 +468,7 @@ define i1 @test47(i32 %X, i32 %Y, i32 %Z) {
}
; PR9343 #8
-; CHECK: @test48
+; CHECK-LABEL: @test48(
; CHECK: %C = icmp eq i32 %X, %Y
define i1 @test48(i32 %X, i32 %Y, i32 %Z) {
%A = sdiv exact i32 %X, %Z
@@ -467,17 +478,17 @@ define i1 @test48(i32 %X, i32 %Y, i32 %Z) {
}
; PR8469
-; CHECK: @test49
+; CHECK-LABEL: @test49(
; CHECK: ret <2 x i1> <i1 true, i1 true>
define <2 x i1> @test49(<2 x i32> %tmp3) {
entry:
%tmp11 = and <2 x i32> %tmp3, <i32 3, i32 3>
%cmp = icmp ult <2 x i32> %tmp11, <i32 4, i32 4>
- ret <2 x i1> %cmp
+ ret <2 x i1> %cmp
}
; PR9343 #7
-; CHECK: @test50
+; CHECK-LABEL: @test50(
; CHECK: ret i1 true
define i1 @test50(i16 %X, i32 %Y) {
%A = zext i16 %X to i32
@@ -486,7 +497,7 @@ define i1 @test50(i16 %X, i32 %Y) {
ret i1 %C
}
-; CHECK: @test51
+; CHECK-LABEL: @test51(
; CHECK: ret i1 %C
define i1 @test51(i32 %X, i32 %Y) {
%A = and i32 %X, 2147483648
@@ -495,7 +506,7 @@ define i1 @test51(i32 %X, i32 %Y) {
ret i1 %C
}
-; CHECK: @test52
+; CHECK-LABEL: @test52(
; CHECK-NEXT: and i32 %x1, 16711935
; CHECK-NEXT: icmp eq i32 {{.*}}, 4980863
; CHECK-NEXT: ret i1
@@ -511,18 +522,18 @@ define i1 @test52(i32 %x1) nounwind {
}
; PR9838
-; CHECK: @test53
-; CHECK-NEXT: ashr exact
-; CHECK-NEXT: ashr
+; CHECK-LABEL: @test53(
+; CHECK-NEXT: sdiv exact
+; CHECK-NEXT: sdiv
; CHECK-NEXT: icmp
define i1 @test53(i32 %a, i32 %b) nounwind {
- %x = ashr exact i32 %a, 30
- %y = ashr i32 %b, 30
+ %x = sdiv exact i32 %a, 30
+ %y = sdiv i32 %b, 30
%z = icmp eq i32 %x, %y
ret i1 %z
}
-; CHECK: @test54
+; CHECK-LABEL: @test54(
; CHECK-NEXT: %and = and i8 %a, -64
; CHECK-NEXT: icmp eq i8 %and, -128
define i1 @test54(i8 %a) nounwind {
@@ -532,7 +543,7 @@ define i1 @test54(i8 %a) nounwind {
ret i1 %ret
}
-; CHECK: @test55
+; CHECK-LABEL: @test55(
; CHECK-NEXT: icmp eq i32 %a, -123
define i1 @test55(i32 %a) {
%sub = sub i32 0, %a
@@ -540,7 +551,7 @@ define i1 @test55(i32 %a) {
ret i1 %cmp
}
-; CHECK: @test56
+; CHECK-LABEL: @test56(
; CHECK-NEXT: icmp eq i32 %a, -113
define i1 @test56(i32 %a) {
%sub = sub i32 10, %a
@@ -550,7 +561,7 @@ define i1 @test56(i32 %a) {
; PR10267 Don't make icmps more expensive when no other inst is subsumed.
declare void @foo(i32)
-; CHECK: @test57
+; CHECK-LABEL: @test57(
; CHECK: %and = and i32 %a, -2
; CHECK: %cmp = icmp ne i32 %and, 0
define i1 @test57(i32 %a) {
@@ -561,7 +572,7 @@ define i1 @test57(i32 %a) {
}
; rdar://problem/10482509
-; CHECK: @cmpabs1
+; CHECK-LABEL: @cmpabs1(
; CHECK-NEXT: icmp ne
define zeroext i1 @cmpabs1(i64 %val) {
%sub = sub nsw i64 0, %val
@@ -571,7 +582,7 @@ define zeroext i1 @cmpabs1(i64 %val) {
ret i1 %tobool
}
-; CHECK: @cmpabs2
+; CHECK-LABEL: @cmpabs2(
; CHECK-NEXT: icmp ne
define zeroext i1 @cmpabs2(i64 %val) {
%sub = sub nsw i64 0, %val
@@ -581,7 +592,7 @@ define zeroext i1 @cmpabs2(i64 %val) {
ret i1 %tobool
}
-; CHECK: @test58
+; CHECK-LABEL: @test58(
; CHECK-NEXT: call i32 @test58_d(i64 36029346783166592)
define void @test58() nounwind {
%cast = bitcast <1 x i64> <i64 36029346783166592> to i64
@@ -599,7 +610,22 @@ define i1 @test59(i8* %foo) {
%use = ptrtoint i8* %cast1 to i64
%call = call i32 @test58_d(i64 %use) nounwind
ret i1 %cmp
-; CHECK: @test59
+; CHECK-LABEL: @test59(
+; CHECK: ret i1 true
+}
+
+define i1 @test59_as1(i8 addrspace(1)* %foo) {
+ %bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
+ %gep1 = getelementptr inbounds i32 addrspace(1)* %bit, i64 2
+ %gep2 = getelementptr inbounds i8 addrspace(1)* %foo, i64 10
+ %cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
+ %cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
+ %use = ptrtoint i8 addrspace(1)* %cast1 to i64
+ %call = call i32 @test58_d(i64 %use) nounwind
+ ret i1 %cmp
+; CHECK: @test59_as1
+; CHECK: %[[GEP:.+]] = getelementptr inbounds i8 addrspace(1)* %foo, i16 8
+; CHECK: ptrtoint i8 addrspace(1)* %[[GEP]] to i16
; CHECK: ret i1 true
}
@@ -610,12 +636,27 @@ define i1 @test60(i8* %foo, i64 %i, i64 %j) {
%cast1 = bitcast i32* %gep1 to i8*
%cmp = icmp ult i8* %cast1, %gep2
ret i1 %cmp
-; CHECK: @test60
+; CHECK-LABEL: @test60(
; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2
; CHECK-NEXT: icmp slt i64 %gep1.idx, %j
; CHECK-NEXT: ret i1
}
+define i1 @test60_as1(i8 addrspace(1)* %foo, i64 %i, i64 %j) {
+ %bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
+ %gep1 = getelementptr inbounds i32 addrspace(1)* %bit, i64 %i
+ %gep2 = getelementptr inbounds i8 addrspace(1)* %foo, i64 %j
+ %cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
+ %cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
+ ret i1 %cmp
+; CHECK: @test60_as1
+; CHECK: trunc i64 %i to i16
+; CHECK: trunc i64 %j to i16
+; CHECK: %gep1.idx = shl nuw i16 %{{.+}}, 2
+; CHECK-NEXT: icmp sgt i16 %{{.+}}, %gep1.idx
+; CHECK-NEXT: ret i1
+}
+
define i1 @test61(i8* %foo, i64 %i, i64 %j) {
%bit = bitcast i8* %foo to i32*
%gep1 = getelementptr i32* %bit, i64 %i
@@ -624,26 +665,48 @@ define i1 @test61(i8* %foo, i64 %i, i64 %j) {
%cmp = icmp ult i8* %cast1, %gep2
ret i1 %cmp
; Don't transform non-inbounds GEPs.
-; CHECK: @test61
+; CHECK-LABEL: @test61(
; CHECK: icmp ult i8* %cast1, %gep2
; CHECK-NEXT: ret i1
}
+define i1 @test61_as1(i8 addrspace(1)* %foo, i16 %i, i16 %j) {
+ %bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
+ %gep1 = getelementptr i32 addrspace(1)* %bit, i16 %i
+ %gep2 = getelementptr i8 addrspace(1)* %foo, i16 %j
+ %cast1 = bitcast i32 addrspace(1)* %gep1 to i8 addrspace(1)*
+ %cmp = icmp ult i8 addrspace(1)* %cast1, %gep2
+ ret i1 %cmp
+; Don't transform non-inbounds GEPs.
+; CHECK: @test61_as1
+; CHECK: icmp ult i8 addrspace(1)* %cast1, %gep2
+; CHECK-NEXT: ret i1
+}
+
define i1 @test62(i8* %a) {
%arrayidx1 = getelementptr inbounds i8* %a, i64 1
%arrayidx2 = getelementptr inbounds i8* %a, i64 10
%cmp = icmp slt i8* %arrayidx1, %arrayidx2
ret i1 %cmp
-; CHECK: @test62
+; CHECK-LABEL: @test62(
; CHECK-NEXT: ret i1 true
}
+define i1 @test62_as1(i8 addrspace(1)* %a) {
+; CHECK-LABEL: @test62_as1(
+; CHECK-NEXT: ret i1 true
+ %arrayidx1 = getelementptr inbounds i8 addrspace(1)* %a, i64 1
+ %arrayidx2 = getelementptr inbounds i8 addrspace(1)* %a, i64 10
+ %cmp = icmp slt i8 addrspace(1)* %arrayidx1, %arrayidx2
+ ret i1 %cmp
+}
+
define i1 @test63(i8 %a, i32 %b) nounwind {
%z = zext i8 %a to i32
%t = and i32 %b, 255
%c = icmp eq i32 %z, %t
ret i1 %c
-; CHECK: @test63
+; CHECK-LABEL: @test63(
; CHECK-NEXT: %1 = trunc i32 %b to i8
; CHECK-NEXT: %c = icmp eq i8 %1, %a
; CHECK-NEXT: ret i1 %c
@@ -654,7 +717,7 @@ define i1 @test64(i8 %a, i32 %b) nounwind {
%z = zext i8 %a to i32
%c = icmp eq i32 %t, %z
ret i1 %c
-; CHECK: @test64
+; CHECK-LABEL: @test64(
; CHECK-NEXT: %1 = trunc i32 %b to i8
; CHECK-NEXT: %c = icmp eq i8 %1, %a
; CHECK-NEXT: ret i1 %c
@@ -664,7 +727,7 @@ define i1 @test65(i64 %A, i64 %B) {
%s1 = add i64 %A, %B
%s2 = add i64 %A, %B
%cmp = icmp eq i64 %s1, %s2
-; CHECK: @test65
+; CHECK-LABEL: @test65(
; CHECK-NEXT: ret i1 true
ret i1 %cmp
}
@@ -673,12 +736,12 @@ define i1 @test66(i64 %A, i64 %B) {
%s1 = add i64 %A, %B
%s2 = add i64 %B, %A
%cmp = icmp eq i64 %s1, %s2
-; CHECK: @test66
+; CHECK-LABEL: @test66(
; CHECK-NEXT: ret i1 true
ret i1 %cmp
}
-; CHECK: @test67
+; CHECK-LABEL: @test67(
; CHECK: %and = and i32 %x, 96
; CHECK: %cmp = icmp ne i32 %and, 0
define i1 @test67(i32 %x) nounwind uwtable {
@@ -687,7 +750,7 @@ define i1 @test67(i32 %x) nounwind uwtable {
ret i1 %cmp
}
-; CHECK: @test68
+; CHECK-LABEL: @test68(
; CHECK: %cmp = icmp ugt i32 %and, 30
define i1 @test68(i32 %x) nounwind uwtable {
%and = and i32 %x, 127
@@ -696,7 +759,7 @@ define i1 @test68(i32 %x) nounwind uwtable {
}
; PR14708
-; CHECK: @test69
+; CHECK-LABEL: @test69(
; CHECK: %1 = and i32 %c, -33
; CHECK: %2 = icmp eq i32 %1, 65
; CHECK: ret i1 %2
@@ -707,7 +770,19 @@ define i1 @test69(i32 %c) nounwind uwtable {
ret i1 %3
}
-; CHECK: @icmp_sext16trunc
+; PR15940
+; CHECK-LABEL: @test70(
+; CHECK-NEXT: %A = srem i32 5, %X
+; CHECK-NEXT: %C = icmp ne i32 %A, 2
+; CHECK-NEXT: ret i1 %C
+define i1 @test70(i32 %X) {
+ %A = srem i32 5, %X
+ %B = add i32 %A, 2
+ %C = icmp ne i32 %B, 4
+ ret i1 %C
+}
+
+; CHECK-LABEL: @icmp_sext16trunc(
; CHECK-NEXT: %1 = trunc i32 %x to i16
; CHECK-NEXT: %cmp = icmp slt i16 %1, 36
define i1 @icmp_sext16trunc(i32 %x) {
@@ -717,7 +792,7 @@ define i1 @icmp_sext16trunc(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_sext8trunc
+; CHECK-LABEL: @icmp_sext8trunc(
; CHECK-NEXT: %1 = trunc i32 %x to i8
; CHECK-NEXT: %cmp = icmp slt i8 %1, 36
define i1 @icmp_sext8trunc(i32 %x) {
@@ -727,7 +802,7 @@ define i1 @icmp_sext8trunc(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl16
+; CHECK-LABEL: @icmp_shl16(
; CHECK-NEXT: %1 = trunc i32 %x to i16
; CHECK-NEXT: %cmp = icmp slt i16 %1, 36
define i1 @icmp_shl16(i32 %x) {
@@ -736,7 +811,7 @@ define i1 @icmp_shl16(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl24
+; CHECK-LABEL: @icmp_shl24(
; CHECK-NEXT: %1 = trunc i32 %x to i8
; CHECK-NEXT: %cmp = icmp slt i8 %1, 36
define i1 @icmp_shl24(i32 %x) {
@@ -747,7 +822,7 @@ define i1 @icmp_shl24(i32 %x) {
; If the (shl x, C) preserved the sign and this is a sign test,
; compare the LHS operand instead
-; CHECK: @icmp_shl_nsw_sgt
+; CHECK-LABEL: @icmp_shl_nsw_sgt(
; CHECK-NEXT: icmp sgt i32 %x, 0
define i1 @icmp_shl_nsw_sgt(i32 %x) {
%shl = shl nsw i32 %x, 21
@@ -755,7 +830,7 @@ define i1 @icmp_shl_nsw_sgt(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl_nsw_sge0
+; CHECK-LABEL: @icmp_shl_nsw_sge0(
; CHECK-NEXT: icmp sgt i32 %x, -1
define i1 @icmp_shl_nsw_sge0(i32 %x) {
%shl = shl nsw i32 %x, 21
@@ -763,7 +838,7 @@ define i1 @icmp_shl_nsw_sge0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl_nsw_sge1
+; CHECK-LABEL: @icmp_shl_nsw_sge1(
; CHECK-NEXT: icmp sgt i32 %x, 0
define i1 @icmp_shl_nsw_sge1(i32 %x) {
%shl = shl nsw i32 %x, 21
@@ -772,7 +847,7 @@ define i1 @icmp_shl_nsw_sge1(i32 %x) {
}
; Checks for icmp (eq|ne) (shl x, C), 0
-; CHECK: @icmp_shl_nsw_eq
+; CHECK-LABEL: @icmp_shl_nsw_eq(
; CHECK-NEXT: icmp eq i32 %x, 0
define i1 @icmp_shl_nsw_eq(i32 %x) {
%mul = shl nsw i32 %x, 5
@@ -780,7 +855,7 @@ define i1 @icmp_shl_nsw_eq(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl_eq
+; CHECK-LABEL: @icmp_shl_eq(
; CHECK-NOT: icmp eq i32 %mul, 0
define i1 @icmp_shl_eq(i32 %x) {
%mul = shl i32 %x, 5
@@ -788,7 +863,7 @@ define i1 @icmp_shl_eq(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl_nsw_ne
+; CHECK-LABEL: @icmp_shl_nsw_ne(
; CHECK-NEXT: icmp ne i32 %x, 0
define i1 @icmp_shl_nsw_ne(i32 %x) {
%mul = shl nsw i32 %x, 7
@@ -796,7 +871,7 @@ define i1 @icmp_shl_nsw_ne(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_shl_ne
+; CHECK-LABEL: @icmp_shl_ne(
; CHECK-NOT: icmp ne i32 %x, 0
define i1 @icmp_shl_ne(i32 %x) {
%mul = shl i32 %x, 7
@@ -806,7 +881,7 @@ define i1 @icmp_shl_ne(i32 %x) {
; If the (mul x, C) preserved the sign and this is sign test,
; compare the LHS operand instead
-; CHECK: @icmp_mul_nsw
+; CHECK-LABEL: @icmp_mul_nsw(
; CHECK-NEXT: icmp sgt i32 %x, 0
define i1 @icmp_mul_nsw(i32 %x) {
%mul = mul nsw i32 %x, 12
@@ -814,7 +889,7 @@ define i1 @icmp_mul_nsw(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul_nsw1
+; CHECK-LABEL: @icmp_mul_nsw1(
; CHECK-NEXT: icmp slt i32 %x, 0
define i1 @icmp_mul_nsw1(i32 %x) {
%mul = mul nsw i32 %x, 12
@@ -822,7 +897,7 @@ define i1 @icmp_mul_nsw1(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul_nsw_neg
+; CHECK-LABEL: @icmp_mul_nsw_neg(
; CHECK-NEXT: icmp slt i32 %x, 1
define i1 @icmp_mul_nsw_neg(i32 %x) {
%mul = mul nsw i32 %x, -12
@@ -830,7 +905,7 @@ define i1 @icmp_mul_nsw_neg(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul_nsw_neg1
+; CHECK-LABEL: @icmp_mul_nsw_neg1(
; CHECK-NEXT: icmp slt i32 %x, 0
define i1 @icmp_mul_nsw_neg1(i32 %x) {
%mul = mul nsw i32 %x, -12
@@ -838,7 +913,7 @@ define i1 @icmp_mul_nsw_neg1(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul_nsw_0
+; CHECK-LABEL: @icmp_mul_nsw_0(
; CHECK-NOT: icmp sgt i32 %x, 0
define i1 @icmp_mul_nsw_0(i32 %x) {
%mul = mul nsw i32 %x, 0
@@ -846,7 +921,7 @@ define i1 @icmp_mul_nsw_0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul
+; CHECK-LABEL: @icmp_mul(
; CHECK-NEXT: %mul = mul i32 %x, -12
define i1 @icmp_mul(i32 %x) {
%mul = mul i32 %x, -12
@@ -855,7 +930,7 @@ define i1 @icmp_mul(i32 %x) {
}
; Checks for icmp (eq|ne) (mul x, C), 0
-; CHECK: @icmp_mul_neq0
+; CHECK-LABEL: @icmp_mul_neq0(
; CHECK-NEXT: icmp ne i32 %x, 0
define i1 @icmp_mul_neq0(i32 %x) {
%mul = mul nsw i32 %x, -12
@@ -863,7 +938,7 @@ define i1 @icmp_mul_neq0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul_eq0
+; CHECK-LABEL: @icmp_mul_eq0(
; CHECK-NEXT: icmp eq i32 %x, 0
define i1 @icmp_mul_eq0(i32 %x) {
%mul = mul nsw i32 %x, 12
@@ -871,7 +946,7 @@ define i1 @icmp_mul_eq0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul0_eq0
+; CHECK-LABEL: @icmp_mul0_eq0(
; CHECK-NEXT: ret i1 true
define i1 @icmp_mul0_eq0(i32 %x) {
%mul = mul i32 %x, 0
@@ -879,7 +954,7 @@ define i1 @icmp_mul0_eq0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_mul0_ne0
+; CHECK-LABEL: @icmp_mul0_ne0(
; CHECK-NEXT: ret i1 false
define i1 @icmp_mul0_ne0(i32 %x) {
%mul = mul i32 %x, 0
@@ -887,7 +962,7 @@ define i1 @icmp_mul0_ne0(i32 %x) {
ret i1 %cmp
}
-; CHECK: @icmp_sub1_sge
+; CHECK-LABEL: @icmp_sub1_sge(
; CHECK-NEXT: icmp sgt i32 %x, %y
define i1 @icmp_sub1_sge(i32 %x, i32 %y) {
%sub = add nsw i32 %x, -1
@@ -895,7 +970,7 @@ define i1 @icmp_sub1_sge(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_add1_sgt
+; CHECK-LABEL: @icmp_add1_sgt(
; CHECK-NEXT: icmp sge i32 %x, %y
define i1 @icmp_add1_sgt(i32 %x, i32 %y) {
%add = add nsw i32 %x, 1
@@ -903,7 +978,7 @@ define i1 @icmp_add1_sgt(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_sub1_slt
+; CHECK-LABEL: @icmp_sub1_slt(
; CHECK-NEXT: icmp sle i32 %x, %y
define i1 @icmp_sub1_slt(i32 %x, i32 %y) {
%sub = add nsw i32 %x, -1
@@ -911,7 +986,7 @@ define i1 @icmp_sub1_slt(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_add1_sle
+; CHECK-LABEL: @icmp_add1_sle(
; CHECK-NEXT: icmp slt i32 %x, %y
define i1 @icmp_add1_sle(i32 %x, i32 %y) {
%add = add nsw i32 %x, 1
@@ -919,7 +994,7 @@ define i1 @icmp_add1_sle(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_add20_sge_add57
+; CHECK-LABEL: @icmp_add20_sge_add57(
; CHECK-NEXT: [[ADD:%[a-z0-9]+]] = add nsw i32 %y, 37
; CHECK-NEXT: icmp sle i32 [[ADD]], %x
define i1 @icmp_add20_sge_add57(i32 %x, i32 %y) {
@@ -929,7 +1004,7 @@ define i1 @icmp_add20_sge_add57(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_sub57_sge_sub20
+; CHECK-LABEL: @icmp_sub57_sge_sub20(
; CHECK-NEXT: [[SUB:%[a-z0-9]+]] = add nsw i32 %x, -37
; CHECK-NEXT: icmp sge i32 [[SUB]], %y
define i1 @icmp_sub57_sge_sub20(i32 %x, i32 %y) {
@@ -939,7 +1014,7 @@ define i1 @icmp_sub57_sge_sub20(i32 %x, i32 %y) {
ret i1 %cmp
}
-; CHECK: @icmp_and_shl_neg_ne_0
+; CHECK-LABEL: @icmp_and_shl_neg_ne_0(
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 0
@@ -952,7 +1027,7 @@ define i1 @icmp_and_shl_neg_ne_0(i32 %A, i32 %B) {
ret i1 %cmp
}
-; CHECK: @icmp_and_shl_neg_eq_0
+; CHECK-LABEL: @icmp_and_shl_neg_eq_0(
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 1, %B
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], %A
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 0
@@ -965,7 +1040,7 @@ define i1 @icmp_and_shl_neg_eq_0(i32 %A, i32 %B) {
ret i1 %cmp
}
-; CHECK: @icmp_add_and_shr_ne_0
+; CHECK-LABEL: @icmp_add_and_shr_ne_0(
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, 240
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 224
; CHECK-NEXT: ret i1 [[CMP]]
@@ -976,3 +1051,308 @@ define i1 @icmp_add_and_shr_ne_0(i32 %X) {
%tobool = icmp ne i32 %add, 0
ret i1 %tobool
}
+
+; PR16244
+; CHECK-LABEL: define i1 @test71(
+; CHECK-NEXT: ret i1 false
+define i1 @test71(i8* %x) {
+ %a = getelementptr i8* %x, i64 8
+ %b = getelementptr inbounds i8* %x, i64 8
+ %c = icmp ugt i8* %a, %b
+ ret i1 %c
+}
+
+define i1 @test71_as1(i8 addrspace(1)* %x) {
+; CHECK-LABEL: @test71_as1(
+; CHECK-NEXT: ret i1 false
+ %a = getelementptr i8 addrspace(1)* %x, i64 8
+ %b = getelementptr inbounds i8 addrspace(1)* %x, i64 8
+ %c = icmp ugt i8 addrspace(1)* %a, %b
+ ret i1 %c
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ult_32(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_ult_32(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ult i32 %shl, 32
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_eq_32(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 %V, 5
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_eq_32(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp eq i32 %shl, 32
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_eq_31(
+; CHECK-NEXT: ret i1 false
+define i1 @icmp_shl_1_V_eq_31(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp eq i32 %shl, 31
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ne_31(
+; CHECK-NEXT: ret i1 true
+define i1 @icmp_shl_1_V_ne_31(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ne i32 %shl, 31
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ult_30(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_ult_30(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ult i32 %shl, 30
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ugt_30(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %V, 4
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_ugt_30(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ugt i32 %shl, 30
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ule_30(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %V, 5
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_ule_30(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ule i32 %shl, 30
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_uge_30(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %V, 4
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_uge_30(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp uge i32 %shl, 30
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_uge_2147483648(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 %V, 31
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_uge_2147483648(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp uge i32 %shl, 2147483648
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ugt_2147483648(
+; CHECK-NEXT: ret i1 false
+define i1 @icmp_shl_1_V_ugt_2147483648(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ugt i32 %shl, 2147483648
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ule_2147483648(
+; CHECK-NEXT: ret i1 true
+define i1 @icmp_shl_1_V_ule_2147483648(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ule i32 %shl, 2147483648
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_shl_1_V_ult_2147483648(
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 %V, 31
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_shl_1_V_ult_2147483648(i32 %V) {
+ %shl = shl i32 1, %V
+ %cmp = icmp ult i32 %shl, 2147483648
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @or_icmp_eq_B_0_icmp_ult_A_B(
+; CHECK-NEXT: [[SUB:%[a-z0-9]+]] = add i64 %b, -1
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp uge i64 [[SUB]], %a
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @or_icmp_eq_B_0_icmp_ult_A_B(i64 %a, i64 %b) {
+ %1 = icmp eq i64 %b, 0
+ %2 = icmp ult i64 %a, %b
+ %3 = or i1 %1, %2
+ ret i1 %3
+}
+
+; CHECK-LABEL: @icmp_add_ult_2(
+; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 14
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_add_ult_2(i32 %X) {
+ %add = add i32 %X, -14
+ %cmp = icmp ult i32 %add, 2
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_add_X_-14_ult_2
+; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[AND]], 14
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_add_X_-14_ult_2(i32 %X) {
+ %add = add i32 %X, -14
+ %cmp = icmp ult i32 %add, 2
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_sub_3_X_ult_2(
+; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %X, 1
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp eq i32 [[OR]], 3
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_sub_3_X_ult_2(i32 %X) {
+ %add = sub i32 3, %X
+ %cmp = icmp ult i32 %add, 2
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_add_X_-14_uge_2
+; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %X, -2
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[AND]], 14
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_add_X_-14_uge_2(i32 %X) {
+ %add = add i32 %X, -14
+ %cmp = icmp uge i32 %add, 2
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_sub_3_X_uge_2(
+; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 %X, 1
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ne i32 [[OR]], 3
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_sub_3_X_uge_2(i32 %X) {
+ %add = sub i32 3, %X
+ %cmp = icmp uge i32 %add, 2
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_and_X_-16_eq-16
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %X, -17
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_and_X_-16_eq-16(i32 %X) {
+ %and = and i32 %X, -16
+ %cmp = icmp eq i32 %and, -16
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_and_X_-16_ne-16
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, -16
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_and_X_-16_ne-16(i32 %X) {
+ %and = and i32 %X, -16
+ %cmp = icmp ne i32 %and, -16
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_sub_-1_X_ult_4
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %X, -5
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_sub_-1_X_ult_4(i32 %X) {
+ %sub = sub i32 -1, %X
+ %cmp = icmp ult i32 %sub, 4
+ ret i1 %cmp
+}
+
+; CHECK: @icmp_sub_-1_X_uge_4
+; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, -4
+; CHECK-NEXT: ret i1 [[CMP]]
+define i1 @icmp_sub_-1_X_uge_4(i32 %X) {
+ %sub = sub i32 -1, %X
+ %cmp = icmp uge i32 %sub, 4
+ ret i1 %cmp
+}
+
+; CHECK-LABEL: @icmp_swap_operands_for_cse
+; CHECK: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, %Y
+; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
+; CHECK: ret i1
+define i1 @icmp_swap_operands_for_cse(i32 %X, i32 %Y) {
+entry:
+ %sub = sub i32 %X, %Y
+ %cmp = icmp ugt i32 %Y, %X
+ br i1 %cmp, label %true, label %false
+true:
+ %restrue = trunc i32 %sub to i1
+ br label %end
+false:
+ %shift = lshr i32 %sub, 4
+ %resfalse = trunc i32 %shift to i1
+ br label %end
+end:
+ %res = phi i1 [%restrue, %true], [%resfalse, %false]
+ ret i1 %res
+}
+
+; CHECK-LABEL: @icmp_swap_operands_for_cse2
+; CHECK: [[CMP:%[a-z0-9]+]] = icmp ult i32 %X, %Y
+; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
+; CHECK: ret i1
+define i1 @icmp_swap_operands_for_cse2(i32 %X, i32 %Y) {
+entry:
+ %cmp = icmp ugt i32 %Y, %X
+ br i1 %cmp, label %true, label %false
+true:
+ %sub = sub i32 %X, %Y
+ %sub1 = sub i32 %X, %Y
+ %add = add i32 %sub, %sub1
+ %restrue = trunc i32 %add to i1
+ br label %end
+false:
+ %sub2 = sub i32 %Y, %X
+ %resfalse = trunc i32 %sub2 to i1
+ br label %end
+end:
+ %res = phi i1 [%restrue, %true], [%resfalse, %false]
+ ret i1 %res
+}
+
+; CHECK-LABEL: @icmp_do_not_swap_operands_for_cse
+; CHECK: [[CMP:%[a-z0-9]+]] = icmp ugt i32 %Y, %X
+; CHECK-NEXT: br i1 [[CMP]], label %true, label %false
+; CHECK: ret i1
+define i1 @icmp_do_not_swap_operands_for_cse(i32 %X, i32 %Y) {
+entry:
+ %cmp = icmp ugt i32 %Y, %X
+ br i1 %cmp, label %true, label %false
+true:
+ %sub = sub i32 %X, %Y
+ %restrue = trunc i32 %sub to i1
+ br label %end
+false:
+ %sub2 = sub i32 %Y, %X
+ %resfalse = trunc i32 %sub2 to i1
+ br label %end
+end:
+ %res = phi i1 [%restrue, %true], [%resfalse, %false]
+ ret i1 %res
+}
+
+; CHECK-LABEL: @icmp_lshr_lshr_eq
+; CHECK: %z.unshifted = xor i32 %a, %b
+; CHECK: %z = icmp ult i32 %z.unshifted, 1073741824
+define i1 @icmp_lshr_lshr_eq(i32 %a, i32 %b) nounwind {
+ %x = lshr i32 %a, 30
+ %y = lshr i32 %b, 30
+ %z = icmp eq i32 %x, %y
+ ret i1 %z
+}
+
+; CHECK-LABEL: @icmp_ashr_ashr_ne
+; CHECK: %z.unshifted = xor i32 %a, %b
+; CHECK: %z = icmp ugt i32 %z.unshifted, 255
+define i1 @icmp_ashr_ashr_ne(i32 %a, i32 %b) nounwind {
+ %x = ashr i32 %a, 8
+ %y = ashr i32 %b, 8
+ %z = icmp ne i32 %x, %y
+ ret i1 %z
+}
diff --git a/test/Transforms/InstCombine/idioms.ll b/test/Transforms/InstCombine/idioms.ll
index 1a211668c3bf..58485442230c 100644
--- a/test/Transforms/InstCombine/idioms.ll
+++ b/test/Transforms/InstCombine/idioms.ll
@@ -25,7 +25,7 @@ bb3:
bb4:
%f = phi i32 [ %not2, %bb2 ], [ %e, %bb3 ]
ret i32 %f
-; CHECK: @test_asr
+; CHECK-LABEL: @test_asr(
; CHECK: bb4:
; CHECK: %f = ashr i32 %a, %b
; CHECK: ret i32 %f
diff --git a/test/Transforms/InstCombine/intrinsics.ll b/test/Transforms/InstCombine/intrinsics.ll
index f334b3b1e935..91c44704ce78 100644
--- a/test/Transforms/InstCombine/intrinsics.ll
+++ b/test/Transforms/InstCombine/intrinsics.ll
@@ -14,7 +14,7 @@ define i8 @uaddtest1(i8 %A, i8 %B) {
%x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %A, i8 %B)
%y = extractvalue %overflow.result %x, 0
ret i8 %y
-; CHECK: @uaddtest1
+; CHECK-LABEL: @uaddtest1(
; CHECK-NEXT: %y = add i8 %A, %B
; CHECK-NEXT: ret i8 %y
}
@@ -27,7 +27,7 @@ define i8 @uaddtest2(i8 %A, i8 %B, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @uaddtest2
+; CHECK-LABEL: @uaddtest2(
; CHECK-NEXT: %and.A = and i8 %A, 127
; CHECK-NEXT: %and.B = and i8 %B, 127
; CHECK-NEXT: %x = add nuw i8 %and.A, %and.B
@@ -43,7 +43,7 @@ define i8 @uaddtest3(i8 %A, i8 %B, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @uaddtest3
+; CHECK-LABEL: @uaddtest3(
; CHECK-NEXT: %or.A = or i8 %A, -128
; CHECK-NEXT: %or.B = or i8 %B, -128
; CHECK-NEXT: %x = add i8 %or.A, %or.B
@@ -57,7 +57,7 @@ define i8 @uaddtest4(i8 %A, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @uaddtest4
+; CHECK-LABEL: @uaddtest4(
; CHECK-NEXT: ret i8 undef
}
@@ -67,7 +67,7 @@ define i8 @uaddtest5(i8 %A, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @uaddtest5
+; CHECK-LABEL: @uaddtest5(
; CHECK: ret i8 %A
}
@@ -75,7 +75,7 @@ define i1 @uaddtest6(i8 %A, i8 %B) {
%x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %A, i8 -4)
%z = extractvalue %overflow.result %x, 1
ret i1 %z
-; CHECK: @uaddtest6
+; CHECK-LABEL: @uaddtest6(
; CHECK-NEXT: %z = icmp ugt i8 %A, 3
; CHECK-NEXT: ret i1 %z
}
@@ -84,7 +84,7 @@ define i8 @uaddtest7(i8 %A, i8 %B) {
%x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %A, i8 %B)
%z = extractvalue %overflow.result %x, 0
ret i8 %z
-; CHECK: @uaddtest7
+; CHECK-LABEL: @uaddtest7(
; CHECK-NEXT: %z = add i8 %A, %B
; CHECK-NEXT: ret i8 %z
}
@@ -96,7 +96,7 @@ define i8 @umultest1(i8 %A, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @umultest1
+; CHECK-LABEL: @umultest1(
; CHECK-NEXT: store i1 false, i1* %overflowPtr
; CHECK-NEXT: ret i8 0
}
@@ -107,7 +107,7 @@ define i8 @umultest2(i8 %A, i1* %overflowPtr) {
%z = extractvalue %overflow.result %x, 1
store i1 %z, i1* %overflowPtr
ret i8 %y
-; CHECK: @umultest2
+; CHECK-LABEL: @umultest2(
; CHECK-NEXT: store i1 false, i1* %overflowPtr
; CHECK-NEXT: ret i8 %A
}
@@ -122,7 +122,7 @@ define i32 @umultest3(i32 %n) nounwind {
%res = extractvalue %ov.result.32 %mul, 0
%ret = select i1 %ov, i32 -1, i32 %res
ret i32 %ret
-; CHECK: @umultest3
+; CHECK-LABEL: @umultest3(
; CHECK-NEXT: shr
; CHECK-NEXT: mul nuw
; CHECK-NEXT: ret
@@ -135,7 +135,7 @@ define i32 @umultest4(i32 %n) nounwind {
%res = extractvalue %ov.result.32 %mul, 0
%ret = select i1 %ov, i32 -1, i32 %res
ret i32 %ret
-; CHECK: @umultest4
+; CHECK-LABEL: @umultest4(
; CHECK: umul.with.overflow
}
@@ -150,7 +150,7 @@ entry:
%C = tail call double @llvm.powi.f64(double %V, i32 1) nounwind
store volatile double %C, double* %P
ret void
-; CHECK: @powi
+; CHECK-LABEL: @powi(
; CHECK: %A = fdiv double 1.0{{.*}}, %V
; CHECK: store volatile double %A,
; CHECK: store volatile double 1.0
@@ -163,7 +163,7 @@ entry:
%and = and i32 %or, -8
%count = tail call i32 @llvm.cttz.i32(i32 %and, i1 true) nounwind readnone
ret i32 %count
-; CHECK: @cttz
+; CHECK-LABEL: @cttz(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 3
}
@@ -174,7 +174,7 @@ entry:
%and = and i8 %or, 63
%count = tail call i8 @llvm.ctlz.i8(i8 %and, i1 true) nounwind readnone
ret i8 %count
-; CHECK: @ctlz
+; CHECK-LABEL: @ctlz(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i8 2
}
@@ -206,7 +206,7 @@ define i32 @cttz_simplify1a(i32 %x) nounwind readnone ssp {
%shr3 = lshr i32 %tmp1, 5
ret i32 %shr3
-; CHECK: @cttz_simplify1a
+; CHECK-LABEL: @cttz_simplify1a(
; CHECK: icmp eq i32 %x, 0
; CHECK-NEXT: zext i1
; CHECK-NEXT: ret i32
@@ -217,7 +217,7 @@ define i32 @cttz_simplify1b(i32 %x) nounwind readnone ssp {
%shr3 = lshr i32 %tmp1, 5
ret i32 %shr3
-; CHECK: @cttz_simplify1b
+; CHECK-LABEL: @cttz_simplify1b(
; CHECK-NEXT: ret i32 0
}
@@ -225,7 +225,7 @@ define i32 @ctlz_undef(i32 %Value) nounwind {
%ctlz = call i32 @llvm.ctlz.i32(i32 0, i1 true)
ret i32 %ctlz
-; CHECK: @ctlz_undef
+; CHECK-LABEL: @ctlz_undef(
; CHECK-NEXT: ret i32 undef
}
@@ -233,7 +233,7 @@ define i32 @cttz_undef(i32 %Value) nounwind {
%cttz = call i32 @llvm.cttz.i32(i32 0, i1 true)
ret i32 %cttz
-; CHECK: @cttz_undef
+; CHECK-LABEL: @cttz_undef(
; CHECK-NEXT: ret i32 undef
}
@@ -243,7 +243,7 @@ define i32 @ctlz_select(i32 %Value) nounwind {
%s = select i1 %tobool, i32 %ctlz, i32 32
ret i32 %s
-; CHECK: @ctlz_select
+; CHECK-LABEL: @ctlz_select(
; CHECK: select i1 %tobool, i32 %ctlz, i32 32
}
@@ -253,6 +253,6 @@ define i32 @cttz_select(i32 %Value) nounwind {
%s = select i1 %tobool, i32 %cttz, i32 32
ret i32 %s
-; CHECK: @cttz_select
+; CHECK-LABEL: @cttz_select(
; CHECK: select i1 %tobool, i32 %cttz, i32 32
}
diff --git a/test/Transforms/InstCombine/invoke.ll b/test/Transforms/InstCombine/invoke.ll
index 04eaf86a287b..c4b58de61946 100644
--- a/test/Transforms/InstCombine/invoke.ll
+++ b/test/Transforms/InstCombine/invoke.ll
@@ -7,7 +7,7 @@ declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly
declare i8* @_Znwm(i64)
-; CHECK: @f1
+; CHECK-LABEL: @f1(
define i64 @f1() nounwind uwtable ssp {
entry:
; CHECK: nvoke noalias i8* undef()
@@ -27,7 +27,7 @@ lpad:
unreachable
}
-; CHECK: @f2
+; CHECK-LABEL: @f2(
define i64 @f2() nounwind uwtable ssp {
entry:
; CHECK: nvoke noalias i8* null()
@@ -47,7 +47,7 @@ lpad:
unreachable
}
-; CHECK: @f3
+; CHECK-LABEL: @f3(
define void @f3() nounwind uwtable ssp {
; CHECK: invoke void @llvm.donothing()
%call = invoke noalias i8* @_Znwm(i64 13)
diff --git a/test/Transforms/InstCombine/isascii-1.ll b/test/Transforms/InstCombine/isascii-1.ll
index 2a413d89b492..88f5ad66d2ef 100644
--- a/test/Transforms/InstCombine/isascii-1.ll
+++ b/test/Transforms/InstCombine/isascii-1.ll
@@ -9,21 +9,21 @@ declare i32 @isascii(i32)
; Check isascii(c) -> c <u 128.
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @isascii(i32 127)
ret i32 %ret
; CHECK-NEXT: ret i32 1
}
define i32 @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%ret = call i32 @isascii(i32 128)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify3(i32 %x) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%ret = call i32 @isascii(i32 %x)
; CHECK-NEXT: [[CMP:%[a-z0-9]+]] = icmp ult i32 %x, 128
; CHECK-NEXT: [[ZEXT:%[a-z0-9]+]] = zext i1 [[CMP]] to i32
diff --git a/test/Transforms/InstCombine/isdigit-1.ll b/test/Transforms/InstCombine/isdigit-1.ll
index f291296c8826..6791307aeaee 100644
--- a/test/Transforms/InstCombine/isdigit-1.ll
+++ b/test/Transforms/InstCombine/isdigit-1.ll
@@ -9,35 +9,35 @@ declare i32 @isdigit(i32)
; Check isdigit(c) -> (c - '0') <u 10;
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @isdigit(i32 47)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%ret = call i32 @isdigit(i32 48)
ret i32 %ret
; CHECK-NEXT: ret i32 1
}
define i32 @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%ret = call i32 @isdigit(i32 57)
ret i32 %ret
; CHECK-NEXT: ret i32 1
}
define i32 @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%ret = call i32 @isdigit(i32 58)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify5(i32 %x) {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%ret = call i32 @isdigit(i32 %x)
; CHECK-NEXT: [[ADD:%[a-z0-9]+]] = add i32 %x, -48
diff --git a/test/Transforms/InstCombine/lit.local.cfg b/test/Transforms/InstCombine/lit.local.cfg
deleted file mode 100644
index 19eebc0ac7ac..000000000000
--- a/test/Transforms/InstCombine/lit.local.cfg
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.ll', '.c', '.cpp']
diff --git a/test/Transforms/InstCombine/load-cmp.ll b/test/Transforms/InstCombine/load-cmp.ll
index 869215cb58d4..98100263b48c 100644
--- a/test/Transforms/InstCombine/load-cmp.ll
+++ b/test/Transforms/InstCombine/load-cmp.ll
@@ -1,18 +1,75 @@
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt -instcombine -S < %s | FileCheck -check-prefix=NODL %s
+; RUN: opt -instcombine -S -default-data-layout="p:32:32:32-p1:16:16:16-n8:16:32:64" < %s | FileCheck -check-prefix=P32 %s
-@G16 = internal constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
+@G16 = internal constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
i16 73, i16 82, i16 69, i16 68, i16 0]
+
+@G16_as1 = internal addrspace(1) constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85,
+ i16 73, i16 82, i16 69, i16 68, i16 0]
+
@GD = internal constant [6 x double]
[double -10.0, double 1.0, double 4.0, double 2.0, double -20.0, double -40.0]
+%Foo = type { i32, i32, i32, i32 }
+
+@GS = internal constant %Foo { i32 1, i32 4, i32 9, i32 14 }
+
+@GStructArr = internal constant [4 x %Foo] [ %Foo { i32 1, i32 4, i32 9, i32 14 },
+ %Foo { i32 5, i32 4, i32 6, i32 11 },
+ %Foo { i32 6, i32 5, i32 9, i32 20 },
+ %Foo { i32 12, i32 3, i32 9, i32 8 } ]
+
+
define i1 @test1(i32 %X) {
%P = getelementptr inbounds [10 x i16]* @G16, i32 0, i32 %X
%Q = load i16* %P
%R = icmp eq i16 %Q, 0
ret i1 %R
-; CHECK: @test1
-; CHECK-NEXT: %R = icmp eq i32 %X, 9
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test1(
+; NODL-NEXT: %R = icmp eq i32 %X, 9
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test1(
+; P32-NEXT: %R = icmp eq i32 %X, 9
+; P32-NEXT: ret i1 %R
+}
+
+define i1 @test1_noinbounds(i32 %X) {
+ %P = getelementptr [10 x i16]* @G16, i32 0, i32 %X
+ %Q = load i16* %P
+ %R = icmp eq i16 %Q, 0
+ ret i1 %R
+; NODL-LABEL: @test1_noinbounds(
+; NODL-NEXT: %P = getelementptr [10 x i16]* @G16, i32 0, i32 %X
+
+; P32-LABEL: @test1_noinbounds(
+; P32-NEXT: %R = icmp eq i32 %X, 9
+; P32-NEXT: ret i1 %R
+}
+
+define i1 @test1_noinbounds_i64(i64 %X) {
+ %P = getelementptr [10 x i16]* @G16, i64 0, i64 %X
+ %Q = load i16* %P
+ %R = icmp eq i16 %Q, 0
+ ret i1 %R
+; NODL-LABEL: @test1_noinbounds_i64(
+; NODL-NEXT: %P = getelementptr [10 x i16]* @G16, i64 0, i64 %X
+
+; P32-LABEL: @test1_noinbounds_i64(
+; P32: %R = icmp eq i32 %1, 9
+; P32-NEXT: ret i1 %R
+}
+
+define i1 @test1_noinbounds_as1(i32 %x) {
+ %p = getelementptr [10 x i16] addrspace(1)* @G16_as1, i16 0, i32 %x
+ %q = load i16 addrspace(1)* %p
+ %r = icmp eq i16 %q, 0
+ ret i1 %r
+
+; P32-LABEL: @test1_noinbounds_as1(
+; P32-NEXT: trunc i32 %x to i16
+; P32-NEXT: %r = icmp eq i16 %1, 9
+; P32-NEXT: ret i1 %r
}
define i1 @test2(i32 %X) {
@@ -20,9 +77,9 @@ define i1 @test2(i32 %X) {
%Q = load i16* %P
%R = icmp slt i16 %Q, 85
ret i1 %R
-; CHECK: @test2
-; CHECK-NEXT: %R = icmp ne i32 %X, 4
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test2(
+; NODL-NEXT: %R = icmp ne i32 %X, 4
+; NODL-NEXT: ret i1 %R
}
define i1 @test3(i32 %X) {
@@ -30,9 +87,14 @@ define i1 @test3(i32 %X) {
%Q = load double* %P
%R = fcmp oeq double %Q, 1.0
ret i1 %R
-; CHECK: @test3
-; CHECK-NEXT: %R = icmp eq i32 %X, 1
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test3(
+; NODL-NEXT: %R = icmp eq i32 %X, 1
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test3(
+; P32-NEXT: %R = icmp eq i32 %X, 1
+; P32-NEXT: ret i1 %R
+
}
define i1 @test4(i32 %X) {
@@ -40,11 +102,17 @@ define i1 @test4(i32 %X) {
%Q = load i16* %P
%R = icmp sle i16 %Q, 73
ret i1 %R
-; CHECK: @test4
-; CHECK-NEXT: lshr i32 933, %X
-; CHECK-NEXT: and i32 {{.*}}, 1
-; CHECK-NEXT: %R = icmp ne i32 {{.*}}, 0
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test4(
+; NODL-NEXT: lshr i32 933, %X
+; NODL-NEXT: and i32 {{.*}}, 1
+; NODL-NEXT: %R = icmp ne i32 {{.*}}, 0
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test4(
+; P32-NEXT: lshr i32 933, %X
+; P32-NEXT: and i32 {{.*}}, 1
+; P32-NEXT: %R = icmp ne i32 {{.*}}, 0
+; P32-NEXT: ret i1 %R
}
define i1 @test4_i16(i16 %X) {
@@ -52,11 +120,19 @@ define i1 @test4_i16(i16 %X) {
%Q = load i16* %P
%R = icmp sle i16 %Q, 73
ret i1 %R
-; CHECK: @test4_i16
-; CHECK-NEXT: lshr i16 933, %X
-; CHECK-NEXT: and i16 {{.*}}, 1
-; CHECK-NEXT: %R = icmp ne i16 {{.*}}, 0
-; CHECK-NEXT: ret i1 %R
+
+; NODL-LABEL: @test4_i16(
+; NODL-NEXT: lshr i16 933, %X
+; NODL-NEXT: and i16 {{.*}}, 1
+; NODL-NEXT: %R = icmp ne i16 {{.*}}, 0
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test4_i16(
+; P32-NEXT: sext i16 %X to i32
+; P32-NEXT: lshr i32 933, %1
+; P32-NEXT: and i32 {{.*}}, 1
+; P32-NEXT: %R = icmp ne i32 {{.*}}, 0
+; P32-NEXT: ret i1 %R
}
define i1 @test5(i32 %X) {
@@ -64,11 +140,17 @@ define i1 @test5(i32 %X) {
%Q = load i16* %P
%R = icmp eq i16 %Q, 69
ret i1 %R
-; CHECK: @test5
-; CHECK-NEXT: icmp eq i32 %X, 2
-; CHECK-NEXT: icmp eq i32 %X, 7
-; CHECK-NEXT: %R = or i1
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test5(
+; NODL-NEXT: icmp eq i32 %X, 2
+; NODL-NEXT: icmp eq i32 %X, 7
+; NODL-NEXT: %R = or i1
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test5(
+; P32-NEXT: icmp eq i32 %X, 2
+; P32-NEXT: icmp eq i32 %X, 7
+; P32-NEXT: %R = or i1
+; P32-NEXT: ret i1 %R
}
define i1 @test6(i32 %X) {
@@ -76,10 +158,15 @@ define i1 @test6(i32 %X) {
%Q = load double* %P
%R = fcmp ogt double %Q, 0.0
ret i1 %R
-; CHECK: @test6
-; CHECK-NEXT: add i32 %X, -1
-; CHECK-NEXT: %R = icmp ult i32 {{.*}}, 3
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test6(
+; NODL-NEXT: add i32 %X, -1
+; NODL-NEXT: %R = icmp ult i32 {{.*}}, 3
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test6(
+; P32-NEXT: add i32 %X, -1
+; P32-NEXT: %R = icmp ult i32 {{.*}}, 3
+; P32-NEXT: ret i1 %R
}
define i1 @test7(i32 %X) {
@@ -87,10 +174,15 @@ define i1 @test7(i32 %X) {
%Q = load double* %P
%R = fcmp olt double %Q, 0.0
ret i1 %R
-; CHECK: @test7
-; CHECK-NEXT: add i32 %X, -1
-; CHECK-NEXT: %R = icmp ugt i32 {{.*}}, 2
-; CHECK-NEXT: ret i1 %R
+; NODL-LABEL: @test7(
+; NODL-NEXT: add i32 %X, -1
+; NODL-NEXT: %R = icmp ugt i32 {{.*}}, 2
+; NODL-NEXT: ret i1 %R
+
+; P32-LABEL: @test7(
+; P32-NEXT: add i32 %X, -1
+; P32-NEXT: %R = icmp ugt i32 {{.*}}, 2
+; P32-NEXT: ret i1 %R
}
define i1 @test8(i32 %X) {
@@ -99,10 +191,15 @@ define i1 @test8(i32 %X) {
%R = and i16 %Q, 3
%S = icmp eq i16 %R, 0
ret i1 %S
-; CHECK: @test8
-; CHECK-NEXT: and i32 %X, -2
-; CHECK-NEXT: icmp eq i32 {{.*}}, 8
-; CHECK-NEXT: ret i1
+; NODL-LABEL: @test8(
+; NODL-NEXT: and i32 %X, -2
+; NODL-NEXT: icmp eq i32 {{.*}}, 8
+; NODL-NEXT: ret i1
+
+; P32-LABEL: @test8(
+; P32-NEXT: and i32 %X, -2
+; P32-NEXT: icmp eq i32 {{.*}}, 8
+; P32-NEXT: ret i1
}
@GA = internal constant [4 x { i32, i32 } ] [
@@ -117,8 +214,161 @@ define i1 @test9(i32 %X) {
%Q = load i32* %P
%R = icmp eq i32 %Q, 1
ret i1 %R
-; CHECK: @test9
-; CHECK-NEXT: add i32 %X, -1
-; CHECK-NEXT: icmp ult i32 {{.*}}, 2
-; CHECK-NEXT: ret i1
+; NODL-LABEL: @test9(
+; NODL-NEXT: add i32 %X, -1
+; NODL-NEXT: icmp ult i32 {{.*}}, 2
+; NODL-NEXT: ret i1
+
+; P32-LABEL: @test9(
+; P32-NEXT: add i32 %X, -1
+; P32-NEXT: icmp ult i32 {{.*}}, 2
+; P32-NEXT: ret i1
+}
+
+define i1 @test10_struct(i32 %x) {
+; NODL-LABEL: @test10_struct(
+; NODL: getelementptr inbounds %Foo* @GS, i32 %x, i32 0
+
+; P32-LABEL: @test10_struct(
+; P32: getelementptr inbounds %Foo* @GS, i32 %x, i32 0
+ %p = getelementptr inbounds %Foo* @GS, i32 %x, i32 0
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_noinbounds(i32 %x) {
+; NODL-LABEL: @test10_struct_noinbounds(
+; NODL: getelementptr %Foo* @GS, i32 %x, i32 0
+
+; P32-LABEL: @test10_struct_noinbounds(
+; P32: getelementptr %Foo* @GS, i32 %x, i32 0
+ %p = getelementptr %Foo* @GS, i32 %x, i32 0
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+; Test that the GEP indices are converted before we ever get here
+; Index < ptr size
+define i1 @test10_struct_i16(i16 %x){
+; NODL-LABEL: @test10_struct_i16(
+; NODL: getelementptr inbounds %Foo* @GS, i16 %x, i32 0
+
+; P32-LABEL: @test10_struct_i16(
+; P32: %1 = sext i16 %x to i32
+; P32: getelementptr inbounds %Foo* @GS, i32 %1, i32 0
+ %p = getelementptr inbounds %Foo* @GS, i16 %x, i32 0
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 0
+ ret i1 %r
+}
+
+; Test that the GEP indices are converted before we ever get here
+; Index > ptr size
+define i1 @test10_struct_i64(i64 %x){
+; NODL-LABEL: @test10_struct_i64(
+; NODL: getelementptr inbounds %Foo* @GS, i64 %x, i32 0
+
+; P32-LABEL: @test10_struct_i64(
+; P32: %1 = trunc i64 %x to i32
+; P32: getelementptr inbounds %Foo* @GS, i32 %1, i32 0
+ %p = getelementptr inbounds %Foo* @GS, i64 %x, i32 0
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 0
+ ret i1 %r
+}
+
+define i1 @test10_struct_noinbounds_i16(i16 %x) {
+; NODL-LABEL: @test10_struct_noinbounds_i16(
+; NODL: getelementptr %Foo* @GS, i16 %x, i32 0
+
+; P32-LABEL: @test10_struct_noinbounds_i16(
+; P32: %1 = sext i16 %x to i32
+; P32: getelementptr %Foo* @GS, i32 %1, i32 0
+ %p = getelementptr %Foo* @GS, i16 %x, i32 0
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 0
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr(i32 %x) {
+; NODL-LABEL: @test10_struct_arr(
+; NODL-NEXT: %r = icmp ne i32 %x, 1
+; NODL-NEXT: ret i1 %r
+
+; P32-LABEL: @test10_struct_arr(
+; P32-NEXT: %r = icmp ne i32 %x, 1
+; P32-NEXT: ret i1 %r
+ %p = getelementptr inbounds [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr_noinbounds(i32 %x) {
+; NODL-LABEL: @test10_struct_arr_noinbounds(
+; NODL-NEXT %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
+
+; P32-LABEL: @test10_struct_arr_noinbounds(
+; P32-NEXT %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
+ %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i32 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr_i16(i16 %x) {
+; NODL-LABEL: @test10_struct_arr_i16(
+; NODL-NEXT: %r = icmp ne i16 %x, 1
+; NODL-NEXT: ret i1 %r
+
+; P32-LABEL: @test10_struct_arr_i16(
+; P32-NEXT: %r = icmp ne i16 %x, 1
+; P32-NEXT: ret i1 %r
+ %p = getelementptr inbounds [4 x %Foo]* @GStructArr, i16 0, i16 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr_i64(i64 %x) {
+; NODL-LABEL: @test10_struct_arr_i64(
+; NODL-NEXT: %r = icmp ne i64 %x, 1
+; NODL-NEXT: ret i1 %r
+
+; P32-LABEL: @test10_struct_arr_i64(
+; P32-NEXT: trunc i64 %x to i32
+; P32-NEXT: %r = icmp ne i32 %1, 1
+; P32-NEXT: ret i1 %r
+ %p = getelementptr inbounds [4 x %Foo]* @GStructArr, i64 0, i64 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr_noinbounds_i16(i16 %x) {
+; NODL-LABEL: @test10_struct_arr_noinbounds_i16(
+; NODL-NEXT: %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i16 %x, i32 2
+
+; P32-LABEL: @test10_struct_arr_noinbounds_i16(
+; P32-NEXT: %r = icmp ne i16 %x, 1
+ %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i16 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
+}
+
+define i1 @test10_struct_arr_noinbounds_i64(i64 %x) {
+; FIXME: Should be no trunc?
+; NODL-LABEL: @test10_struct_arr_noinbounds_i64(
+; NODL-NEXT: %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i64 %x, i32 2
+
+; P32-LABEL: @test10_struct_arr_noinbounds_i64(
+; P32: %r = icmp ne i32 %1, 1
+; P32-NEXT: ret i1 %r
+ %p = getelementptr [4 x %Foo]* @GStructArr, i32 0, i64 %x, i32 2
+ %q = load i32* %p
+ %r = icmp eq i32 %q, 9
+ ret i1 %r
}
diff --git a/test/Transforms/InstCombine/load-select.ll b/test/Transforms/InstCombine/load-select.ll
index f3d83dc8210e..e8cbad335dea 100644
--- a/test/Transforms/InstCombine/load-select.ll
+++ b/test/Transforms/InstCombine/load-select.ll
@@ -5,7 +5,7 @@ target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-
@a = constant [2 x i32] [i32 3, i32 6] ; <[2 x i32]*> [#uses=2]
define i32 @b(i32 %y) nounwind readonly {
-; CHECK: @b
+; CHECK-LABEL: @b(
; CHECK-NOT: load
; CHECK: ret i32
entry:
diff --git a/test/Transforms/InstCombine/load3.ll b/test/Transforms/InstCombine/load3.ll
index db74426783c1..f79ef9a695c2 100644
--- a/test/Transforms/InstCombine/load3.ll
+++ b/test/Transforms/InstCombine/load3.ll
@@ -11,7 +11,7 @@ define i32 @test1(i32* %p) {
%x = load i32* %t1
%a = sub i32 %y, %x
ret i32 %a
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 0
}
@@ -22,7 +22,7 @@ define float @test2() {
%tmp = load float* bitcast ([4 x i8]* @.str to float*), align 1
ret float %tmp
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret float 0x3806965600000000
}
@@ -41,6 +41,6 @@ define void @test3() nounwind {
store i32 %l, i32* getelementptr ([36 x i32]* @rslts32, i32 29826161, i32 28), align 4
ret void
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: store i32 1, i32* getelementptr inbounds ([36 x i32]* @rslts32, i32 0, i32 0)
}
diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll
index cd12b29b1186..208520653848 100644
--- a/test/Transforms/InstCombine/malloc-free-delete.ll
+++ b/test/Transforms/InstCombine/malloc-free-delete.ll
@@ -1,7 +1,7 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
; PR1201
define i32 @main(i32 %argc, i8** %argv) {
-; CHECK: @main
+; CHECK-LABEL: @main(
%c_19 = alloca i8*
%malloc_206 = tail call i8* @malloc(i32 mul (i32 ptrtoint (i8* getelementptr (i8* null, i32 1) to i32), i32 10))
store i8* %malloc_206, i8** %c_19
@@ -16,7 +16,7 @@ declare noalias i8* @malloc(i32)
declare void @free(i8*)
define i1 @foo() {
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK-NEXT: ret i1 false
%m = call i8* @malloc(i32 1)
%z = icmp eq i8* %m, null
@@ -32,7 +32,7 @@ declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32,
declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind
define void @test3(i8* %src) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: ret void
%a = call noalias i8* @malloc(i32 10)
call void @llvm.lifetime.start(i64 10, i8* %a)
@@ -49,7 +49,7 @@ define void @test3(i8* %src) {
;; This used to crash.
define void @test4() {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: ret void
%A = call i8* @malloc(i32 16000)
%B = bitcast i8* %A to double*
@@ -58,7 +58,7 @@ define void @test4() {
ret void
}
-; CHECK: @test5
+; CHECK-LABEL: @test5(
define void @test5(i8* %ptr, i8** %esc) {
; CHECK-NEXT: call i8* @malloc
; CHECK-NEXT: call i8* @malloc
@@ -98,7 +98,7 @@ define void @test5(i8* %ptr, i8** %esc) {
;; Using simplifycfg will remove the empty basic block and the branch operation
;; Then, performing a dead elimination will remove the comparison.
;; This is what happens with -O1 and upper.
-; CHECK: @test6
+; CHECK-LABEL: @test6(
define void @test6(i8* %foo) minsize {
; CHECK: %tobool = icmp eq i8* %foo, null
;; Call to free moved
@@ -120,3 +120,27 @@ if.then: ; preds = %entry
if.end: ; preds = %entry, %if.then
ret void
}
+
+declare i8* @_ZnwmRKSt9nothrow_t(i64, i8*) nobuiltin
+declare void @_ZdlPvRKSt9nothrow_t(i8*, i8*) nobuiltin
+declare i32 @__gxx_personality_v0(...)
+declare void @_ZN1AC2Ev(i8* %this)
+
+; CHECK-LABEL: @test7(
+define void @test7() {
+entry:
+ %nt = alloca i8
+ ; CHECK-NOT: call {{.*}}@_ZnwmRKSt9nothrow_t(
+ %call.i = tail call i8* @_ZnwmRKSt9nothrow_t(i64 1, i8* %nt) builtin nounwind
+ invoke void @_ZN1AC2Ev(i8* undef)
+ to label %.noexc.i unwind label %lpad.i
+
+.noexc.i: ; preds = %entry
+ unreachable
+
+lpad.i: ; preds = %entry
+ %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) cleanup
+ ; CHECK-NOT: call {{.*}}@_ZdlPvRKSt9nothrow_t(
+ call void @_ZdlPvRKSt9nothrow_t(i8* %call.i, i8* %nt) builtin nounwind
+ resume { i8*, i32 } %0
+}
diff --git a/test/Transforms/InstCombine/memcmp-1.ll b/test/Transforms/InstCombine/memcmp-1.ll
index c97b201fc0e9..65349c6e6906 100644
--- a/test/Transforms/InstCombine/memcmp-1.ll
+++ b/test/Transforms/InstCombine/memcmp-1.ll
@@ -13,7 +13,7 @@ declare i32 @memcmp(i8*, i8*, i32)
; Check memcmp(mem, mem, size) -> 0.
define i32 @test_simplify1(i8* %mem, i32 %size) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @memcmp(i8* %mem, i8* %mem, i32 %size)
ret i32 %ret
; CHECK: ret i32 0
@@ -22,7 +22,7 @@ define i32 @test_simplify1(i8* %mem, i32 %size) {
; Check memcmp(mem1, mem2, 0) -> 0.
define i32 @test_simplify2(i8* %mem1, i8* %mem2) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 0)
ret i32 %ret
; CHECK: ret i32 0
@@ -31,7 +31,7 @@ define i32 @test_simplify2(i8* %mem1, i8* %mem2) {
;; Check memcmp(mem1, mem2, 1) -> *(unsigned char*)mem1 - *(unsigned char*)mem2.
define i32 @test_simplify3(i8* %mem1, i8* %mem2) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 1)
; CHECK: [[LOAD1:%[a-z]+]] = load i8* %mem1, align 1
; CHECK: [[ZEXT1:%[a-z]+]] = zext i8 [[LOAD1]] to i32
@@ -45,7 +45,7 @@ define i32 @test_simplify3(i8* %mem1, i8* %mem2) {
; Check memcmp(mem1, mem2, size) -> cnst, where all arguments are constants.
define i32 @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%mem1 = getelementptr [4 x i8]* @hel, i32 0, i32 0
%mem2 = getelementptr [8 x i8]* @hello_u, i32 0, i32 0
%ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
@@ -54,7 +54,7 @@ define i32 @test_simplify4() {
}
define i32 @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%mem1 = getelementptr [4 x i8]* @hel, i32 0, i32 0
%mem2 = getelementptr [4 x i8]* @foo, i32 0, i32 0
%ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
@@ -63,7 +63,7 @@ define i32 @test_simplify5() {
}
define i32 @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%mem1 = getelementptr [4 x i8]* @foo, i32 0, i32 0
%mem2 = getelementptr [4 x i8]* @hel, i32 0, i32 0
%ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
diff --git a/test/Transforms/InstCombine/memcmp-2.ll b/test/Transforms/InstCombine/memcmp-2.ll
index 3796117bc24c..bed62eb3fb95 100644
--- a/test/Transforms/InstCombine/memcmp-2.ll
+++ b/test/Transforms/InstCombine/memcmp-2.ll
@@ -9,7 +9,7 @@ declare i32* @memcmp(i8*, i8*, i32)
; Check that memcmp functions with the wrong prototype aren't simplified.
define i32* @test_no_simplify1(i8* %mem, i32 %size) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i32* @memcmp(i8* %mem, i8* %mem, i32 %size)
; CHECK-NEXT: call i32* @memcmp
ret i32* %ret
diff --git a/test/Transforms/InstCombine/memcpy-1.ll b/test/Transforms/InstCombine/memcpy-1.ll
index 65b79ad03df4..9efbcc8283d2 100644
--- a/test/Transforms/InstCombine/memcpy-1.ll
+++ b/test/Transforms/InstCombine/memcpy-1.ll
@@ -9,7 +9,7 @@ declare i8* @memcpy(i8*, i8*, i32)
; Check memcpy(mem1, mem2, size) -> llvm.memcpy(mem1, mem2, size, 1).
define i8* @test_simplify1(i8* %mem1, i8* %mem2, i32 %size) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i8* @memcpy(i8* %mem1, i8* %mem2, i32 %size)
; CHECK: call void @llvm.memcpy
ret i8* %ret
diff --git a/test/Transforms/InstCombine/memcpy-2.ll b/test/Transforms/InstCombine/memcpy-2.ll
index 4a8a02018f5e..a31854c01758 100644
--- a/test/Transforms/InstCombine/memcpy-2.ll
+++ b/test/Transforms/InstCombine/memcpy-2.ll
@@ -9,7 +9,7 @@ declare i8 @memcpy(i8*, i8*, i32)
; Check that memcpy functions with the wrong prototype aren't simplified.
define i8 @test_no_simplify1(i8* %mem1, i8* %mem2, i32 %size) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i8 @memcpy(i8* %mem1, i8* %mem2, i32 %size)
; CHECK: call i8 @memcpy
ret i8 %ret
diff --git a/test/Transforms/InstCombine/memcpy-from-global.ll b/test/Transforms/InstCombine/memcpy-from-global.ll
index 557b160a8785..58793ab431d1 100644
--- a/test/Transforms/InstCombine/memcpy-from-global.ll
+++ b/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -8,7 +8,7 @@ entry:
%lookupTable1 = bitcast [128 x float]* %lookupTable to i8* ; <i8*> [#uses=1]
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %lookupTable1, i8* bitcast ([128 x float]* @C.0.1248 to i8*), i64 512, i32 16, i1 false)
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NOT: alloca
; CHECK-NOT: call{{.*}}@llvm.memcpy
@@ -50,7 +50,7 @@ define void @test2() {
%a = bitcast %T* %A to i8*
%b = bitcast %T* %B to i8*
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; %A alloca is deleted
; CHECK-NEXT: alloca [124 x i8]
@@ -73,7 +73,7 @@ define void @test3() {
%a = bitcast %T* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
call void @bar(i8* %a) readonly
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: call void @bar(i8* getelementptr inbounds (%T* @G, i64 0, i32 0))
ret void
}
@@ -83,7 +83,7 @@ define void @test4() {
%a = bitcast %T* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
call void @baz(i8* byval %a)
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: call void @baz(i8* byval getelementptr inbounds (%T* @G, i64 0, i32 0))
ret void
}
@@ -95,7 +95,7 @@ define void @test5() {
call void @llvm.lifetime.start(i64 -1, i8* %a)
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%T* @G to i8*), i64 124, i32 4, i1 false)
call void @baz(i8* byval %a)
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: call void @baz(i8* byval getelementptr inbounds (%T* @G, i64 0, i32 0))
ret void
}
@@ -109,7 +109,7 @@ define void @test6() {
%a = bitcast %U* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast ([2 x %U]* @H to i8*), i64 20, i32 16, i1 false)
call void @bar(i8* %a) readonly
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: call void @bar(i8* bitcast ([2 x %U]* @H to i8*))
ret void
}
@@ -119,7 +119,7 @@ define void @test7() {
%a = bitcast %U* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%U* getelementptr ([2 x %U]* @H, i64 0, i32 0) to i8*), i64 20, i32 4, i1 false)
call void @bar(i8* %a) readonly
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: call void @bar(i8* bitcast ([2 x %U]* @H to i8*))
ret void
}
@@ -129,7 +129,7 @@ define void @test8() {
%a = bitcast %U* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%U* getelementptr ([2 x %U]* @H, i64 0, i32 1) to i8*), i64 20, i32 4, i1 false)
call void @bar(i8* %a) readonly
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: llvm.memcpy
; CHECK: bar
ret void
@@ -140,7 +140,7 @@ define void @test9() {
%a = bitcast %U* %A to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* bitcast (%U* getelementptr ([2 x %U]* @H, i64 0, i32 1) to i8*), i64 20, i32 4, i1 false)
call void @bar(i8* %a) readonly
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: call void @bar(i8* bitcast (%U* getelementptr inbounds ([2 x %U]* @H, i64 0, i64 1) to i8*))
ret void
}
diff --git a/test/Transforms/InstCombine/memcpy.ll b/test/Transforms/InstCombine/memcpy.ll
index 3a68ff95af82..f66e14c95af7 100644
--- a/test/Transforms/InstCombine/memcpy.ll
+++ b/test/Transforms/InstCombine/memcpy.ll
@@ -6,7 +6,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32,
define void @test1(i8* %a) {
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %a, i32 100, i32 1, i1 false)
ret void
-; CHECK: define void @test1
+; CHECK-LABEL: define void @test1(
; CHECK-NEXT: ret void
}
@@ -15,13 +15,13 @@ define void @test1(i8* %a) {
define void @test2(i8* %a) {
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %a, i32 100, i32 1, i1 true)
ret void
-; CHECK: define void @test2
+; CHECK-LABEL: define void @test2(
; CHECK-NEXT: call void @llvm.memcpy
}
define void @test3(i8* %d, i8* %s) {
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %d, i8* %s, i64 17179869184, i32 4, i1 false)
ret void
-; CHECK: define void @test3
+; CHECK-LABEL: define void @test3(
; CHECK-NEXT: call void @llvm.memcpy
}
diff --git a/test/Transforms/InstCombine/memcpy_chk-1.ll b/test/Transforms/InstCombine/memcpy_chk-1.ll
index 7c7d91808a37..9216ae7fe95a 100644
--- a/test/Transforms/InstCombine/memcpy_chk-1.ll
+++ b/test/Transforms/InstCombine/memcpy_chk-1.ll
@@ -16,7 +16,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; Check cases where dstlen >= len.
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
@@ -26,7 +26,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T3* @t3 to i8*
@@ -38,7 +38,7 @@ define void @test_simplify2() {
; Check cases where dstlen < len.
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = bitcast %struct.T3* @t3 to i8*
%src = bitcast %struct.T1* @t1 to i8*
@@ -48,7 +48,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2() {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
diff --git a/test/Transforms/InstCombine/memcpy_chk-2.ll b/test/Transforms/InstCombine/memcpy_chk-2.ll
index aa43029d47fc..320b54f82dc6 100644
--- a/test/Transforms/InstCombine/memcpy_chk-2.ll
+++ b/test/Transforms/InstCombine/memcpy_chk-2.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
@t2 = common global %struct.T2 zeroinitializer
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
diff --git a/test/Transforms/InstCombine/memmove-1.ll b/test/Transforms/InstCombine/memmove-1.ll
index 53f2f116c777..0445a60aeddb 100644
--- a/test/Transforms/InstCombine/memmove-1.ll
+++ b/test/Transforms/InstCombine/memmove-1.ll
@@ -9,7 +9,7 @@ declare i8* @memmove(i8*, i8*, i32)
; Check memmove(mem1, mem2, size) -> llvm.memmove(mem1, mem2, size, 1).
define i8* @test_simplify1(i8* %mem1, i8* %mem2, i32 %size) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i8* @memmove(i8* %mem1, i8* %mem2, i32 %size)
; CHECK: call void @llvm.memmove
ret i8* %ret
diff --git a/test/Transforms/InstCombine/memmove-2.ll b/test/Transforms/InstCombine/memmove-2.ll
index 23887bce31d8..b20e96bc5555 100644
--- a/test/Transforms/InstCombine/memmove-2.ll
+++ b/test/Transforms/InstCombine/memmove-2.ll
@@ -9,7 +9,7 @@ declare i8 @memmove(i8*, i8*, i32)
; Check that memmove functions with the wrong prototype aren't simplified.
define i8 @test_no_simplify1(i8* %mem1, i8* %mem2, i32 %size) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i8 @memmove(i8* %mem1, i8* %mem2, i32 %size)
; CHECK: call i8 @memmove
ret i8 %ret
diff --git a/test/Transforms/InstCombine/memmove_chk-1.ll b/test/Transforms/InstCombine/memmove_chk-1.ll
index f9ff9a103a30..6d93bbbf959e 100644
--- a/test/Transforms/InstCombine/memmove_chk-1.ll
+++ b/test/Transforms/InstCombine/memmove_chk-1.ll
@@ -16,7 +16,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; Check cases where dstlen >= len.
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
@@ -26,7 +26,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T3* @t3 to i8*
@@ -38,7 +38,7 @@ define void @test_simplify2() {
; Check cases where dstlen < len.
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = bitcast %struct.T3* @t3 to i8*
%src = bitcast %struct.T1* @t1 to i8*
@@ -48,7 +48,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2() {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
diff --git a/test/Transforms/InstCombine/memmove_chk-2.ll b/test/Transforms/InstCombine/memmove_chk-2.ll
index f0a915fde2e9..adadf905a588 100644
--- a/test/Transforms/InstCombine/memmove_chk-2.ll
+++ b/test/Transforms/InstCombine/memmove_chk-2.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
@t2 = common global %struct.T2 zeroinitializer
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = bitcast %struct.T1* @t1 to i8*
%src = bitcast %struct.T2* @t2 to i8*
diff --git a/test/Transforms/InstCombine/memset-1.ll b/test/Transforms/InstCombine/memset-1.ll
index 48b433e137c0..991567d6b597 100644
--- a/test/Transforms/InstCombine/memset-1.ll
+++ b/test/Transforms/InstCombine/memset-1.ll
@@ -9,7 +9,7 @@ declare i8* @memset(i8*, i32, i32)
; Check memset(mem1, val, size) -> llvm.memset(mem1, val, size, 1).
define i8* @test_simplify1(i8* %mem, i32 %val, i32 %size) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i8* @memset(i8* %mem, i32 %val, i32 %size)
; CHECK: call void @llvm.memset
ret i8* %ret
diff --git a/test/Transforms/InstCombine/memset-2.ll b/test/Transforms/InstCombine/memset-2.ll
index 8a9033302d04..5e446cb0ee00 100644
--- a/test/Transforms/InstCombine/memset-2.ll
+++ b/test/Transforms/InstCombine/memset-2.ll
@@ -9,7 +9,7 @@ declare i8 @memset(i8*, i32, i32)
; Check that memset functions with the wrong prototype aren't simplified.
define i8 @test_no_simplify1(i8* %mem, i32 %val, i32 %size) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i8 @memset(i8* %mem, i32 %val, i32 %size)
; CHECK: call i8 @memset
ret i8 %ret
diff --git a/test/Transforms/InstCombine/memset_chk-1.ll b/test/Transforms/InstCombine/memset_chk-1.ll
index be4c1cfccdb2..47cc7db998e4 100644
--- a/test/Transforms/InstCombine/memset_chk-1.ll
+++ b/test/Transforms/InstCombine/memset_chk-1.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
; Check cases where dstlen >= len.
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call void @llvm.memset.p0i8.i64
@@ -21,7 +21,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call void @llvm.memset.p0i8.i64
@@ -30,7 +30,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call void @llvm.memset.p0i8.i64
@@ -41,7 +41,7 @@ define void @test_simplify3() {
; Check cases where dstlen < len.
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call i8* @__memset_chk
@@ -50,7 +50,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2() {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call i8* @__memset_chk
diff --git a/test/Transforms/InstCombine/memset_chk-2.ll b/test/Transforms/InstCombine/memset_chk-2.ll
index 60fbf163c212..bb4f772785e3 100644
--- a/test/Transforms/InstCombine/memset_chk-2.ll
+++ b/test/Transforms/InstCombine/memset_chk-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
@t = common global %struct.T zeroinitializer
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = bitcast %struct.T* @t to i8*
; CHECK-NEXT: call i8* @__memset_chk
diff --git a/test/Transforms/InstCombine/merge-icmp.ll b/test/Transforms/InstCombine/merge-icmp.ll
index 00020b157e0f..b021fe0429a5 100644
--- a/test/Transforms/InstCombine/merge-icmp.ll
+++ b/test/Transforms/InstCombine/merge-icmp.ll
@@ -8,7 +8,7 @@ define i1 @test1(i16* %x) {
%cmp2 = icmp eq i16 %and, 17664
%or = and i1 %cmp1, %cmp2
ret i1 %or
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: load i16
; CHECK-NEXT: icmp eq i16 %load, 17791
; CHECK-NEXT: ret i1
@@ -22,7 +22,7 @@ define i1 @test2(i16* %x) {
%cmp2 = icmp eq i8 %trunc, 69
%or = and i1 %cmp1, %cmp2
ret i1 %or
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: load i16
; CHECK-NEXT: icmp eq i16 %load, 32581
; CHECK-NEXT: ret i1
diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll
index 16213b8628ca..94fc1183c55a 100644
--- a/test/Transforms/InstCombine/mul.ll
+++ b/test/Transforms/InstCombine/mul.ll
@@ -2,14 +2,14 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @test1(i32 %A) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
%B = mul i32 %A, 1 ; <i32> [#uses=1]
ret i32 %B
; CHECK: ret i32 %A
}
define i32 @test2(i32 %A) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; Should convert to an add instruction
%B = mul i32 %A, 2 ; <i32> [#uses=1]
ret i32 %B
@@ -17,7 +17,7 @@ define i32 @test2(i32 %A) {
}
define i32 @test3(i32 %A) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; This should disappear entirely
%B = mul i32 %A, 0 ; <i32> [#uses=1]
ret i32 %B
@@ -25,7 +25,7 @@ define i32 @test3(i32 %A) {
}
define double @test4(double %A) {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; This is safe for FP
%B = fmul double 1.000000e+00, %A ; <double> [#uses=1]
ret double %B
@@ -33,14 +33,14 @@ define double @test4(double %A) {
}
define i32 @test5(i32 %A) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
%B = mul i32 %A, 8 ; <i32> [#uses=1]
ret i32 %B
; CHECK: shl i32 %A, 3
}
define i8 @test6(i8 %A) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
%B = mul i8 %A, 8 ; <i8> [#uses=1]
%C = mul i8 %B, 8 ; <i8> [#uses=1]
ret i8 %C
@@ -48,28 +48,28 @@ define i8 @test6(i8 %A) {
}
define i32 @test7(i32 %i) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
%tmp = mul i32 %i, -1 ; <i32> [#uses=1]
ret i32 %tmp
; CHECK: sub i32 0, %i
}
define i64 @test8(i64 %i) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
%j = mul i64 %i, -1 ; <i64> [#uses=1]
ret i64 %j
; CHECK: sub i64 0, %i
}
define i32 @test9(i32 %i) {
-; CHECK: @test9
+; CHECK-LABEL: @test9(
%j = mul i32 %i, -1 ; <i32> [#uses=1]
ret i32 %j
; CHECK: sub i32 0, %i
}
define i32 @test10(i32 %a, i32 %b) {
-; CHECK: @test10
+; CHECK-LABEL: @test10(
%c = icmp slt i32 %a, 0 ; <i1> [#uses=1]
%d = zext i1 %c to i32 ; <i32> [#uses=1]
; e = b & (a >> 31)
@@ -81,7 +81,7 @@ define i32 @test10(i32 %a, i32 %b) {
}
define i32 @test11(i32 %a, i32 %b) {
-; CHECK: @test11
+; CHECK-LABEL: @test11(
%c = icmp sle i32 %a, -1 ; <i1> [#uses=1]
%d = zext i1 %c to i32 ; <i32> [#uses=1]
; e = b & (a >> 31)
@@ -93,7 +93,7 @@ define i32 @test11(i32 %a, i32 %b) {
}
define i32 @test12(i32 %a, i32 %b) {
-; CHECK: @test12
+; CHECK-LABEL: @test12(
%c = icmp ugt i32 %a, 2147483647 ; <i1> [#uses=1]
%d = zext i1 %c to i32 ; <i32> [#uses=1]
%e = mul i32 %d, %b ; <i32> [#uses=1]
@@ -106,7 +106,7 @@ define i32 @test12(i32 %a, i32 %b) {
; PR2642
define internal void @test13(<4 x float>*) {
-; CHECK: @test13
+; CHECK-LABEL: @test13(
load <4 x float>* %0, align 1
fmul <4 x float> %2, < float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 >
store <4 x float> %3, <4 x float>* %0, align 1
@@ -115,7 +115,7 @@ define internal void @test13(<4 x float>*) {
}
define <16 x i8> @test14(<16 x i8> %a) {
-; CHECK: @test14
+; CHECK-LABEL: @test14(
%b = mul <16 x i8> %a, zeroinitializer
ret <16 x i8> %b
; CHECK-NEXT: ret <16 x i8> zeroinitializer
@@ -123,7 +123,7 @@ define <16 x i8> @test14(<16 x i8> %a) {
; rdar://7293527
define i32 @test15(i32 %A, i32 %B) {
-; CHECK: @test15
+; CHECK-LABEL: @test15(
entry:
%shl = shl i32 1, %B
%m = mul i32 %shl, %A
@@ -133,7 +133,7 @@ entry:
; X * Y (when Y is 0 or 1) --> x & (0-Y)
define i32 @test16(i32 %b, i1 %c) {
-; CHECK: @test16
+; CHECK-LABEL: @test16(
%d = zext i1 %c to i32 ; <i32> [#uses=1]
; e = b & (a >> 31)
%e = mul i32 %d, %b ; <i32> [#uses=1]
@@ -144,7 +144,7 @@ define i32 @test16(i32 %b, i1 %c) {
; X * Y (when Y is 0 or 1) --> x & (0-Y)
define i32 @test17(i32 %a, i32 %b) {
-; CHECK: @test17
+; CHECK-LABEL: @test17(
%a.lobit = lshr i32 %a, 31
%e = mul i32 %a.lobit, %b
ret i32 %e
@@ -154,7 +154,7 @@ define i32 @test17(i32 %a, i32 %b) {
}
define i32 @test18(i32 %A, i32 %B) {
-; CHECK: @test18
+; CHECK-LABEL: @test18(
%C = and i32 %A, 1
%D = and i32 %B, 1
@@ -168,7 +168,7 @@ declare {i32, i1} @llvm.smul.with.overflow.i32(i32, i32)
declare void @use(i1)
define i32 @test19(i32 %A, i32 %B) {
-; CHECK: @test19
+; CHECK-LABEL: @test19(
%C = and i32 %A, 1
%D = and i32 %B, 1
diff --git a/test/Transforms/InstCombine/multi-size-address-space-pointer.ll b/test/Transforms/InstCombine/multi-size-address-space-pointer.ll
new file mode 100644
index 000000000000..2d88bed4e7bf
--- /dev/null
+++ b/test/Transforms/InstCombine/multi-size-address-space-pointer.ll
@@ -0,0 +1,112 @@
+; RUN: opt -S -instcombine %s -o - | FileCheck %s
+target datalayout = "e-p:32:32:32-p1:64:64:64-p2:8:8:8-p3:16:16:16-p4:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
+
+
+define i32 @test_as0(i32 addrspace(0)* %a) {
+; CHECK-LABEL: @test_as0(
+; CHECK: %arrayidx = getelementptr i32* %a, i32 1
+ %arrayidx = getelementptr i32 addrspace(0)* %a, i64 1
+ %y = load i32 addrspace(0)* %arrayidx, align 4
+ ret i32 %y
+}
+
+define i32 @test_as1(i32 addrspace(1)* %a) {
+; CHECK-LABEL: @test_as1(
+; CHECK: %arrayidx = getelementptr i32 addrspace(1)* %a, i64 1
+ %arrayidx = getelementptr i32 addrspace(1)* %a, i32 1
+ %y = load i32 addrspace(1)* %arrayidx, align 4
+ ret i32 %y
+}
+
+define i32 @test_as2(i32 addrspace(2)* %a) {
+; CHECK-LABEL: @test_as2(
+; CHECK: %arrayidx = getelementptr i32 addrspace(2)* %a, i8 1
+ %arrayidx = getelementptr i32 addrspace(2)* %a, i32 1
+ %y = load i32 addrspace(2)* %arrayidx, align 4
+ ret i32 %y
+}
+
+define i32 @test_as3(i32 addrspace(3)* %a) {
+; CHECK-LABEL: @test_as3(
+; CHECK: %arrayidx = getelementptr i32 addrspace(3)* %a, i16 1
+ %arrayidx = getelementptr i32 addrspace(3)* %a, i32 1
+ %y = load i32 addrspace(3)* %arrayidx, align 4
+ ret i32 %y
+}
+
+define i32 @test_combine_ptrtoint(i32 addrspace(2)* %a) {
+; CHECK-LABEL: @test_combine_ptrtoint(
+; CHECK-NEXT: %y = load i32 addrspace(2)* %a
+; CHECK-NEXT: ret i32 %y
+ %cast = ptrtoint i32 addrspace(2)* %a to i8
+ %castback = inttoptr i8 %cast to i32 addrspace(2)*
+ %y = load i32 addrspace(2)* %castback, align 4
+ ret i32 %y
+}
+
+define i8 @test_combine_inttoptr(i8 %a) {
+; CHECK-LABEL: @test_combine_inttoptr(
+; CHECK-NEXT: ret i8 %a
+ %cast = inttoptr i8 %a to i32 addrspace(2)*
+ %castback = ptrtoint i32 addrspace(2)* %cast to i8
+ ret i8 %castback
+}
+
+define i32 @test_combine_vector_ptrtoint(<2 x i32 addrspace(2)*> %a) {
+; CHECK-LABEL: @test_combine_vector_ptrtoint(
+; CHECK-NEXT: %p = extractelement <2 x i32 addrspace(2)*> %a, i32 0
+; CHECK-NEXT: %y = load i32 addrspace(2)* %p, align 4
+; CHECK-NEXT: ret i32 %y
+ %cast = ptrtoint <2 x i32 addrspace(2)*> %a to <2 x i8>
+ %castback = inttoptr <2 x i8> %cast to <2 x i32 addrspace(2)*>
+ %p = extractelement <2 x i32 addrspace(2)*> %castback, i32 0
+ %y = load i32 addrspace(2)* %p, align 4
+ ret i32 %y
+}
+
+define <2 x i8> @test_combine_vector_inttoptr(<2 x i8> %a) {
+; CHECK-LABEL: @test_combine_vector_inttoptr(
+; CHECK-NEXT: ret <2 x i8> %a
+ %cast = inttoptr <2 x i8> %a to <2 x i32 addrspace(2)*>
+ %castback = ptrtoint <2 x i32 addrspace(2)*> %cast to <2 x i8>
+ ret <2 x i8> %castback
+}
+
+; Check that the GEP index is changed to the address space integer type (i64 -> i8)
+define i32 addrspace(2)* @shrink_gep_constant_index_64_as2(i32 addrspace(2)* %p) {
+; CHECK-LABEL: @shrink_gep_constant_index_64_as2(
+; CHECK-NEXT: getelementptr i32 addrspace(2)* %p, i8 1
+ %ret = getelementptr i32 addrspace(2)* %p, i64 1
+ ret i32 addrspace(2)* %ret
+}
+
+define i32 addrspace(2)* @shrink_gep_constant_index_32_as2(i32 addrspace(2)* %p) {
+; CHECK-LABEL: @shrink_gep_constant_index_32_as2(
+; CHECK-NEXT: getelementptr i32 addrspace(2)* %p, i8 1
+ %ret = getelementptr i32 addrspace(2)* %p, i32 1
+ ret i32 addrspace(2)* %ret
+}
+
+define i32 addrspace(3)* @shrink_gep_constant_index_64_as3(i32 addrspace(3)* %p) {
+; CHECK-LABEL: @shrink_gep_constant_index_64_as3(
+; CHECK-NEXT: getelementptr i32 addrspace(3)* %p, i16 1
+ %ret = getelementptr i32 addrspace(3)* %p, i64 1
+ ret i32 addrspace(3)* %ret
+}
+
+define i32 addrspace(2)* @shrink_gep_variable_index_64_as2(i32 addrspace(2)* %p, i64 %idx) {
+; CHECK-LABEL: @shrink_gep_variable_index_64_as2(
+; CHECK-NEXT: %1 = trunc i64 %idx to i8
+; CHECK-NEXT: getelementptr i32 addrspace(2)* %p, i8 %1
+ %ret = getelementptr i32 addrspace(2)* %p, i64 %idx
+ ret i32 addrspace(2)* %ret
+}
+
+define i32 addrspace(1)* @grow_gep_variable_index_8_as1(i32 addrspace(1)* %p, i8 %idx) {
+; CHECK-LABEL: @grow_gep_variable_index_8_as1(
+; CHECK-NEXT: %1 = sext i8 %idx to i64
+; CHECK-NEXT: getelementptr i32 addrspace(1)* %p, i64 %1
+ %ret = getelementptr i32 addrspace(1)* %p, i8 %idx
+ ret i32 addrspace(1)* %ret
+}
+
diff --git a/test/Transforms/InstCombine/no-negzero.ll b/test/Transforms/InstCombine/no-negzero.ll
index f295130b0ea4..4ed283603446 100644
--- a/test/Transforms/InstCombine/no-negzero.ll
+++ b/test/Transforms/InstCombine/no-negzero.ll
@@ -4,7 +4,7 @@
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin9.8"
-; CHECK: @mysqrt
+; CHECK-LABEL: @mysqrt(
; CHECK-NOT: fadd
; CHECK: ret
define double @mysqrt(double %x) nounwind {
diff --git a/test/Transforms/InstCombine/nsw.ll b/test/Transforms/InstCombine/nsw.ll
index 0140c2f80122..0bed76717ce9 100644
--- a/test/Transforms/InstCombine/nsw.ll
+++ b/test/Transforms/InstCombine/nsw.ll
@@ -1,6 +1,6 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: @sub1
+; CHECK-LABEL: @sub1(
; CHECK: %y = sub i32 0, %x
; CHECK: %z = sdiv i32 %y, 337
; CHECK: ret i32 %z
@@ -10,7 +10,7 @@ define i32 @sub1(i32 %x) {
ret i32 %z
}
-; CHECK: @sub2
+; CHECK-LABEL: @sub2(
; CHECK: %z = sdiv i32 %x, -337
; CHECK: ret i32 %z
define i32 @sub2(i32 %x) {
@@ -19,7 +19,7 @@ define i32 @sub2(i32 %x) {
ret i32 %z
}
-; CHECK: @shl_icmp
+; CHECK-LABEL: @shl_icmp(
; CHECK: %B = icmp eq i64 %X, 0
; CHECK: ret i1 %B
define i1 @shl_icmp(i64 %X) nounwind {
@@ -28,7 +28,7 @@ define i1 @shl_icmp(i64 %X) nounwind {
ret i1 %B
}
-; CHECK: @shl1
+; CHECK-LABEL: @shl1(
; CHECK: %B = shl nuw nsw i64 %A, 8
; CHECK: ret i64 %B
define i64 @shl1(i64 %X, i64* %P) nounwind {
@@ -38,7 +38,7 @@ define i64 @shl1(i64 %X, i64* %P) nounwind {
ret i64 %B
}
-; CHECK: @preserve1
+; CHECK-LABEL: @preserve1(
; CHECK: add nsw i32 %x, 5
define i32 @preserve1(i32 %x) nounwind {
%add = add nsw i32 %x, 2
@@ -46,7 +46,7 @@ define i32 @preserve1(i32 %x) nounwind {
ret i32 %add3
}
-; CHECK: @nopreserve1
+; CHECK-LABEL: @nopreserve1(
; CHECK: add i8 %x, -126
define i8 @nopreserve1(i8 %x) nounwind {
%add = add nsw i8 %x, 127
@@ -54,7 +54,7 @@ define i8 @nopreserve1(i8 %x) nounwind {
ret i8 %add3
}
-; CHECK: @nopreserve2
+; CHECK-LABEL: @nopreserve2(
; CHECK: add i8 %x, 3
define i8 @nopreserve2(i8 %x) nounwind {
%add = add i8 %x, 1
@@ -62,7 +62,7 @@ define i8 @nopreserve2(i8 %x) nounwind {
ret i8 %add3
}
-; CHECK: @nopreserve3
+; CHECK-LABEL: @nopreserve3(
; CHECK: add i8 %A, %B
; CHECK: add i8
define i8 @nopreserve3(i8 %A, i8 %B) nounwind {
@@ -72,7 +72,7 @@ define i8 @nopreserve3(i8 %A, i8 %B) nounwind {
ret i8 %add
}
-; CHECK: @nopreserve4
+; CHECK-LABEL: @nopreserve4(
; CHECK: add i8 %A, %B
; CHECK: add i8
define i8 @nopreserve4(i8 %A, i8 %B) nounwind {
diff --git a/test/Transforms/InstCombine/objsize-64.ll b/test/Transforms/InstCombine/objsize-64.ll
index 530e1234b4a6..5046724038a3 100644
--- a/test/Transforms/InstCombine/objsize-64.ll
+++ b/test/Transforms/InstCombine/objsize-64.ll
@@ -7,7 +7,7 @@ declare i32 @__gxx_personality_v0(...)
declare void @__cxa_call_unexpected(i8*)
declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly
-; CHECK: @f1
+; CHECK-LABEL: @f1(
define i64 @f1(i8 **%esc) {
%call = call i8* @malloc(i32 4)
store i8* %call, i8** %esc
@@ -17,7 +17,7 @@ define i64 @f1(i8 **%esc) {
}
-; CHECK: @f2
+; CHECK-LABEL: @f2(
define i64 @f2(i8** %esc) nounwind uwtable ssp {
entry:
; CHECK: invoke noalias i8* @_Znwm(i64 13)
diff --git a/test/Transforms/InstCombine/objsize-address-space.ll b/test/Transforms/InstCombine/objsize-address-space.ll
new file mode 100644
index 000000000000..9cb688423960
--- /dev/null
+++ b/test/Transforms/InstCombine/objsize-address-space.ll
@@ -0,0 +1,80 @@
+; RUN: opt -S -instcombine -o - %s | FileCheck %s
+target datalayout = "e-p:32:32:32-p1:64:64:64-p2:8:8:8-p3:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
+
+declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p1i8(i8 addrspace(1)*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p2i8(i8 addrspace(2)*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)*, i1) nounwind readonly
+declare i16 @llvm.objectsize.i16.p3i8(i8 addrspace(3)*, i1) nounwind readonly
+
+@array_as2 = private addrspace(2) global [60 x i8] zeroinitializer, align 4
+
+@array_as1_pointers = private global [10 x i32 addrspace(1)*] zeroinitializer, align 4
+@array_as2_pointers = private global [24 x i32 addrspace(2)*] zeroinitializer, align 4
+@array_as3_pointers = private global [42 x i32 addrspace(3)*] zeroinitializer, align 4
+
+@array_as2_as1_pointer_pointers = private global [16 x i32 addrspace(2)* addrspace(1)*] zeroinitializer, align 4
+
+
+@a_as3 = private addrspace(3) global [60 x i8] zeroinitializer, align 1
+
+define i32 @foo_as3() nounwind {
+; CHECK-LABEL: @foo_as3(
+; CHECK-NEXT: ret i32 60
+ %1 = call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_as3, i32 0, i32 0), i1 false)
+ ret i32 %1
+}
+
+define i16 @foo_as3_i16() nounwind {
+; CHECK-LABEL: @foo_as3_i16(
+; CHECK-NEXT: ret i16 60
+ %1 = call i16 @llvm.objectsize.i16.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_as3, i32 0, i32 0), i1 false)
+ ret i16 %1
+}
+
+@a_alias = alias weak [60 x i8] addrspace(3)* @a_as3
+define i32 @foo_alias() nounwind {
+ %1 = call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_alias, i32 0, i32 0), i1 false)
+ ret i32 %1
+}
+
+define i32 @array_as2_size() {
+; CHECK-LABEL: @array_as2_size(
+; CHECK-NEXT: ret i32 60
+ %bc = bitcast [60 x i8] addrspace(2)* @array_as2 to i8 addrspace(2)*
+ %1 = call i32 @llvm.objectsize.i32.p2i8(i8 addrspace(2)* %bc, i1 false)
+ ret i32 %1
+}
+
+define i32 @pointer_array_as1() {
+; CHECK-LABEL: @pointer_array_as1(
+; CHECK-NEXT: ret i32 80
+ %bc = addrspacecast [10 x i32 addrspace(1)*]* @array_as1_pointers to i8 addrspace(1)*
+ %1 = call i32 @llvm.objectsize.i32.p1i8(i8 addrspace(1)* %bc, i1 false)
+ ret i32 %1
+}
+
+define i32 @pointer_array_as2() {
+; CHECK-LABEL: @pointer_array_as2(
+; CHECK-NEXT: ret i32 24
+ %bc = bitcast [24 x i32 addrspace(2)*]* @array_as2_pointers to i8*
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
+ ret i32 %1
+}
+
+define i32 @pointer_array_as3() {
+; CHECK-LABEL: @pointer_array_as3(
+; CHECK-NEXT: ret i32 84
+ %bc = bitcast [42 x i32 addrspace(3)*]* @array_as3_pointers to i8*
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
+ ret i32 %1
+}
+
+define i32 @pointer_pointer_array_as2_as1() {
+; CHECK-LABEL: @pointer_pointer_array_as2_as1(
+; CHECK-NEXT: ret i32 128
+ %bc = bitcast [16 x i32 addrspace(2)* addrspace(1)*]* @array_as2_as1_pointer_pointers to i8*
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
+ ret i32 %1
+}
+
diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll
index 122c6501a3f5..645903299c86 100644
--- a/test/Transforms/InstCombine/objsize.ll
+++ b/test/Transforms/InstCombine/objsize.ll
@@ -5,19 +5,18 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@a = private global [60 x i8] zeroinitializer, align 1 ; <[60 x i8]*>
@.str = private constant [8 x i8] c"abcdefg\00" ; <[8 x i8]*>
-
define i32 @foo() nounwind {
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK-NEXT: ret i32 60
- %1 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
ret i32 %1
}
define i8* @bar() nounwind {
-; CHECK: @bar
+; CHECK-LABEL: @bar(
entry:
%retval = alloca i8*
- %0 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
+ %0 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
%cmp = icmp ne i32 %0, -1
; CHECK: br i1 true
br i1 %cmp, label %cond.true, label %cond.false
@@ -32,27 +31,27 @@ cond.false:
}
define i32 @f() nounwind {
-; CHECK: @f
+; CHECK-LABEL: @f(
; CHECK-NEXT: ret i32 0
- %1 = call i32 @llvm.objectsize.i32(i8* getelementptr ([60 x i8]* @a, i32 1, i32 0), i1 false)
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr ([60 x i8]* @a, i32 1, i32 0), i1 false)
ret i32 %1
}
@window = external global [0 x i8]
define i1 @baz() nounwind {
-; CHECK: @baz
+; CHECK-LABEL: @baz(
; CHECK-NEXT: objectsize
- %1 = tail call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 0), i1 false)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 0), i1 false)
%2 = icmp eq i32 %1, -1
ret i1 %2
}
define void @test1(i8* %q, i32 %x) nounwind noinline {
-; CHECK: @test1
-; CHECK: objectsize.i32
+; CHECK-LABEL: @test1(
+; CHECK: objectsize.i32.p0i8
entry:
- %0 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 10), i1 false) ; <i64> [#uses=1]
+ %0 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 10), i1 false) ; <i64> [#uses=1]
%1 = icmp eq i32 %0, -1 ; <i1> [#uses=1]
br i1 %1, label %"47", label %"46"
@@ -66,9 +65,9 @@ entry:
@.str5 = private constant [9 x i32] [i32 97, i32 98, i32 99, i32 100, i32 0, i32
101, i32 102, i32 103, i32 0], align 4
define i32 @test2() nounwind {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: ret i32 34
- %1 = call i32 @llvm.objectsize.i32(i8* getelementptr (i8* bitcast ([9 x i32]* @.str5 to i8*), i32 2), i1 false)
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr (i8* bitcast ([9 x i32]* @.str5 to i8*), i32 2), i1 false)
ret i32 %1
}
@@ -77,19 +76,19 @@ define i32 @test2() nounwind {
declare i8* @__memcpy_chk(i8*, i8*, i32, i32) nounwind
-declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
declare i8* @__inline_memcpy_chk(i8*, i8*, i32) nounwind inlinehint
define void @test3() nounwind {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
entry:
br i1 undef, label %bb11, label %bb12
bb11:
%0 = getelementptr inbounds float* getelementptr inbounds ([480 x float]* @array, i32 0, i32 128), i32 -127 ; <float*> [#uses=1]
%1 = bitcast float* %0 to i8* ; <i8*> [#uses=1]
- %2 = call i32 @llvm.objectsize.i32(i8* %1, i1 false) ; <i32> [#uses=1]
+ %2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1, i1 false) ; <i32> [#uses=1]
%3 = call i8* @__memcpy_chk(i8* undef, i8* undef, i32 512, i32 %2) nounwind ; <i8*> [#uses=0]
; CHECK: unreachable
unreachable
@@ -107,11 +106,11 @@ bb12:
%struct.data = type { [100 x i32], [100 x i32], [1024 x i8] }
define i32 @test4(i8** %esc) nounwind ssp {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
entry:
%0 = alloca %struct.data, align 8
%1 = bitcast %struct.data* %0 to i8*
- %2 = call i32 @llvm.objectsize.i32(i8* %1, i1 false) nounwind
+ %2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1, i1 false) nounwind
; CHECK-NOT: @llvm.objectsize
; CHECK: @llvm.memset.p0i8.i32(i8* %1, i8 0, i32 1824, i32 8, i1 false)
%3 = call i8* @__memset_chk(i8* %1, i32 0, i32 1824, i32 %2) nounwind
@@ -123,10 +122,10 @@ entry:
@s = external global i8*
define i8* @test5(i32 %n) nounwind ssp {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
entry:
%0 = tail call noalias i8* @malloc(i32 20) nounwind
- %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false)
%2 = load i8** @s, align 8
; CHECK-NOT: @llvm.objectsize
; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false)
@@ -135,10 +134,10 @@ entry:
}
define void @test6(i32 %n) nounwind ssp {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
entry:
%0 = tail call noalias i8* @malloc(i32 20) nounwind
- %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false)
%2 = load i8** @s, align 8
; CHECK-NOT: @llvm.objectsize
; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 30, i32 20)
@@ -151,11 +150,11 @@ declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
declare noalias i8* @malloc(i32) nounwind
define i32 @test7(i8** %esc) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
%alloc = call noalias i8* @malloc(i32 48) nounwind
store i8* %alloc, i8** %esc
%gep = getelementptr inbounds i8* %alloc, i32 16
- %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
+ %objsize = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 false) nounwind readonly
; CHECK: ret i32 32
ret i32 %objsize
}
@@ -163,11 +162,11 @@ define i32 @test7(i8** %esc) {
declare noalias i8* @calloc(i32, i32) nounwind
define i32 @test8(i8** %esc) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
%alloc = call noalias i8* @calloc(i32 5, i32 7) nounwind
store i8* %alloc, i8** %esc
%gep = getelementptr inbounds i8* %alloc, i32 5
- %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
+ %objsize = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 false) nounwind readonly
; CHECK: ret i32 30
ret i32 %objsize
}
@@ -175,52 +174,52 @@ define i32 @test8(i8** %esc) {
declare noalias i8* @strdup(i8* nocapture) nounwind
declare noalias i8* @strndup(i8* nocapture, i32) nounwind
-; CHECK: @test9
+; CHECK-LABEL: @test9(
define i32 @test9(i8** %esc) {
%call = tail call i8* @strdup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0)) nounwind
store i8* %call, i8** %esc, align 8
- %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
; CHECK: ret i32 8
ret i32 %1
}
-; CHECK: @test10
+; CHECK-LABEL: @test10(
define i32 @test10(i8** %esc) {
%call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 3) nounwind
store i8* %call, i8** %esc, align 8
- %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
; CHECK: ret i32 4
ret i32 %1
}
-; CHECK: @test11
+; CHECK-LABEL: @test11(
define i32 @test11(i8** %esc) {
%call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 7) nounwind
store i8* %call, i8** %esc, align 8
- %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
; CHECK: ret i32 8
ret i32 %1
}
-; CHECK: @test12
+; CHECK-LABEL: @test12(
define i32 @test12(i8** %esc) {
%call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 8) nounwind
store i8* %call, i8** %esc, align 8
- %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
; CHECK: ret i32 8
ret i32 %1
}
-; CHECK: @test13
+; CHECK-LABEL: @test13(
define i32 @test13(i8** %esc) {
%call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 57) nounwind
store i8* %call, i8** %esc, align 8
- %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
; CHECK: ret i32 8
ret i32 %1
}
-; CHECK: @PR13390
+; CHECK-LABEL: @PR13390(
define i32 @PR13390(i1 %bool, i8* %a) {
entry:
%cond = or i1 %bool, true
@@ -229,8 +228,8 @@ entry:
xpto:
%select = select i1 %bool, i8* %select, i8* %a
%select2 = select i1 %bool, i8* %a, i8* %select2
- %0 = tail call i32 @llvm.objectsize.i32(i8* %select, i1 true)
- %1 = tail call i32 @llvm.objectsize.i32(i8* %select2, i1 true)
+ %0 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select, i1 true)
+ %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select2, i1 true)
%2 = add i32 %0, %1
; CHECK: ret i32 undef
ret i32 %2
@@ -239,7 +238,7 @@ return:
ret i32 42
}
-; CHECK: @PR13621
+; CHECK-LABEL: @PR13621(
define i32 @PR13621(i1 %bool) nounwind {
entry:
%cond = or i1 %bool, true
@@ -249,7 +248,7 @@ entry:
xpto:
%gep2 = getelementptr i8* %gep, i32 1
%gep = getelementptr i8* %gep2, i32 1
- %o = call i32 @llvm.objectsize.i32(i8* %gep, i1 true)
+ %o = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 true)
; CHECK: ret i32 undef
ret i32 %o
@@ -259,20 +258,21 @@ return:
@globalalias = alias internal [60 x i8]* @a
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK-NEXT: ret i32 60
define i32 @test18() {
%bc = bitcast [60 x i8]* @globalalias to i8*
- %1 = call i32 @llvm.objectsize.i32(i8* %bc, i1 false)
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
ret i32 %1
}
@globalalias2 = alias weak [60 x i8]* @a
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK: llvm.objectsize
define i32 @test19() {
%bc = bitcast [60 x i8]* @globalalias2 to i8*
- %1 = call i32 @llvm.objectsize.i32(i8* %bc, i1 false)
+ %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
ret i32 %1
}
+
diff --git a/test/Transforms/InstCombine/onehot_merge.ll b/test/Transforms/InstCombine/onehot_merge.ll
new file mode 100644
index 000000000000..51f955c2c248
--- /dev/null
+++ b/test/Transforms/InstCombine/onehot_merge.ll
@@ -0,0 +1,35 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+;CHECK: @and_consts
+;CHECK: and i32 %k, 12
+;CHECK: icmp ne i32 %0, 12
+;CHECK: ret
+define i1 @and_consts(i32 %k, i32 %c1, i32 %c2) {
+bb:
+ %tmp1 = and i32 4, %k
+ %tmp2 = icmp eq i32 %tmp1, 0
+ %tmp5 = and i32 8, %k
+ %tmp6 = icmp eq i32 %tmp5, 0
+ %or = or i1 %tmp2, %tmp6
+ ret i1 %or
+}
+
+;CHECK: @foo1_and
+;CHECK: shl i32 1, %c1
+;CHECK-NEXT: shl i32 1, %c2
+;CHECK-NEXT: or i32
+;CHECK-NEXT: and i32
+;CHECK-NEXT: icmp ne i32 %1, %0
+;CHECK: ret
+define i1 @foo1_and(i32 %k, i32 %c1, i32 %c2) {
+bb:
+ %tmp = shl i32 1, %c1
+ %tmp4 = shl i32 1, %c2
+ %tmp1 = and i32 %tmp, %k
+ %tmp2 = icmp eq i32 %tmp1, 0
+ %tmp5 = and i32 %tmp4, %k
+ %tmp6 = icmp eq i32 %tmp5, 0
+ %or = or i1 %tmp2, %tmp6
+ ret i1 %or
+}
+
diff --git a/test/Transforms/InstCombine/or-fcmp.ll b/test/Transforms/InstCombine/or-fcmp.ll
index 09a3c994d93e..29963f6c5c24 100644
--- a/test/Transforms/InstCombine/or-fcmp.ll
+++ b/test/Transforms/InstCombine/or-fcmp.ll
@@ -1,6 +1,6 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
-; CHECK: @t1
+; CHECK-LABEL: @t1(
define zeroext i8 @t1(float %x, float %y) nounwind {
%a = fcmp ueq float %x, %y ; <i1> [#uses=1]
%b = fcmp uno float %x, %y ; <i1> [#uses=1]
@@ -11,7 +11,7 @@ define zeroext i8 @t1(float %x, float %y) nounwind {
ret i8 %retval
}
-; CHECK: @t2
+; CHECK-LABEL: @t2(
define zeroext i8 @t2(float %x, float %y) nounwind {
%a = fcmp olt float %x, %y ; <i1> [#uses=1]
%b = fcmp oeq float %x, %y ; <i1> [#uses=1]
@@ -23,7 +23,7 @@ define zeroext i8 @t2(float %x, float %y) nounwind {
ret i8 %retval
}
-; CHECK: @t3
+; CHECK-LABEL: @t3(
define zeroext i8 @t3(float %x, float %y) nounwind {
%a = fcmp ult float %x, %y ; <i1> [#uses=1]
%b = fcmp uge float %x, %y ; <i1> [#uses=1]
@@ -33,7 +33,7 @@ define zeroext i8 @t3(float %x, float %y) nounwind {
ret i8 %retval
}
-; CHECK: @t4
+; CHECK-LABEL: @t4(
define zeroext i8 @t4(float %x, float %y) nounwind {
%a = fcmp ult float %x, %y ; <i1> [#uses=1]
%b = fcmp ugt float %x, %y ; <i1> [#uses=1]
@@ -45,7 +45,7 @@ define zeroext i8 @t4(float %x, float %y) nounwind {
ret i8 %retval
}
-; CHECK: @t5
+; CHECK-LABEL: @t5(
define zeroext i8 @t5(float %x, float %y) nounwind {
%a = fcmp olt float %x, %y ; <i1> [#uses=1]
%b = fcmp oge float %x, %y ; <i1> [#uses=1]
diff --git a/test/Transforms/InstCombine/or-xor.ll b/test/Transforms/InstCombine/or-xor.ll
index f496dd48c402..cec36f119a9a 100644
--- a/test/Transforms/InstCombine/or-xor.ll
+++ b/test/Transforms/InstCombine/or-xor.ll
@@ -5,7 +5,7 @@ define i32 @test1(i32 %x, i32 %y) nounwind {
%not = xor i32 %or, -1
%z = or i32 %x, %not
ret i32 %z
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: %y.not = xor i32 %y, -1
; CHECK-NEXT: %z = or i32 %y.not, %x
; CHECK-NEXT: ret i32 %z
@@ -16,7 +16,7 @@ define i32 @test2(i32 %x, i32 %y) nounwind {
%not = xor i32 %or, -1
%z = or i32 %y, %not
ret i32 %z
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: %x.not = xor i32 %x, -1
; CHECK-NEXT: %z = or i32 %x.not, %y
; CHECK-NEXT: ret i32 %z
@@ -27,7 +27,7 @@ define i32 @test3(i32 %x, i32 %y) nounwind {
%not = xor i32 %xor, -1
%z = or i32 %x, %not
ret i32 %z
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: %y.not = xor i32 %y, -1
; CHECK-NEXT: %z = or i32 %y.not, %x
; CHECK-NEXT: ret i32 %z
@@ -38,7 +38,7 @@ define i32 @test4(i32 %x, i32 %y) nounwind {
%not = xor i32 %xor, -1
%z = or i32 %y, %not
ret i32 %z
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: %x.not = xor i32 %x, -1
; CHECK-NEXT: %z = or i32 %x.not, %y
; CHECK-NEXT: ret i32 %z
@@ -49,7 +49,7 @@ define i32 @test5(i32 %x, i32 %y) nounwind {
%not = xor i32 %and, -1
%z = or i32 %x, %not
ret i32 %z
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: ret i32 -1
}
@@ -58,7 +58,7 @@ define i32 @test6(i32 %x, i32 %y) nounwind {
%not = xor i32 %and, -1
%z = or i32 %y, %not
ret i32 %z
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: ret i32 -1
}
@@ -66,7 +66,7 @@ define i32 @test7(i32 %x, i32 %y) nounwind {
%xor = xor i32 %x, %y
%z = or i32 %y, %xor
ret i32 %z
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: %z = or i32 %x, %y
; CHECK-NEXT: ret i32 %z
}
@@ -76,7 +76,7 @@ define i32 @test8(i32 %x, i32 %y) nounwind {
%xor = xor i32 %x, %not
%z = or i32 %y, %xor
ret i32 %z
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NEXT: %x.not = xor i32 %x, -1
; CHECK-NEXT: %z = or i32 %x.not, %y
; CHECK-NEXT: ret i32 %z
@@ -87,7 +87,7 @@ define i32 @test9(i32 %x, i32 %y) nounwind {
%xor = xor i32 %not, %y
%z = or i32 %x, %xor
ret i32 %z
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: %y.not = xor i32 %y, -1
; CHECK-NEXT: %z = or i32 %y.not, %x
; CHECK-NEXT: ret i32 %z
diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll
index 7226bd93996f..1cd897ee90c6 100644
--- a/test/Transforms/InstCombine/or.ll
+++ b/test/Transforms/InstCombine/or.ll
@@ -6,49 +6,49 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
define i32 @test1(i32 %A) {
%B = or i32 %A, 0
ret i32 %B
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 %A
}
define i32 @test2(i32 %A) {
%B = or i32 %A, -1
ret i32 %B
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret i32 -1
}
define i8 @test2a(i8 %A) {
%B = or i8 %A, -1
ret i8 %B
-; CHECK: @test2a
+; CHECK-LABEL: @test2a(
; CHECK: ret i8 -1
}
define i1 @test3(i1 %A) {
%B = or i1 %A, false
ret i1 %B
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i1 %A
}
define i1 @test4(i1 %A) {
%B = or i1 %A, true
ret i1 %B
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ret i1 true
}
define i1 @test5(i1 %A) {
%B = or i1 %A, %A
ret i1 %B
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: ret i1 %A
}
define i32 @test6(i32 %A) {
%B = or i32 %A, %A
ret i32 %B
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: ret i32 %A
}
@@ -57,7 +57,7 @@ define i32 @test7(i32 %A) {
%NotA = xor i32 -1, %A
%B = or i32 %A, %NotA
ret i32 %B
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: ret i32 -1
}
@@ -65,7 +65,7 @@ define i8 @test8(i8 %A) {
%B = or i8 %A, -2
%C = or i8 %B, 1
ret i8 %C
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: ret i8 -1
}
@@ -75,7 +75,7 @@ define i8 @test9(i8 %A, i8 %B) {
%D = or i8 %B, -2
%E = or i8 %C, %D
ret i8 %E
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: ret i8 -1
}
@@ -85,7 +85,7 @@ define i8 @test10(i8 %A) {
; (X & C1) | C2 --> (X | C2) & (C1|C2)
%D = or i8 %C, -2
ret i8 %D
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: ret i8 -2
}
@@ -96,7 +96,7 @@ define i8 @test11(i8 %A) {
%D = or i8 %C, 1
%E = xor i8 %D, 12
ret i8 %E
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: ret i8 -1
}
@@ -105,7 +105,7 @@ define i32 @test12(i32 %A) {
%B = or i32 %A, 4
%C = and i32 %B, 8
ret i32 %C
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK: %C = and i32 %A, 8
; CHECK: ret i32 %C
}
@@ -115,7 +115,7 @@ define i32 @test13(i32 %A) {
; Always equal to 8
%C = and i32 %B, 8
ret i32 %C
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: ret i32 8
}
@@ -125,7 +125,7 @@ define i1 @test14(i32 %A, i32 %B) {
; (A < B) | (A > B) === A != B
%D = or i1 %C1, %C2
ret i1 %D
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK: icmp ne i32 %A, %B
; CHECK: ret i1
}
@@ -136,7 +136,7 @@ define i1 @test15(i32 %A, i32 %B) {
; (A < B) | (A == B) === A <= B
%D = or i1 %C1, %C2
ret i1 %D
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK: icmp ule i32 %A, %B
; CHECK: ret i1
}
@@ -148,7 +148,7 @@ define i32 @test16(i32 %A) {
; %D = and int %B, -1 == %B
%D = or i32 %B, %C
ret i32 %D
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK: ret i32 %A
}
@@ -158,7 +158,7 @@ define i32 @test17(i32 %A) {
; %D = and int %B, 5
%D = or i32 %B, %C
ret i32 %D
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK: %D = and i32 %A, 5
; CHECK: ret i32 %D
}
@@ -169,7 +169,7 @@ define i1 @test18(i32 %A) {
;; (A-50) >u 50
%D = or i1 %B, %C
ret i1 %D
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: add i32
; CHECK: icmp ugt
; CHECK: ret i1
@@ -181,7 +181,7 @@ define i1 @test19(i32 %A) {
;; (A&-2) == 50
%D = or i1 %B, %C
ret i1 %D
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK: and i32
; CHECK: icmp eq
; CHECK: ret i1
@@ -191,7 +191,7 @@ define i32 @test20(i32 %x) {
%y = and i32 %x, 123
%z = or i32 %y, %x
ret i32 %z
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK: ret i32 %x
}
@@ -202,7 +202,7 @@ define i32 @test21(i32 %tmp.1) {
;; add tmp.1, 2
%tmp.6 = or i32 %tmp.5, %tmp.3
ret i32 %tmp.6
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK: add i32 %{{[^,]*}}, 2
; CHECK: ret i32
}
@@ -212,7 +212,7 @@ define i32 @test22(i32 %B) {
%ELIM7 = and i32 %B, -2
%ELIM5 = or i32 %ELIM41, %ELIM7
ret i32 %ELIM5
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK: ret i32 %B
}
@@ -222,7 +222,7 @@ define i16 @test23(i16 %A) {
%C = or i16 %B, -32768
%D = xor i16 %C, 8193
ret i16 %D
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK: %B = lshr i16 %A, 1
; CHECK: %D = xor i16 %B, -24575
; CHECK: ret i16 %D
@@ -235,7 +235,7 @@ define i1 @test24(double %X, double %Y) {
%bothcond = or i1 %tmp13, %tmp9 ; <i1> [#uses=1]
ret i1 %bothcond
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK: = fcmp uno double %Y, %X
; CHECK: ret i1
}
@@ -248,7 +248,7 @@ define i1 @test25(i32 %A, i32 %B) {
%F = xor i1 %E, -1
ret i1 %F
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK: icmp ne i32 %A, 0
; CHECK-NEXT: icmp ne i32 %B, 57
; CHECK-NEXT: %F = and i1
@@ -262,7 +262,7 @@ define i1 @test26(i32 %A, i32 %B) {
; (A == 0) & (A == 0) --> (A|B) == 0
%D = and i1 %C1, %C2
ret i1 %D
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK: or i32 %A, %B
; CHECK: icmp eq i32 {{.*}}, 0
; CHECK: ret i1
@@ -274,7 +274,7 @@ define i1 @test27(i32* %A, i32* %B) {
%D = or i32 %C1, %C2
%E = icmp eq i32 %D, 0
ret i1 %E
-; CHECK: @test27
+; CHECK-LABEL: @test27(
; CHECK: icmp eq i32* %A, null
; CHECK: icmp eq i32* %B, null
; CHECK: and i1
@@ -288,7 +288,7 @@ define i1 @test28(i32 %A, i32 %B) {
; (A != 0) | (A != 0) --> (A|B) != 0
%D = or i1 %C1, %C2
ret i1 %D
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; CHECK: or i32 %A, %B
; CHECK: icmp ne i32 {{.*}}, 0
; CHECK: ret i1
@@ -300,7 +300,7 @@ define i1 @test29(i32* %A, i32* %B) {
%D = or i32 %C1, %C2
%E = icmp ne i32 %D, 0
ret i1 %E
-; CHECK: @test29
+; CHECK-LABEL: @test29(
; CHECK: icmp ne i32* %A, null
; CHECK: icmp ne i32* %B, null
; CHECK: or i1
@@ -315,7 +315,7 @@ entry:
%D = and i32 %B, 40186
%E = or i32 %D, %C
ret i32 %E
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; CHECK: %D = and i32 %A, -58312
; CHECK: %E = or i32 %D, 32962
; CHECK: ret i32 %E
@@ -331,7 +331,7 @@ define i64 @test31(i64 %A) nounwind readnone ssp noredzone {
%F = or i64 %D, %E
ret i64 %F
-; CHECK: @test31
+; CHECK-LABEL: @test31(
; CHECK-NEXT: %E = and i64 %A, 4294908984
; CHECK-NEXT: %F = or i64 %E, 32962
; CHECK-NEXT: ret i64 %F
@@ -345,7 +345,7 @@ define <4 x i32> @test32(<4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32
%or.i = or <4 x i32> %and.i, %and.i129 ; <<4 x i32>> [#uses=1]
ret <4 x i32> %or.i
; codegen is mature enough to handle vector selects.
-; CHECK: @test32
+; CHECK-LABEL: @test32(
; CHECK: select <4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32> %vecinit6.i191
}
@@ -353,7 +353,7 @@ define i1 @test33(i1 %X, i1 %Y) {
%a = or i1 %X, %Y
%b = or i1 %a, %X
ret i1 %b
-; CHECK: @test33
+; CHECK-LABEL: @test33(
; CHECK-NEXT: or i1 %X, %Y
; CHECK-NEXT: ret
}
@@ -362,7 +362,7 @@ define i32 @test34(i32 %X, i32 %Y) {
%a = or i32 %X, %Y
%b = or i32 %Y, %a
ret i32 %b
-; CHECK: @test34
+; CHECK-LABEL: @test34(
; CHECK-NEXT: or i32 %X, %Y
; CHECK-NEXT: ret
}
@@ -371,7 +371,7 @@ define i32 @test35(i32 %a, i32 %b) {
%1 = or i32 %a, 1135
%2 = or i32 %1, %b
ret i32 %2
- ; CHECK: @test35
+ ; CHECK-LABEL: @test35(
; CHECK-NEXT: or i32 %a, %b
; CHECK-NEXT: or i32 %1, 1135
}
@@ -383,14 +383,14 @@ define i1 @test36(i32 %x) {
%cmp3 = icmp eq i32 %x, 25
%ret2 = or i1 %ret1, %cmp3
ret i1 %ret2
-; CHECK: @test36
+; CHECK-LABEL: @test36(
; CHECK-NEXT: %x.off = add i32 %x, -23
; CHECK-NEXT: icmp ult i32 %x.off, 3
; CHECK-NEXT: ret i1
}
define i32 @test37(i32* %xp, i32 %y) {
-; CHECK: @test37
+; CHECK-LABEL: @test37(
; CHECK: select i1 %tobool, i32 -1, i32 %x
%tobool = icmp ne i32 %y, 0
%sext = sext i1 %tobool to i32
@@ -400,7 +400,7 @@ define i32 @test37(i32* %xp, i32 %y) {
}
define i32 @test38(i32* %xp, i32 %y) {
-; CHECK: @test38
+; CHECK-LABEL: @test38(
; CHECK: select i1 %tobool, i32 -1, i32 %x
%tobool = icmp ne i32 %y, 0
%sext = sext i1 %tobool to i32
diff --git a/test/Transforms/InstCombine/osx-names.ll b/test/Transforms/InstCombine/osx-names.ll
index 7b83526aceb5..926caadc49d8 100644
--- a/test/Transforms/InstCombine/osx-names.ll
+++ b/test/Transforms/InstCombine/osx-names.ll
@@ -14,14 +14,14 @@ target triple = "i386-apple-macosx10.7.2"
@.str2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
define void @test1(%struct.__sFILE* %stream) nounwind {
-; CHECK: define void @test1
+; CHECK-LABEL: define void @test1(
; CHECK: call i32 @"fwrite$UNIX2003"
%call = tail call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %stream, i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0)) nounwind
ret void
}
define void @test2(%struct.__sFILE* %stream, i8* %str) nounwind ssp {
-; CHECK: define void @test2
+; CHECK-LABEL: define void @test2(
; CHECK: call i32 @"fputs$UNIX2003"
%call = tail call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %stream, i8* getelementptr inbounds ([3 x i8]* @.str2, i32 0, i32 0), i8* %str) nounwind
ret void
diff --git a/test/Transforms/InstCombine/overflow.ll b/test/Transforms/InstCombine/overflow.ll
index 81ceef8c41cf..3eddc80a7048 100644
--- a/test/Transforms/InstCombine/overflow.ll
+++ b/test/Transforms/InstCombine/overflow.ll
@@ -3,7 +3,7 @@
declare void @throwAnExceptionOrWhatever()
-; CHECK: @test1
+; CHECK-LABEL: @test1(
define i32 @test1(i32 %a, i32 %b) nounwind ssp {
entry:
; CHECK-NOT: sext
@@ -26,7 +26,7 @@ if.end:
ret i32 %conv9
}
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; This form should not be promoted for two reasons: 1) it is unprofitable to
; promote it since the add.off instruction has another use, and 2) it is unsafe
; because the add-with-off makes the high bits of the original add live.
@@ -76,7 +76,7 @@ if.end:
; CHECK: ret i64
}
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; Should be able to form an i8 sadd computed in an i32.
define zeroext i8 @test4(i8 signext %a, i8 signext %b) nounwind ssp {
entry:
@@ -97,7 +97,7 @@ if.end: ; preds = %entry
; CHECK: ret i8
}
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: llvm.uadd.with.overflow
; CHECK: ret i64
define i64 @test5(i64 %a, i64 %b) nounwind ssp {
@@ -108,7 +108,7 @@ entry:
ret i64 %Q
}
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: llvm.uadd.with.overflow
; CHECK: ret i64
define i64 @test6(i64 %a, i64 %b) nounwind ssp {
@@ -119,7 +119,7 @@ entry:
ret i64 %Q
}
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: llvm.uadd.with.overflow
; CHECK: ret i64
define i64 @test7(i64 %a, i64 %b) nounwind ssp {
@@ -130,7 +130,7 @@ entry:
ret i64 %Q
}
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; PR11438
; This is @test1, but the operands are not sign-extended. Make sure
; we don't transform this case.
diff --git a/test/Transforms/InstCombine/phi-select-constexpr.ll b/test/Transforms/InstCombine/phi-select-constexpr.ll
new file mode 100644
index 000000000000..054e0691d47a
--- /dev/null
+++ b/test/Transforms/InstCombine/phi-select-constexpr.ll
@@ -0,0 +1,19 @@
+; RUN: opt < %s -S -instcombine | FileCheck %s
+@A = extern_weak global i32, align 4
+@B = extern_weak global i32, align 4
+
+define i32 @foo(i1 %which) {
+entry:
+ br i1 %which, label %final, label %delay
+
+delay:
+ br label %final
+
+; CHECK-LABEL: final:
+; CHECK: phi i32 [ 1, %entry ], [ select (i1 icmp eq (i32* @A, i32* @B), i32 2, i32 1), %delay ]
+final:
+ %use2 = phi i1 [ false, %entry ], [ icmp eq (i32* @A, i32* @B), %delay ]
+ %value = select i1 %use2, i32 2, i32 1
+ ret i32 %value
+}
+
diff --git a/test/Transforms/InstCombine/phi.ll b/test/Transforms/InstCombine/phi.ll
index 1c307d430f3f..6e314651383c 100644
--- a/test/Transforms/InstCombine/phi.ll
+++ b/test/Transforms/InstCombine/phi.ll
@@ -15,7 +15,7 @@ BB1:
BB2:
ret i32 %A
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: BB1:
; CHECK-NEXT: ret i32 %A
}
@@ -31,7 +31,7 @@ BB2:
; Combine away PHI nodes with same values
%B = phi i32 [ %A, %BB0 ], [ %A, %BB1 ]
ret i32 %B
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: BB2:
; CHECK-NEXT: ret i32 %A
}
@@ -47,7 +47,7 @@ Loop:
Exit:
ret i32 %B
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: Exit:
; CHECK-NEXT: ret i32 %A
}
@@ -64,7 +64,7 @@ Loop: ; preds = %L2, %Loop
L2: ; preds = %Loop
br label %Loop
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: Loop:
; CHECK-NEXT: br i1 %b
}
@@ -80,7 +80,7 @@ Loop: ; preds = %Loop, %BB0
Exit: ; preds = %Loop
ret i32 %B
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: Loop:
; CHECK-NEXT: br i1 %b
; CHECK: Exit:
@@ -100,7 +100,7 @@ BB2:
;; Suck casts into phi
%B = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
ret i32 %B
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: BB2:
; CHECK: zext i16 %A to i32
; CHECK-NEXT: ret i32
@@ -118,7 +118,7 @@ Loop: ; preds = %Loop, %BB0
Exit: ; preds = %Loop
ret i32 0
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: Loop:
; CHECK-NEXT: br i1 %b
}
@@ -136,7 +136,7 @@ BB2:
;; Suck GEPs into phi
%B = phi i32* [ %X, %BB0 ], [ %Y, %BB1 ]
ret i32* %B
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NOT: phi
; CHECK: BB2:
; CHECK-NEXT: %B = getelementptr { i32, i32 }* %A
@@ -159,7 +159,7 @@ bb1:
bb2:
%E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
ret i32 %E
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: bb2:
; CHECK-NEXT: phi i32* [ %B, %bb ], [ %A, %bb1 ]
; CHECK-NEXT: %E = load i32* %{{[^,]*}}, align 1
@@ -183,7 +183,7 @@ bb1:
bb2:
%E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
ret i32 %E
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: bb2:
; CHECK-NEXT: phi i32* [ %B, %bb ], [ %A, %bb1 ]
; CHECK-NEXT: %E = load i32* %{{[^,]*}}, align 16
@@ -219,7 +219,7 @@ end:
store i32 10, i32* %g
%z = call i1 @test11a()
ret i1 %z
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK-NOT: phi i32
; CHECK: ret i1 %z
}
@@ -245,7 +245,7 @@ end:
%tmp2 = add i64 %tmp32, %tmp30
ret i64 %tmp2
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NOT: zext
; CHECK: end:
; CHECK-NEXT: phi i64 [ 0, %entry ], [ %Val, %two ]
@@ -276,7 +276,7 @@ end:
call void @test13f(double %tmp31, i32 %tmp32)
ret void
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK-NOT: zext
; CHECK: end:
; CHECK-NEXT: phi double [ 0.000000e+00, %entry ], [ %Vald, %two ]
@@ -296,7 +296,7 @@ Loop:
Exit: ; preds = %Loop
ret i640 %C
-; CHECK: @test14a
+; CHECK-LABEL: @test14a(
; CHECK: Loop:
; CHECK-NEXT: phi i320
}
@@ -313,7 +313,7 @@ Loop:
Exit: ; preds = %Loop
ret i160 %C
-; CHECK: @test14b
+; CHECK-LABEL: @test14b(
; CHECK: Loop:
; CHECK-NEXT: phi i160
}
@@ -321,7 +321,7 @@ Exit: ; preds = %Loop
declare i64 @test15a(i64)
define i64 @test15b(i64 %A, i1 %b) {
-; CHECK: @test15b
+; CHECK-LABEL: @test15b(
entry:
%i0 = zext i64 %A to i128
%i1 = shl i128 %i0, 64
@@ -405,7 +405,7 @@ if.else: ; preds = %entry
; PR4413
declare i32 @ext()
-; CHECK: @test17
+; CHECK-LABEL: @test17(
define i32 @test17(i1 %a) {
entry:
br i1 %a, label %bb1, label %bb2
@@ -435,7 +435,7 @@ ret:
%ptr = phi i32* [ %zero, %true ] , [ %one, %false ]
%isnull = icmp eq i32* %ptr, null
ret i1 %isnull
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: ret i1 false
}
@@ -449,7 +449,7 @@ ret:
%p = phi double [ %x, %true ], [ 0x7FF0000000000000, %false ]; RHS = +infty
%cmp = fcmp ule double %x, %p
ret i1 %cmp
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK: ret i1 true
}
@@ -466,7 +466,7 @@ ret:
%p = phi i32* [ %a, %true ], [ %b, %false ]
%r = icmp eq i32* %p, %c
ret i1 %r
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK: ret i1 false
}
@@ -485,12 +485,12 @@ loop:
br i1 %c2, label %ret, label %loop
ret:
ret i1 %r
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK: ret i1 false
}
define void @test22() {
-; CHECK: @test22
+; CHECK-LABEL: @test22(
entry:
br label %loop
loop:
@@ -518,7 +518,7 @@ Loop: ; preds = %Loop, %BB0
Exit: ; preds = %Loop
%E = add i32 %B, 19
ret i32 %E
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK: %phitmp = add i32 %A, 19
; CHECK: Loop:
; CHECK-NEXT: %B = phi i32 [ %phitmp, %BB0 ], [ 61, %Loop ]
@@ -538,7 +538,7 @@ BB1:
BB2:
%C = phi i32 [ %X, %BB0 ], [ %Y, %BB1 ]
ret i32 %C
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK-NOT: phi
; CHECK: BB2:
; CHECK-NEXT: %C = add nuw i32 %A, 1
@@ -573,7 +573,7 @@ end:
store i32 10, i32* %g
%z = call i1 @test25a()
ret i1 %z
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK-NOT: phi i32
; CHECK: ret i1 %z
}
@@ -616,12 +616,12 @@ end:
store i32 10, i32* %g
%z = call i1 @test26a()
ret i1 %z
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK-NOT: phi i32
; CHECK: ret i1 %z
}
-; CHECK: @test27(
+; CHECK-LABEL: @test27(
; CHECK: ret i32 undef
define i32 @test27(i1 %b) {
entry:
diff --git a/test/Transforms/InstCombine/pow-1.ll b/test/Transforms/InstCombine/pow-1.ll
index 8a311f0b74c6..9f1d073fe760 100644
--- a/test/Transforms/InstCombine/pow-1.ll
+++ b/test/Transforms/InstCombine/pow-1.ll
@@ -12,14 +12,14 @@ declare double @pow(double, double) nounwind readonly
; Check pow(1.0, x) -> 1.0.
define float @test_simplify1(float %x) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%retval = call float @powf(float 1.0, float %x)
ret float %retval
; CHECK-NEXT: ret float 1.000000e+00
}
define double @test_simplify2(double %x) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%retval = call double @pow(double 1.0, double %x)
ret double %retval
; CHECK-NEXT: ret double 1.000000e+00
@@ -28,7 +28,7 @@ define double @test_simplify2(double %x) {
; Check pow(2.0, x) -> exp2(x).
define float @test_simplify3(float %x) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%retval = call float @powf(float 2.0, float %x)
; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call float @exp2f(float %x) [[NUW_RO:#[0-9]+]]
ret float %retval
@@ -36,7 +36,7 @@ define float @test_simplify3(float %x) {
}
define double @test_simplify4(double %x) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%retval = call double @pow(double 2.0, double %x)
; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call double @exp2(double %x) [[NUW_RO]]
ret double %retval
@@ -46,14 +46,14 @@ define double @test_simplify4(double %x) {
; Check pow(x, 0.0) -> 1.0.
define float @test_simplify5(float %x) {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%retval = call float @powf(float %x, float 0.0)
ret float %retval
; CHECK-NEXT: ret float 1.000000e+00
}
define double @test_simplify6(double %x) {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%retval = call double @pow(double %x, double 0.0)
ret double %retval
; CHECK-NEXT: ret double 1.000000e+00
@@ -62,7 +62,7 @@ define double @test_simplify6(double %x) {
; Check pow(x, 0.5) -> fabs(sqrt(x)), where x != -infinity.
define float @test_simplify7(float %x) {
-; CHECK: @test_simplify7
+; CHECK-LABEL: @test_simplify7(
%retval = call float @powf(float %x, float 0.5)
; CHECK-NEXT: [[SQRTF:%[a-z0-9]+]] = call float @sqrtf(float %x) [[NUW_RO]]
; CHECK-NEXT: [[FABSF:%[a-z0-9]+]] = call float @fabsf(float [[SQRTF]]) [[NUW_RO]]
@@ -73,7 +73,7 @@ define float @test_simplify7(float %x) {
}
define double @test_simplify8(double %x) {
-; CHECK: @test_simplify8
+; CHECK-LABEL: @test_simplify8(
%retval = call double @pow(double %x, double 0.5)
; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) [[NUW_RO]]
; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]]) [[NUW_RO]]
@@ -86,14 +86,14 @@ define double @test_simplify8(double %x) {
; Check pow(-infinity, 0.5) -> +infinity.
define float @test_simplify9(float %x) {
-; CHECK: @test_simplify9
+; CHECK-LABEL: @test_simplify9(
%retval = call float @powf(float 0xFFF0000000000000, float 0.5)
ret float %retval
; CHECK-NEXT: ret float 0x7FF0000000000000
}
define double @test_simplify10(double %x) {
-; CHECK: @test_simplify10
+; CHECK-LABEL: @test_simplify10(
%retval = call double @pow(double 0xFFF0000000000000, double 0.5)
ret double %retval
; CHECK-NEXT: ret double 0x7FF0000000000000
@@ -102,14 +102,14 @@ define double @test_simplify10(double %x) {
; Check pow(x, 1.0) -> x.
define float @test_simplify11(float %x) {
-; CHECK: @test_simplify11
+; CHECK-LABEL: @test_simplify11(
%retval = call float @powf(float %x, float 1.0)
ret float %retval
; CHECK-NEXT: ret float %x
}
define double @test_simplify12(double %x) {
-; CHECK: @test_simplify12
+; CHECK-LABEL: @test_simplify12(
%retval = call double @pow(double %x, double 1.0)
ret double %retval
; CHECK-NEXT: ret double %x
@@ -118,7 +118,7 @@ define double @test_simplify12(double %x) {
; Check pow(x, 2.0) -> x*x.
define float @test_simplify13(float %x) {
-; CHECK: @test_simplify13
+; CHECK-LABEL: @test_simplify13(
%retval = call float @powf(float %x, float 2.0)
; CHECK-NEXT: [[SQUARE:%[a-z0-9]+]] = fmul float %x, %x
ret float %retval
@@ -126,7 +126,7 @@ define float @test_simplify13(float %x) {
}
define double @test_simplify14(double %x) {
-; CHECK: @test_simplify14
+; CHECK-LABEL: @test_simplify14(
%retval = call double @pow(double %x, double 2.0)
; CHECK-NEXT: [[SQUARE:%[a-z0-9]+]] = fmul double %x, %x
ret double %retval
@@ -136,7 +136,7 @@ define double @test_simplify14(double %x) {
; Check pow(x, -1.0) -> 1.0/x.
define float @test_simplify15(float %x) {
-; CHECK: @test_simplify15
+; CHECK-LABEL: @test_simplify15(
%retval = call float @powf(float %x, float -1.0)
; CHECK-NEXT: [[RECIPROCAL:%[a-z0-9]+]] = fdiv float 1.000000e+00, %x
ret float %retval
@@ -144,11 +144,24 @@ define float @test_simplify15(float %x) {
}
define double @test_simplify16(double %x) {
-; CHECK: @test_simplify16
+; CHECK-LABEL: @test_simplify16(
%retval = call double @pow(double %x, double -1.0)
; CHECK-NEXT: [[RECIPROCAL:%[a-z0-9]+]] = fdiv double 1.000000e+00, %x
ret double %retval
; CHECK-NEXT: ret double [[RECIPROCAL]]
}
+declare double @llvm.pow.f64(double %Val, double %Power)
+define double @test_simplify17(double %x) {
+; CHECK-LABEL: @test_simplify17(
+ %retval = call double @llvm.pow.f64(double %x, double 0.5)
+; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) [[NUW_RO]]
+; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]]) [[NUW_RO]]
+; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq double %x, 0xFFF0000000000000
+; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], double 0x7FF0000000000000, double [[FABS]]
+ ret double %retval
+; CHECK-NEXT: ret double [[SELECT]]
+}
+
; CHECK: attributes [[NUW_RO]] = { nounwind readonly }
+
diff --git a/test/Transforms/InstCombine/pow-2.ll b/test/Transforms/InstCombine/pow-2.ll
index af64cda0904a..d1ffde703faa 100644
--- a/test/Transforms/InstCombine/pow-2.ll
+++ b/test/Transforms/InstCombine/pow-2.ll
@@ -7,7 +7,7 @@ declare float @pow(double, double)
; Check that pow functions with the wrong prototype aren't simplified.
define float @test_no_simplify1(double %x) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%retval = call float @pow(double 1.0, double %x)
; CHECK-NEXT: call float @pow(double 1.000000e+00, double %x)
ret float %retval
diff --git a/test/Transforms/InstCombine/pow-3.ll b/test/Transforms/InstCombine/pow-3.ll
new file mode 100644
index 000000000000..1c5cf910a8af
--- /dev/null
+++ b/test/Transforms/InstCombine/pow-3.ll
@@ -0,0 +1,12 @@
+; Test that the pow won't get simplified to sqrt(fabs) when they are not available.
+;
+; RUN: opt < %s -disable-simplify-libcalls -instcombine -S | FileCheck %s
+
+declare double @llvm.pow.f64(double %Val, double %Power)
+
+define double @test_simplify_unavailable(double %x) {
+; CHECK-LABEL: @test_simplify_unavailable(
+ %retval = call double @llvm.pow.f64(double %x, double 0.5)
+; CHECK-NEXT: call double @llvm.pow.f64(double %x, double 5.000000e-01)
+ ret double %retval
+}
diff --git a/test/Transforms/InstCombine/pr17827.ll b/test/Transforms/InstCombine/pr17827.ll
new file mode 100644
index 000000000000..a8b592635523
--- /dev/null
+++ b/test/Transforms/InstCombine/pr17827.ll
@@ -0,0 +1,74 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; With left shift, the comparison should not be modified.
+; CHECK-LABEL: @test_shift_and_cmp_not_changed1(
+; CHECK: icmp slt i8 %andp, 32
+define i1 @test_shift_and_cmp_not_changed1(i8 %p) #0 {
+entry:
+ %shlp = shl i8 %p, 5
+ %andp = and i8 %shlp, -64
+ %cmp = icmp slt i8 %andp, 32
+ ret i1 %cmp
+}
+
+; With arithmetic right shift, the comparison should not be modified.
+; CHECK-LABEL: @test_shift_and_cmp_not_changed2(
+; CHECK: icmp slt i8 %andp, 32
+define i1 @test_shift_and_cmp_not_changed2(i8 %p) #0 {
+entry:
+ %shlp = ashr i8 %p, 5
+ %andp = and i8 %shlp, -64
+ %cmp = icmp slt i8 %andp, 32
+ ret i1 %cmp
+}
+
+; This should simplify functionally to the left shift case.
+; The extra input parameter should be optimized away.
+; CHECK-LABEL: @test_shift_and_cmp_changed1(
+; CHECK: %andp = shl i8 %p, 5
+; CHECK-NEXT: %shl = and i8 %andp, -64
+; CHECK-NEXT: %cmp = icmp slt i8 %shl, 32
+define i1 @test_shift_and_cmp_changed1(i8 %p, i8 %q) #0 {
+entry:
+ %andp = and i8 %p, 6
+ %andq = and i8 %q, 8
+ %or = or i8 %andq, %andp
+ %shl = shl i8 %or, 5
+ %ashr = ashr i8 %shl, 5
+ %cmp = icmp slt i8 %ashr, 1
+ ret i1 %cmp
+}
+
+; Unsigned compare allows a transformation to compare against 0.
+; CHECK-LABEL: @test_shift_and_cmp_changed2(
+; CHECK: icmp eq i8 %andp, 0
+define i1 @test_shift_and_cmp_changed2(i8 %p) #0 {
+entry:
+ %shlp = shl i8 %p, 5
+ %andp = and i8 %shlp, -64
+ %cmp = icmp ult i8 %andp, 32
+ ret i1 %cmp
+}
+
+; nsw on the shift should not affect the comparison.
+; CHECK-LABEL: @test_shift_and_cmp_changed3(
+; CHECK: icmp slt i8 %andp, 32
+define i1 @test_shift_and_cmp_changed3(i8 %p) #0 {
+entry:
+ %shlp = shl nsw i8 %p, 5
+ %andp = and i8 %shlp, -64
+ %cmp = icmp slt i8 %andp, 32
+ ret i1 %cmp
+}
+
+; Logical shift right allows a return true because the 'and' guarantees no bits are set.
+; CHECK-LABEL: @test_shift_and_cmp_changed4(
+; CHECK: ret i1 true
+define i1 @test_shift_and_cmp_changed4(i8 %p) #0 {
+entry:
+ %shlp = lshr i8 %p, 5
+ %andp = and i8 %shlp, -64
+ %cmp = icmp slt i8 %andp, 32
+ ret i1 %cmp
+}
+
diff --git a/test/Transforms/InstCombine/pr8547.ll b/test/Transforms/InstCombine/pr8547.ll
index 485f4d9644f3..7e9cbe17b68d 100644
--- a/test/Transforms/InstCombine/pr8547.ll
+++ b/test/Transforms/InstCombine/pr8547.ll
@@ -23,4 +23,4 @@ for.cond: ; preds = %for.cond, %codeRepl
codeRepl2: ; preds = %for.cond
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i64 0, i64 0), i32 %conv2) nounwind
ret i32 0
-} \ No newline at end of file
+}
diff --git a/test/Transforms/InstCombine/printf-1.ll b/test/Transforms/InstCombine/printf-1.ll
index 3a910ea437b7..c98ddd55df10 100644
--- a/test/Transforms/InstCombine/printf-1.ll
+++ b/test/Transforms/InstCombine/printf-1.ll
@@ -1,7 +1,7 @@
; Test that the printf library call simplifier works correctly.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
-; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=IPRINTF
+; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=CHECK-IPRINTF
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
@@ -20,7 +20,7 @@ declare i32 @printf(i8*, ...)
; Check printf("") -> noop.
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%fmt = getelementptr [1 x i8]* @empty, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt)
ret void
@@ -30,7 +30,7 @@ define void @test_simplify1() {
; Check printf("x") -> putchar('x'), even for '%'.
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%fmt = getelementptr [2 x i8]* @h, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 @putchar(i32 104)
@@ -39,7 +39,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%fmt = getelementptr [2 x i8]* @percent, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 @putchar(i32 37)
@@ -50,7 +50,7 @@ define void @test_simplify3() {
; Check printf("foo\n") -> puts("foo").
define void @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%fmt = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 @puts(i8* getelementptr inbounds ([12 x i8]* [[STR]], i32 0, i32 0))
@@ -61,7 +61,7 @@ define void @test_simplify4() {
; Check printf("%c", chr) -> putchar(chr).
define void @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%fmt = getelementptr [3 x i8]* @percent_c, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt, i8 104)
; CHECK-NEXT: call i32 @putchar(i32 104)
@@ -72,7 +72,7 @@ define void @test_simplify5() {
; Check printf("%s\n", str) -> puts(str).
define void @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%fmt = getelementptr [4 x i8]* @percent_s, i32 0, i32 0
%str = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt, i8* %str)
@@ -84,7 +84,7 @@ define void @test_simplify6() {
; Check printf(format, ...) -> iprintf(format, ...) if no floating point.
define void @test_simplify7() {
-; CHECK-IPRINTF: @test_simplify7
+; CHECK-IPRINTF-LABEL: @test_simplify7(
%fmt = getelementptr [3 x i8]* @percent_d, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt, i32 187)
; CHECK-NEXT-IPRINTF: call i32 (i8*, ...)* @iprintf(i8* getelementptr inbounds ([3 x i8]* @percent_d, i32 0, i32 0), i32 187)
@@ -93,7 +93,7 @@ define void @test_simplify7() {
}
define void @test_no_simplify1() {
-; CHECK-IPRINTF: @test_no_simplify1
+; CHECK-IPRINTF-LABEL: @test_no_simplify1(
%fmt = getelementptr [3 x i8]* @percent_f, i32 0, i32 0
call i32 (i8*, ...)* @printf(i8* %fmt, double 1.87)
; CHECK-NEXT-IPRINTF: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
@@ -102,7 +102,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2(i8* %fmt, double %d) {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
call i32 (i8*, ...)* @printf(i8* %fmt, double %d)
; CHECK-NEXT: call i32 (i8*, ...)* @printf(i8* %fmt, double %d)
ret void
@@ -110,7 +110,7 @@ define void @test_no_simplify2(i8* %fmt, double %d) {
}
define i32 @test_no_simplify3() {
-; CHECK: @test_no_simplify3
+; CHECK-LABEL: @test_no_simplify3(
%fmt = getelementptr [2 x i8]* @h, i32 0, i32 0
%ret = call i32 (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]* @h, i32 0, i32 0))
diff --git a/test/Transforms/InstCombine/printf-2.ll b/test/Transforms/InstCombine/printf-2.ll
index 466ee1c75770..7e018ebba04d 100644
--- a/test/Transforms/InstCombine/printf-2.ll
+++ b/test/Transforms/InstCombine/printf-2.ll
@@ -13,7 +13,7 @@ declare void @printf(i8*, ...)
; Check simplification of printf with void return type.
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%fmt = getelementptr [2 x i8]* @h, i32 0, i32 0
call void (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 @putchar(i32 104)
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%fmt = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call void (i8*, ...)* @printf(i8* %fmt)
; CHECK-NEXT: call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @str, i32 0, i32 0))
@@ -31,7 +31,7 @@ define void @test_simplify2() {
}
define void @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%fmt = getelementptr [4 x i8]* @percent_s, i32 0, i32 0
%str = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call void (i8*, ...)* @printf(i8* %fmt, i8* %str)
diff --git a/test/Transforms/InstCombine/ptr-int-cast.ll b/test/Transforms/InstCombine/ptr-int-cast.ll
index 7a6ecff9c0be..826c00484227 100644
--- a/test/Transforms/InstCombine/ptr-int-cast.ll
+++ b/test/Transforms/InstCombine/ptr-int-cast.ll
@@ -28,7 +28,7 @@ define i64 @f0(i32 %a0) nounwind {
}
define <4 x i32> @test4(<4 x i8*> %arg) nounwind {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ptrtoint <4 x i8*> %arg to <4 x i64>
; CHECK: trunc <4 x i64> %1 to <4 x i32>
%p1 = ptrtoint <4 x i8*> %arg to <4 x i32>
@@ -36,7 +36,7 @@ define <4 x i32> @test4(<4 x i8*> %arg) nounwind {
}
define <4 x i128> @test5(<4 x i8*> %arg) nounwind {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: ptrtoint <4 x i8*> %arg to <4 x i64>
; CHECK: zext <4 x i64> %1 to <4 x i128>
%p1 = ptrtoint <4 x i8*> %arg to <4 x i128>
@@ -44,7 +44,7 @@ define <4 x i128> @test5(<4 x i8*> %arg) nounwind {
}
define <4 x i8*> @test6(<4 x i32> %arg) nounwind {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: zext <4 x i32> %arg to <4 x i64>
; CHECK: inttoptr <4 x i64> %1 to <4 x i8*>
%p1 = inttoptr <4 x i32> %arg to <4 x i8*>
@@ -52,7 +52,7 @@ define <4 x i8*> @test6(<4 x i32> %arg) nounwind {
}
define <4 x i8*> @test7(<4 x i128> %arg) nounwind {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: trunc <4 x i128> %arg to <4 x i64>
; CHECK: inttoptr <4 x i64> %1 to <4 x i8*>
%p1 = inttoptr <4 x i128> %arg to <4 x i8*>
diff --git a/test/Transforms/InstCombine/puts-1.ll b/test/Transforms/InstCombine/puts-1.ll
index ef4e1bbd824c..bd7557ef650f 100644
--- a/test/Transforms/InstCombine/puts-1.ll
+++ b/test/Transforms/InstCombine/puts-1.ll
@@ -11,7 +11,7 @@ declare i32 @puts(i8*)
; Check puts("") -> putchar('\n').
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%str = getelementptr [1 x i8]* @empty, i32 0, i32 0
call i32 @puts(i8* %str)
; CHECK-NEXT: call i32 @putchar(i32 10)
@@ -22,7 +22,7 @@ define void @test_simplify1() {
; Don't simplify if the return value is used.
define i32 @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%str = getelementptr [1 x i8]* @empty, i32 0, i32 0
%ret = call i32 @puts(i8* %str)
; CHECK-NEXT: call i32 @puts(i8* getelementptr inbounds ([1 x i8]* @empty, i32 0, i32 0))
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll
index b421b7c0e8b4..22fd90bf7a75 100644
--- a/test/Transforms/InstCombine/rem.ll
+++ b/test/Transforms/InstCombine/rem.ll
@@ -1,36 +1,56 @@
-; This test makes sure that these instructions are properly eliminated.
+; This test makes sure that urem instructions are properly eliminated.
;
-; RUN: opt < %s -instcombine -S | not grep rem
+; RUN: opt < %s -instcombine -S | FileCheck %s
; END.
define i32 @test1(i32 %A) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: ret i32 0
%B = srem i32 %A, 1 ; ISA constant 0
ret i32 %B
}
define i32 @test2(i32 %A) { ; 0 % X = 0, we don't need to preserve traps
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: ret i32 0
%B = srem i32 0, %A
ret i32 %B
}
define i32 @test3(i32 %A) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: [[AND:%.*]] = and i32 %A, 7
+; CHECK-NEXT: ret i32 [[AND]]
%B = urem i32 %A, 8
ret i32 %B
}
define i1 @test3a(i32 %A) {
+; CHECK-LABEL: @test3a(
+; CHECK-NEXT: [[AND:%.*]] = and i32 %A, 7
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[AND]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
%B = srem i32 %A, -8
%C = icmp ne i32 %B, 0
ret i1 %C
}
define i32 @test4(i32 %X, i1 %C) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: [[SEL:%.*]] = select i1 %C, i32 0, i32 7
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[SEL]], %X
%V = select i1 %C, i32 1, i32 8
%R = urem i32 %X, %V
ret i32 %R
}
define i32 @test5(i32 %X, i8 %B) {
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i8 %B to i32
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 32, [[ZEXT]]
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[SHL]], -1
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[ADD]], %X
+; CHECK-NEXT: ret i32 [[AND]]
%shift.upgrd.1 = zext i8 %B to i32
%Amt = shl i32 32, %shift.upgrd.1
%V = urem i32 %X, %Amt
@@ -38,29 +58,39 @@ define i32 @test5(i32 %X, i8 %B) {
}
define i32 @test6(i32 %A) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: ret i32 undef
%B = srem i32 %A, 0 ;; undef
ret i32 %B
}
define i32 @test7(i32 %A) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: ret i32 0
%B = mul i32 %A, 8
%C = srem i32 %B, 4
ret i32 %C
}
define i32 @test8(i32 %A) {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: ret i32 0
%B = shl i32 %A, 4
%C = srem i32 %B, 8
ret i32 %C
}
define i32 @test9(i32 %A) {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT: ret i32 0
%B = mul i32 %A, 64
%C = urem i32 %B, 32
ret i32 %C
}
define i32 @test10(i8 %c) {
+; CHECK-LABEL: @test10(
+; CHECK-NEXT: ret i32 0
%tmp.1 = zext i8 %c to i32
%tmp.2 = mul i32 %tmp.1, 4
%tmp.3 = sext i32 %tmp.2 to i64
@@ -70,6 +100,8 @@ define i32 @test10(i8 %c) {
}
define i32 @test11(i32 %i) {
+; CHECK-LABEL: @test11(
+; CHECK-NEXT: ret i32 0
%tmp.1 = and i32 %i, -2
%tmp.3 = mul i32 %tmp.1, 2
%tmp.5 = urem i32 %tmp.3, 4
@@ -77,12 +109,98 @@ define i32 @test11(i32 %i) {
}
define i32 @test12(i32 %i) {
+; CHECK-LABEL: @test12(
+; CHECK-NEXT: ret i32 0
%tmp.1 = and i32 %i, -4
%tmp.5 = srem i32 %tmp.1, 2
ret i32 %tmp.5
}
define i32 @test13(i32 %i) {
+; CHECK-LABEL: @test13(
+; CHECK-NEXT: ret i32 0
%x = srem i32 %i, %i
ret i32 %x
}
+
+define i64 @test14(i64 %x, i32 %y) {
+; CHECK-LABEL: @test14(
+; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, %y
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[SHL]] to i64
+; CHECK-NEXT: [[ADD:%.*]] = add i64 [[ZEXT]], -1
+; CHECK-NEXT: [[AND:%.*]] = and i64 [[ADD]], %x
+; CHECK-NEXT: ret i64 [[AND]]
+ %shl = shl i32 1, %y
+ %zext = zext i32 %shl to i64
+ %urem = urem i64 %x, %zext
+ ret i64 %urem
+}
+
+define i64 @test15(i32 %x, i32 %y) {
+; CHECK-LABEL: @test15(
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 1, %y
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[SHL]], -1
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[ADD]], %x
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[AND]] to i64
+; CHECK-NEXT: ret i64 [[ZEXT]]
+ %shl = shl i32 1, %y
+ %zext0 = zext i32 %shl to i64
+ %zext1 = zext i32 %x to i64
+ %urem = urem i64 %zext1, %zext0
+ ret i64 %urem
+}
+
+define i32 @test16(i32 %x, i32 %y) {
+; CHECK-LABEL: @test16(
+; CHECK-NEXT: [[SHR:%.*]] = lshr i32 %y, 11
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[SHR]], 4
+; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], 3
+; CHECK-NEXT: [[REM:%.*]] = and i32 [[OR]], %x
+; CHECK-NEXT: ret i32 [[REM]]
+ %shr = lshr i32 %y, 11
+ %and = and i32 %shr, 4
+ %add = add i32 %and, 4
+ %rem = urem i32 %x, %add
+ ret i32 %rem
+}
+
+define i32 @test17(i32 %X) {
+; CHECK-LABEL: @test17(
+; CHECK-NEXT: icmp ne i32 %X, 1
+; CHECK-NEXT: zext i1
+; CHECK-NEXT: ret
+ %A = urem i32 1, %X
+ ret i32 %A
+}
+
+define i32 @test18(i16 %x, i32 %y) {
+; CHECK: @test18
+; CHECK-NEXT: [[AND:%.*]] = and i16 %x, 4
+; CHECK-NEXT: [[EXT:%.*]] = zext i16 [[AND]] to i32
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[EXT]], 3
+; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[SHL]], 63
+; CHECK-NEXT: [[REM:%.*]] = and i32 [[XOR]], %y
+; CHECK-NEXT: ret i32 [[REM]]
+ %1 = and i16 %x, 4
+ %2 = icmp ne i16 %1, 0
+ %3 = select i1 %2, i32 32, i32 64
+ %4 = urem i32 %y, %3
+ ret i32 %4
+}
+
+define i32 @test19(i32 %x, i32 %y) {
+; CHECK: @test19
+; CHECK-NEXT: [[SHL1:%.*]] = shl i32 1, %x
+; CHECK-NEXT: [[SHL2:%.*]] = shl i32 1, %y
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[SHL1]], [[SHL2]]
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[AND]], [[SHL1]]
+; CHECK-NEXT: [[SUB:%.*]] = add i32 [[ADD]], -1
+; CHECK-NEXT: [[REM:%.*]] = and i32 [[SUB]], %y
+; CHECK-NEXT: ret i32 [[REM]]
+ %A = shl i32 1, %x
+ %B = shl i32 1, %y
+ %C = and i32 %A, %B
+ %D = add i32 %C, %A
+ %E = urem i32 %y, %D
+ ret i32 %E
+}
diff --git a/test/Transforms/InstCombine/select-2.ll b/test/Transforms/InstCombine/select-2.ll
index a76addc9942b..5b9deb4515a8 100644
--- a/test/Transforms/InstCombine/select-2.ll
+++ b/test/Transforms/InstCombine/select-2.ll
@@ -1,4 +1,7 @@
-; RUN: opt < %s -instcombine -S | grep select | count 2
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; CHECK: select
+; CHECK: select
; Make sure instcombine don't fold select into operands. We don't want to emit
; select of two integers unless it's selecting 0 / 1.
diff --git a/test/Transforms/InstCombine/select-crash.ll b/test/Transforms/InstCombine/select-crash.ll
index 946ea2b8b70c..77446cd8ba02 100644
--- a/test/Transforms/InstCombine/select-crash.ll
+++ b/test/Transforms/InstCombine/select-crash.ll
@@ -21,7 +21,7 @@ entry:
; PR10180: same crash, but with vectors
define <4 x float> @foo(i1 %b, <4 x float> %x, <4 x float> %y, <4 x float> %z) {
-; CHECK: @foo
+; CHECK-LABEL: @foo(
; CHECK: fsub <4 x float>
; CHECK: select
; CHECK: fadd <4 x float>
@@ -31,7 +31,7 @@ define <4 x float> @foo(i1 %b, <4 x float> %x, <4 x float> %y, <4 x float> %z) {
ret <4 x float> %sel
}
-; CHECK: @test3
+; CHECK-LABEL: @test3(
define i32 @test3(i1 %bool, i32 %a) {
entry:
%cond = or i1 %bool, true
diff --git a/test/Transforms/InstCombine/select-extractelement.ll b/test/Transforms/InstCombine/select-extractelement.ll
new file mode 100644
index 000000000000..e7ea851d9214
--- /dev/null
+++ b/test/Transforms/InstCombine/select-extractelement.ll
@@ -0,0 +1,102 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+declare void @v4float_user(<4 x float>) #0
+
+
+
+define float @extract_one_select(<4 x float> %a, <4 x float> %b, i32 %c) #0 {
+; CHECK-LABEL: @extract_one_select(
+; CHECK-NOT: select i1 {{.*}}, <4 x float>
+ %cmp = icmp ne i32 %c, 0
+ %sel = select i1 %cmp, <4 x float> %a, <4 x float> %b
+ %extract = extractelement <4 x float> %sel, i32 2
+ ret float %extract
+}
+
+; Multiple extractelements
+define <2 x float> @extract_two_select(<4 x float> %a, <4 x float> %b, i32 %c) #0 {
+; CHECK-LABEL: @extract_two_select(
+; CHECK: select i1 {{.*}}, <4 x float>
+ %cmp = icmp ne i32 %c, 0
+ %sel = select i1 %cmp, <4 x float> %a, <4 x float> %b
+ %extract1 = extractelement <4 x float> %sel, i32 1
+ %extract2 = extractelement <4 x float> %sel, i32 2
+ %build1 = insertelement <2 x float> undef, float %extract1, i32 0
+ %build2 = insertelement <2 x float> %build1, float %extract2, i32 1
+ ret <2 x float> %build2
+}
+
+; Select has an extra non-extractelement user, don't change it
+define float @extract_one_select_user(<4 x float> %a, <4 x float> %b, i32 %c) #0 {
+; CHECK-LABEL: @extract_one_select_user(
+; CHECK: select i1 {{.*}}, <4 x float>
+ %cmp = icmp ne i32 %c, 0
+ %sel = select i1 %cmp, <4 x float> %a, <4 x float> %b
+ %extract = extractelement <4 x float> %sel, i32 2
+ call void @v4float_user(<4 x float> %sel)
+ ret float %extract
+}
+
+define float @extract_one_vselect_user(<4 x float> %a, <4 x float> %b, <4 x i32> %c) #0 {
+; CHECK-LABEL: @extract_one_vselect_user(
+; CHECK: select <4 x i1> {{.*}}, <4 x float>
+ %cmp = icmp ne <4 x i32> %c, zeroinitializer
+ %sel = select <4 x i1> %cmp, <4 x float> %a, <4 x float> %b
+ %extract = extractelement <4 x float> %sel, i32 2
+ call void @v4float_user(<4 x float> %sel)
+ ret float %extract
+}
+
+; Extract from a vector select
+define float @extract_one_vselect(<4 x float> %a, <4 x float> %b, <4 x i32> %c) #0 {
+; CHECK-LABEL: @extract_one_vselect(
+; CHECK-NOT: select <4 x i1>
+ %cmp = icmp ne <4 x i32> %c, zeroinitializer
+ %select = select <4 x i1> %cmp, <4 x float> %a, <4 x float> %b
+ %extract = extractelement <4 x float> %select, i32 0
+ ret float %extract
+}
+
+; Multiple extractelements from a vector select
+define <2 x float> @extract_two_vselect(<4 x float> %a, <4 x float> %b, <4 x i32> %c) #0 {
+; CHECK-LABEL: @extract_two_vselect(
+; CHECK-NOT: select i1 {{.*}}, <4 x float>
+ %cmp = icmp ne <4 x i32> %c, zeroinitializer
+ %sel = select <4 x i1> %cmp, <4 x float> %a, <4 x float> %b
+ %extract1 = extractelement <4 x float> %sel, i32 1
+ %extract2 = extractelement <4 x float> %sel, i32 2
+ %build1 = insertelement <2 x float> undef, float %extract1, i32 0
+ %build2 = insertelement <2 x float> %build1, float %extract2, i32 1
+ ret <2 x float> %build2
+}
+
+; All the vector selects should be decomposed into scalar selects
+; Test multiple extractelements
+define <4 x float> @simple_vector_select(<4 x float> %a, <4 x float> %b, <4 x i32> %c) #0 {
+; CHECK-LABEL: @simple_vector_select(
+; CHECK-NOT: select i1 {{.*}}, <4 x float>
+entry:
+ %0 = extractelement <4 x i32> %c, i32 0
+ %tobool = icmp ne i32 %0, 0
+ %a.sink = select i1 %tobool, <4 x float> %a, <4 x float> %b
+ %1 = extractelement <4 x float> %a.sink, i32 0
+ %2 = insertelement <4 x float> undef, float %1, i32 0
+ %3 = extractelement <4 x i32> %c, i32 1
+ %tobool1 = icmp ne i32 %3, 0
+ %a.sink1 = select i1 %tobool1, <4 x float> %a, <4 x float> %b
+ %4 = extractelement <4 x float> %a.sink1, i32 1
+ %5 = insertelement <4 x float> %2, float %4, i32 1
+ %6 = extractelement <4 x i32> %c, i32 2
+ %tobool6 = icmp ne i32 %6, 0
+ %a.sink2 = select i1 %tobool6, <4 x float> %a, <4 x float> %b
+ %7 = extractelement <4 x float> %a.sink2, i32 2
+ %8 = insertelement <4 x float> %5, float %7, i32 2
+ %9 = extractelement <4 x i32> %c, i32 3
+ %tobool11 = icmp ne i32 %9, 0
+ %a.sink3 = select i1 %tobool11, <4 x float> %a, <4 x float> %b
+ %10 = extractelement <4 x float> %a.sink3, i32 3
+ %11 = insertelement <4 x float> %8, float %10, i32 3
+ ret <4 x float> %11
+}
+
+attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
diff --git a/test/Transforms/InstCombine/select.ll b/test/Transforms/InstCombine/select.ll
index c72a6f7c49c6..1458bde82124 100644
--- a/test/Transforms/InstCombine/select.ll
+++ b/test/Transforms/InstCombine/select.ll
@@ -6,14 +6,14 @@
define i32 @test1(i32 %A, i32 %B) {
%C = select i1 false, i32 %A, i32 %B
ret i32 %C
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 %B
}
define i32 @test2(i32 %A, i32 %B) {
%C = select i1 true, i32 %A, i32 %B
ret i32 %C
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret i32 %A
}
@@ -22,7 +22,7 @@ define i32 @test3(i1 %C, i32 %I) {
; V = I
%V = select i1 %C, i32 %I, i32 %I
ret i32 %V
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i32 %I
}
@@ -30,7 +30,7 @@ define i1 @test4(i1 %C) {
; V = C
%V = select i1 %C, i1 true, i1 false
ret i1 %V
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ret i1 %C
}
@@ -38,7 +38,7 @@ define i1 @test5(i1 %C) {
; V = !C
%V = select i1 %C, i1 false, i1 true
ret i1 %V
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: xor i1 %C, true
; CHECK: ret i1
}
@@ -47,7 +47,7 @@ define i32 @test6(i1 %C) {
; V = cast C to int
%V = select i1 %C, i32 1, i32 0
ret i32 %V
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: %V = zext i1 %C to i32
; CHECK: ret i32 %V
}
@@ -56,7 +56,7 @@ define i1 @test7(i1 %C, i1 %X) {
; R = or C, X
%R = select i1 %C, i1 true, i1 %X
ret i1 %R
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %R = or i1 %C, %X
; CHECK: ret i1 %R
}
@@ -65,7 +65,7 @@ define i1 @test8(i1 %C, i1 %X) {
; R = and C, X
%R = select i1 %C, i1 %X, i1 false
ret i1 %R
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: %R = and i1 %C, %X
; CHECK: ret i1 %R
}
@@ -74,7 +74,7 @@ define i1 @test9(i1 %C, i1 %X) {
; R = and !C, X
%R = select i1 %C, i1 false, i1 %X
ret i1 %R
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: xor i1 %C, true
; CHECK: %R = and i1
; CHECK: ret i1 %R
@@ -84,7 +84,7 @@ define i1 @test10(i1 %C, i1 %X) {
; R = or !C, X
%R = select i1 %C, i1 %X, i1 true
ret i1 %R
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: xor i1 %C, true
; CHECK: %R = or i1
; CHECK: ret i1 %R
@@ -94,7 +94,7 @@ define i32 @test11(i32 %a) {
%C = icmp eq i32 %a, 0
%R = select i1 %C, i32 0, i32 1
ret i32 %R
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: icmp ne i32 %a, 0
; CHECK: %R = zext i1
; CHECK: ret i32 %R
@@ -104,7 +104,7 @@ define i32 @test12(i1 %cond, i32 %a) {
%b = or i32 %a, 1
%c = select i1 %cond, i32 %b, i32 %a
ret i32 %c
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK: %b = zext i1 %cond to i32
; CHECK: %c = or i32 %b, %a
; CHECK: ret i32 %c
@@ -114,7 +114,7 @@ define i32 @test12a(i1 %cond, i32 %a) {
%b = ashr i32 %a, 1
%c = select i1 %cond, i32 %b, i32 %a
ret i32 %c
-; CHECK: @test12a
+; CHECK-LABEL: @test12a(
; CHECK: %b = zext i1 %cond to i32
; CHECK: %c = ashr i32 %a, %b
; CHECK: ret i32 %c
@@ -124,7 +124,7 @@ define i32 @test12b(i1 %cond, i32 %a) {
%b = ashr i32 %a, 1
%c = select i1 %cond, i32 %a, i32 %b
ret i32 %c
-; CHECK: @test12b
+; CHECK-LABEL: @test12b(
; CHECK: zext i1 %cond to i32
; CHECK: %b = xor i32
; CHECK: %c = ashr i32 %a, %b
@@ -135,7 +135,7 @@ define i32 @test13(i32 %a, i32 %b) {
%C = icmp eq i32 %a, %b
%V = select i1 %C, i32 %a, i32 %b
ret i32 %V
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: ret i32 %b
}
@@ -143,7 +143,7 @@ define i32 @test13a(i32 %a, i32 %b) {
%C = icmp ne i32 %a, %b
%V = select i1 %C, i32 %a, i32 %b
ret i32 %V
-; CHECK: @test13a
+; CHECK-LABEL: @test13a(
; CHECK: ret i32 %a
}
@@ -151,7 +151,7 @@ define i32 @test13b(i32 %a, i32 %b) {
%C = icmp eq i32 %a, %b
%V = select i1 %C, i32 %b, i32 %a
ret i32 %V
-; CHECK: @test13b
+; CHECK-LABEL: @test13b(
; CHECK: ret i32 %a
}
@@ -160,7 +160,7 @@ define i1 @test14a(i1 %C, i32 %X) {
; (X < 1) | !C
%R = icmp slt i32 %V, 1
ret i1 %R
-; CHECK: @test14a
+; CHECK-LABEL: @test14a(
; CHECK: icmp slt i32 %X, 1
; CHECK: xor i1 %C, true
; CHECK: or i1
@@ -172,7 +172,7 @@ define i1 @test14b(i1 %C, i32 %X) {
; (X < 1) | C
%R = icmp slt i32 %V, 1
ret i1 %R
-; CHECK: @test14b
+; CHECK-LABEL: @test14b(
; CHECK: icmp slt i32 %X, 1
; CHECK: or i1
; CHECK: ret i1 %R
@@ -184,7 +184,7 @@ define i32 @test15a(i32 %X) {
%t2 = icmp eq i32 %t1, 0
%t3 = select i1 %t2, i32 0, i32 16
ret i32 %t3
-; CHECK: @test15a
+; CHECK-LABEL: @test15a(
; CHECK: %t1 = and i32 %X, 16
; CHECK: ret i32 %t1
}
@@ -195,7 +195,7 @@ define i32 @test15b(i32 %X) {
%t2 = icmp eq i32 %t1, 0
%t3 = select i1 %t2, i32 32, i32 0
ret i32 %t3
-; CHECK: @test15b
+; CHECK-LABEL: @test15b(
; CHECK: %t1 = and i32 %X, 32
; CHECK: xor i32 %t1, 32
; CHECK: ret i32
@@ -207,7 +207,7 @@ define i32 @test15c(i32 %X) {
%t2 = icmp eq i32 %t1, 16
%t3 = select i1 %t2, i32 16, i32 0
ret i32 %t3
-; CHECK: @test15c
+; CHECK-LABEL: @test15c(
; CHECK: %t1 = and i32 %X, 16
; CHECK: ret i32 %t1
}
@@ -218,7 +218,7 @@ define i32 @test15d(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 16, i32 0
ret i32 %t3
-; CHECK: @test15d
+; CHECK-LABEL: @test15d(
; CHECK: %t1 = and i32 %X, 16
; CHECK: ret i32 %t1
}
@@ -229,7 +229,7 @@ define i32 @test15e(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 256, i32 0
ret i32 %t3
-; CHECK: @test15e
+; CHECK-LABEL: @test15e(
; CHECK: %t1 = shl i32 %X, 1
; CHECK: and i32 %t1, 256
; CHECK: ret i32
@@ -241,7 +241,7 @@ define i32 @test15f(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 0, i32 256
ret i32 %t3
-; CHECK: @test15f
+; CHECK-LABEL: @test15f(
; CHECK: %t1 = shl i32 %X, 1
; CHECK: and i32 %t1, 256
; CHECK: xor i32 %{{.*}}, 256
@@ -254,7 +254,7 @@ define i32 @test15g(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 -1, i32 -9
ret i32 %t3
-; CHECK: @test15g
+; CHECK-LABEL: @test15g(
; CHECK-NEXT: %1 = or i32 %X, -9
; CHECK-NEXT: ret i32 %1
}
@@ -265,7 +265,7 @@ define i32 @test15h(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 -9, i32 -1
ret i32 %t3
-; CHECK: @test15h
+; CHECK-LABEL: @test15h(
; CHECK-NEXT: %1 = or i32 %X, -9
; CHECK-NEXT: %2 = xor i32 %1, 8
; CHECK-NEXT: ret i32 %2
@@ -277,7 +277,7 @@ define i32 @test15i(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 577, i32 1089
ret i32 %t3
-; CHECK: @test15i
+; CHECK-LABEL: @test15i(
; CHECK-NEXT: %t1 = shl i32 %X, 8
; CHECK-NEXT: %1 = and i32 %t1, 512
; CHECK-NEXT: %2 = xor i32 %1, 512
@@ -291,7 +291,7 @@ define i32 @test15j(i32 %X) {
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 1089, i32 577
ret i32 %t3
-; CHECK: @test15j
+; CHECK-LABEL: @test15j(
; CHECK-NEXT: %t1 = shl i32 %X, 8
; CHECK-NEXT: %1 = and i32 %t1, 512
; CHECK-NEXT: %2 = add i32 %1, 577
@@ -302,7 +302,7 @@ define i32 @test16(i1 %C, i32* %P) {
%P2 = select i1 %C, i32* %P, i32* null
%V = load i32* %P2
ret i32 %V
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK-NEXT: %V = load i32* %P
; CHECK: ret i32 %V
}
@@ -311,7 +311,7 @@ define i1 @test17(i32* %X, i1 %C) {
%R = select i1 %C, i32* %X, i32* null
%RV = icmp eq i32* %R, null
ret i1 %RV
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK: icmp eq i32* %X, null
; CHECK: xor i1 %C, true
; CHECK: %RV = or i1
@@ -322,7 +322,7 @@ define i32 @test18(i32 %X, i32 %Y, i1 %C) {
%R = select i1 %C, i32 %X, i32 0
%V = sdiv i32 %Y, %R
ret i32 %V
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: %V = sdiv i32 %Y, %X
; CHECK: ret i32 %V
}
@@ -331,7 +331,7 @@ define i32 @test19(i32 %x) {
%tmp = icmp ugt i32 %x, 2147483647
%retval = select i1 %tmp, i32 -1, i32 0
ret i32 %retval
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK-NEXT: ashr i32 %x, 31
; CHECK-NEXT: ret i32
}
@@ -340,7 +340,7 @@ define i32 @test20(i32 %x) {
%tmp = icmp slt i32 %x, 0
%retval = select i1 %tmp, i32 -1, i32 0
ret i32 %retval
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK-NEXT: ashr i32 %x, 31
; CHECK-NEXT: ret i32
}
@@ -349,7 +349,7 @@ define i64 @test21(i32 %x) {
%tmp = icmp slt i32 %x, 0
%retval = select i1 %tmp, i64 -1, i64 0
ret i64 %retval
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK-NEXT: ashr i32 %x, 31
; CHECK-NEXT: sext i32
; CHECK-NEXT: ret i64
@@ -359,7 +359,7 @@ define i16 @test22(i32 %x) {
%tmp = icmp slt i32 %x, 0
%retval = select i1 %tmp, i16 -1, i16 0
ret i16 %retval
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK-NEXT: ashr i32 %x, 31
; CHECK-NEXT: trunc i32
; CHECK-NEXT: ret i16
@@ -368,7 +368,7 @@ define i16 @test22(i32 %x) {
define i1 @test23(i1 %a, i1 %b) {
%c = select i1 %a, i1 %b, i1 %a
ret i1 %c
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK-NEXT: %c = and i1 %a, %b
; CHECK-NEXT: ret i1 %c
}
@@ -376,7 +376,7 @@ define i1 @test23(i1 %a, i1 %b) {
define i1 @test24(i1 %a, i1 %b) {
%c = select i1 %a, i1 %a, i1 %b
ret i1 %c
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK-NEXT: %c = or i1 %a, %b
; CHECK-NEXT: ret i1 %c
}
@@ -390,7 +390,7 @@ ret:
%a = phi i1 [true, %jump], [false, %entry]
%b = select i1 %a, i32 10, i32 20
ret i32 %b
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK: %a = phi i32 [ 10, %jump ], [ 20, %entry ]
; CHECK-NEXT: ret i32 %a
}
@@ -405,7 +405,7 @@ ret:
%a = phi i1 [true, %jump], [%c, %entry]
%b = select i1 %a, i32 10, i32 20
ret i32 %b
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK: %a = phi i32 [ 10, %jump ], [ 20, %entry ]
; CHECK-NEXT: ret i32 %a
}
@@ -419,7 +419,7 @@ ret:
%a = phi i1 [true, %jump], [false, %entry]
%b = select i1 %a, i32 %A, i32 %B
ret i32 %b
-; CHECK: @test27
+; CHECK-LABEL: @test27(
; CHECK: %a = phi i32 [ %A, %jump ], [ %B, %entry ]
; CHECK-NEXT: ret i32 %a
}
@@ -434,7 +434,7 @@ ret:
%a = phi i1 [true, %jump], [false, %entry]
%b = select i1 %a, i32 %A, i32 %c
ret i32 %b
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; CHECK: %a = phi i32 [ %A, %jump ], [ %B, %entry ]
; CHECK-NEXT: ret i32 %a
}
@@ -452,7 +452,7 @@ ret:
next:
%b = select i1 %a, i32 %A, i32 %c
ret i32 %b
-; CHECK: @test29
+; CHECK-LABEL: @test29(
; CHECK: %a = phi i32 [ %A, %jump ], [ %B, %entry ]
; CHECK: ret i32 %a
}
@@ -466,7 +466,7 @@ define i32 @test30(i32 %x, i32 %y) {
%cmp5 = icmp sgt i32 %cond, %x
%retval = select i1 %cmp5, i32 %cond, i32 %x
ret i32 %retval
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; CHECK: ret i32 %cond
}
@@ -477,7 +477,7 @@ define i32 @test31(i32 %x, i32 %y) {
%cmp5 = icmp ugt i32 %cond, %x
%retval = select i1 %cmp5, i32 %cond, i32 %x
ret i32 %retval
-; CHECK: @test31
+; CHECK-LABEL: @test31(
; CHECK: ret i32 %cond
}
@@ -488,7 +488,7 @@ define i32 @test32(i32 %x, i32 %y) {
%cmp5 = icmp sgt i32 %cond, %x
%retval = select i1 %cmp5, i32 %x, i32 %cond
ret i32 %retval
-; CHECK: @test32
+; CHECK-LABEL: @test32(
; CHECK: ret i32 %cond
}
@@ -499,7 +499,7 @@ define i32 @test33(i32 %x, i32 %y) {
%cmp5 = icmp sgt i32 %cond, %x
%retval = select i1 %cmp5, i32 %cond, i32 %x
ret i32 %retval
-; CHECK: @test33
+; CHECK-LABEL: @test33(
; CHECK: ret i32 %x
}
@@ -510,7 +510,7 @@ define i32 @test34(i32 %x, i32 %y) {
%cmp5 = icmp sgt i32 %cond, %x
%retval = select i1 %cmp5, i32 %x, i32 %cond
ret i32 %retval
-; CHECK: @test34
+; CHECK-LABEL: @test34(
; CHECK: ret i32 %x
}
@@ -518,7 +518,7 @@ define i32 @test35(i32 %x) {
%cmp = icmp sge i32 %x, 0
%cond = select i1 %cmp, i32 60, i32 100
ret i32 %cond
-; CHECK: @test35
+; CHECK-LABEL: @test35(
; CHECK: ashr i32 %x, 31
; CHECK: and i32 {{.*}}, 40
; CHECK: add i32 {{.*}}, 60
@@ -529,7 +529,7 @@ define i32 @test36(i32 %x) {
%cmp = icmp slt i32 %x, 0
%cond = select i1 %cmp, i32 60, i32 100
ret i32 %cond
-; CHECK: @test36
+; CHECK-LABEL: @test36(
; CHECK: ashr i32 %x, 31
; CHECK: and i32 {{.*}}, -40
; CHECK: add i32 {{.*}}, 100
@@ -540,7 +540,7 @@ define i32 @test37(i32 %x) {
%cmp = icmp sgt i32 %x, -1
%cond = select i1 %cmp, i32 1, i32 -1
ret i32 %cond
-; CHECK: @test37
+; CHECK-LABEL: @test37(
; CHECK: ashr i32 %x, 31
; CHECK: or i32 {{.*}}, 1
; CHECK: ret
@@ -552,7 +552,7 @@ define i1 @test38(i1 %cond) {
%ptr = select i1 %cond, i32* %zero, i32* %one
%isnull = icmp eq i32* %ptr, null
ret i1 %isnull
-; CHECK: @test38
+; CHECK-LABEL: @test38(
; CHECK: ret i1 false
}
@@ -560,7 +560,7 @@ define i1 @test39(i1 %cond, double %x) {
%s = select i1 %cond, double %x, double 0x7FF0000000000000 ; RHS = +infty
%cmp = fcmp ule double %x, %s
ret i1 %cmp
-; CHECK: @test39
+; CHECK-LABEL: @test39(
; CHECK: ret i1 true
}
@@ -571,7 +571,7 @@ define i1 @test40(i1 %cond) {
%s = select i1 %cond, i32* %a, i32* %b
%r = icmp eq i32* %s, %c
ret i1 %r
-; CHECK: @test40
+; CHECK-LABEL: @test40(
; CHECK: ret i1 false
}
@@ -580,7 +580,7 @@ define i32 @test41(i1 %cond, i32 %x, i32 %y) {
%s = select i1 %cond, i32 %y, i32 %z
%r = and i32 %x, %s
ret i32 %r
-; CHECK: @test41
+; CHECK-LABEL: @test41(
; CHECK-NEXT: and i32 %x, %y
; CHECK-NEXT: ret i32
}
@@ -590,7 +590,7 @@ define i32 @test42(i32 %x, i32 %y) {
%cond = icmp eq i32 %x, 0
%c = select i1 %cond, i32 %b, i32 %y
ret i32 %c
-; CHECK: @test42
+; CHECK-LABEL: @test42(
; CHECK-NEXT: %cond = icmp eq i32 %x, 0
; CHECK-NEXT: %b = sext i1 %cond to i32
; CHECK-NEXT: %c = add i32 %b, %y
@@ -602,7 +602,7 @@ define i64 @test43(i32 %a) nounwind {
%is_a_nonnegative = icmp sgt i32 %a, -1
%max = select i1 %is_a_nonnegative, i64 %a_ext, i64 0
ret i64 %max
-; CHECK: @test43
+; CHECK-LABEL: @test43(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonnegative = icmp slt i64 %a_ext, 0
; CHECK-NEXT: %max = select i1 %is_a_nonnegative, i64 0, i64 %a_ext
@@ -614,7 +614,7 @@ define i64 @test44(i32 %a) nounwind {
%is_a_nonpositive = icmp slt i32 %a, 1
%min = select i1 %is_a_nonpositive, i64 %a_ext, i64 0
ret i64 %min
-; CHECK: @test44
+; CHECK-LABEL: @test44(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonpositive = icmp sgt i64 %a_ext, 0
; CHECK-NEXT: %min = select i1 %is_a_nonpositive, i64 0, i64 %a_ext
@@ -625,7 +625,7 @@ define i64 @test45(i32 %a) nounwind {
%is_a_nonnegative = icmp ugt i32 %a, 2
%max = select i1 %is_a_nonnegative, i64 %a_ext, i64 3
ret i64 %max
-; CHECK: @test45
+; CHECK-LABEL: @test45(
; CHECK-NEXT: %a_ext = zext i32 %a to i64
; CHECK-NEXT: %is_a_nonnegative = icmp ult i64 %a_ext, 3
; CHECK-NEXT: %max = select i1 %is_a_nonnegative, i64 3, i64 %a_ext
@@ -637,7 +637,7 @@ define i64 @test46(i32 %a) nounwind {
%is_a_nonpositive = icmp ult i32 %a, 3
%min = select i1 %is_a_nonpositive, i64 %a_ext, i64 2
ret i64 %min
-; CHECK: @test46
+; CHECK-LABEL: @test46(
; CHECK-NEXT: %a_ext = zext i32 %a to i64
; CHECK-NEXT: %is_a_nonpositive = icmp ugt i64 %a_ext, 2
; CHECK-NEXT: %min = select i1 %is_a_nonpositive, i64 2, i64 %a_ext
@@ -648,7 +648,7 @@ define i64 @test47(i32 %a) nounwind {
%is_a_nonnegative = icmp ugt i32 %a, 2
%max = select i1 %is_a_nonnegative, i64 %a_ext, i64 3
ret i64 %max
-; CHECK: @test47
+; CHECK-LABEL: @test47(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonnegative = icmp ult i64 %a_ext, 3
; CHECK-NEXT: %max = select i1 %is_a_nonnegative, i64 3, i64 %a_ext
@@ -660,7 +660,7 @@ define i64 @test48(i32 %a) nounwind {
%is_a_nonpositive = icmp ult i32 %a, 3
%min = select i1 %is_a_nonpositive, i64 %a_ext, i64 2
ret i64 %min
-; CHECK: @test48
+; CHECK-LABEL: @test48(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonpositive = icmp ugt i64 %a_ext, 2
; CHECK-NEXT: %min = select i1 %is_a_nonpositive, i64 2, i64 %a_ext
@@ -672,7 +672,7 @@ define i64 @test49(i32 %a) nounwind {
%is_a_nonpositive = icmp ult i32 %a, 3
%min = select i1 %is_a_nonpositive, i64 2, i64 %a_ext
ret i64 %min
-; CHECK: @test49
+; CHECK-LABEL: @test49(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonpositive = icmp ugt i64 %a_ext, 2
; CHECK-NEXT: %min = select i1 %is_a_nonpositive, i64 %a_ext, i64 2
@@ -683,7 +683,7 @@ define i64 @test50(i32 %a) nounwind {
%a_ext = sext i32 %a to i64
%min = select i1 %is_a_nonpositive, i64 2, i64 %a_ext
ret i64 %min
-; CHECK: @test50
+; CHECK-LABEL: @test50(
; CHECK-NEXT: %a_ext = sext i32 %a to i64
; CHECK-NEXT: %is_a_nonpositive = icmp ugt i64 %a_ext, 2
; CHECK-NEXT: %min = select i1 %is_a_nonpositive, i64 %a_ext, i64 2
@@ -695,7 +695,7 @@ define i64 @test50(i32 %a) nounwind {
; This select instruction can't be eliminated because trying to do so would
; change the number of vector elements. This used to assert.
define i48 @test51(<3 x i1> %icmp, <3 x i16> %tmp) {
-; CHECK: @test51
+; CHECK-LABEL: @test51(
%select = select <3 x i1> %icmp, <3 x i16> zeroinitializer, <3 x i16> %tmp
; CHECK: select <3 x i1>
%tmp2 = bitcast <3 x i16> %select to i48
@@ -705,7 +705,7 @@ define i48 @test51(<3 x i1> %icmp, <3 x i16> %tmp) {
; PR8575
define i32 @test52(i32 %n, i32 %m) nounwind {
-; CHECK: @test52
+; CHECK-LABEL: @test52(
%cmp = icmp sgt i32 %n, %m
%. = select i1 %cmp, i32 1, i32 3
%add = add nsw i32 %., 3
@@ -720,7 +720,7 @@ define i32 @test53(i32 %x) nounwind {
%cmp = icmp eq i32 %and, %x
%sel = select i1 %cmp, i32 2, i32 1
ret i32 %sel
-; CHECK: @test53
+; CHECK-LABEL: @test53(
; CHECK: select i1 %cmp
; CHECK: ret
}
@@ -730,7 +730,7 @@ define i32 @test54(i32 %X, i32 %Y) {
%B = icmp eq i32 %A, 0
%C = select i1 %B, i32 %A, i32 1
ret i32 %C
-; CHECK: @test54
+; CHECK-LABEL: @test54(
; CHECK-NOT: ashr
; CHECK-NOT: select
; CHECK: icmp ne i32 %X, 0
@@ -743,7 +743,7 @@ define i1 @test55(i1 %X, i32 %Y, i32 %Z) {
%B = select i1 %X, i32 %Y, i32 %A
%C = icmp eq i32 %B, 0
ret i1 %C
-; CHECK: @test55
+; CHECK-LABEL: @test55(
; CHECK-NOT: ashr
; CHECK-NOT: select
; CHECK: icmp eq
@@ -755,7 +755,7 @@ define i32 @test56(i16 %x) nounwind {
%conv = zext i16 %x to i32
%cond = select i1 %tobool, i32 0, i32 %conv
ret i32 %cond
-; CHECK: @test56
+; CHECK-LABEL: @test56(
; CHECK-NEXT: zext
; CHECK-NEXT: ret
}
@@ -765,7 +765,7 @@ define i32 @test57(i32 %x, i32 %y) nounwind {
%tobool = icmp eq i32 %x, 0
%.and = select i1 %tobool, i32 0, i32 %and
ret i32 %.and
-; CHECK: @test57
+; CHECK-LABEL: @test57(
; CHECK-NEXT: and i32 %x, %y
; CHECK-NEXT: ret
}
@@ -775,7 +775,7 @@ define i32 @test58(i16 %x) nounwind {
%conv = zext i16 %x to i32
%cond = select i1 %tobool, i32 %conv, i32 1
ret i32 %cond
-; CHECK: @test58
+; CHECK-LABEL: @test58(
; CHECK-NEXT: zext
; CHECK-NEXT: ret
}
@@ -785,7 +785,7 @@ define i32 @test59(i32 %x, i32 %y) nounwind {
%tobool = icmp ne i32 %x, %y
%.and = select i1 %tobool, i32 %and, i32 %y
ret i32 %.and
-; CHECK: @test59
+; CHECK-LABEL: @test59(
; CHECK-NEXT: and i32 %x, %y
; CHECK-NEXT: ret
}
@@ -796,7 +796,7 @@ define i1 @test60(i32 %x, i1* %y) nounwind {
%cmp1 = icmp slt i32 %x, 1
%sel = select i1 %cmp, i1 %load, i1 %cmp1
ret i1 %sel
-; CHECK: @test60
+; CHECK-LABEL: @test60(
; CHECK: select
}
@@ -806,7 +806,7 @@ define i32 @test61(i32* %ptr) {
%B = icmp eq i32* %ptr, @glbl
%C = select i1 %B, i32 %A, i32 10
ret i32 %C
-; CHECK: @test61
+; CHECK-LABEL: @test61(
; CHECK: ret i32 10
}
@@ -814,7 +814,7 @@ define i1 @test62(i1 %A, i1 %B) {
%not = xor i1 %A, true
%C = select i1 %A, i1 %not, i1 %B
ret i1 %C
-; CHECK: @test62
+; CHECK-LABEL: @test62(
; CHECK: %not = xor i1 %A, true
; CHECK: %C = and i1 %not, %B
; CHECK: ret i1 %C
@@ -824,7 +824,7 @@ define i1 @test63(i1 %A, i1 %B) {
%not = xor i1 %A, true
%C = select i1 %A, i1 %B, i1 %not
ret i1 %C
-; CHECK: @test63
+; CHECK-LABEL: @test63(
; CHECK: %not = xor i1 %A, true
; CHECK: %C = or i1 %B, %not
; CHECK: ret i1 %C
@@ -860,11 +860,11 @@ cond.end17:
while.body:
br label %while.body
-; CHECK: @test64
+; CHECK-LABEL: @test64(
; CHECK-NOT: select
}
-; CHECK: @select_icmp_eq_and_1_0_or_2
+; CHECK-LABEL: @select_icmp_eq_and_1_0_or_2(
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 %x, 1
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], 2
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[AND]], %y
@@ -877,7 +877,7 @@ define i32 @select_icmp_eq_and_1_0_or_2(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_eq_and_32_0_or_8
+; CHECK-LABEL: @select_icmp_eq_and_32_0_or_8(
; CHECK-NEXT: [[LSHR:%[a-z0-9]+]] = lshr i32 %x, 2
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[LSHR]], 8
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[AND]], %y
@@ -890,7 +890,7 @@ define i32 @select_icmp_eq_and_32_0_or_8(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_ne_0_and_4096_or_4096
+; CHECK-LABEL: @select_icmp_ne_0_and_4096_or_4096(
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %x, 4096
; CHECK-NEXT: [[XOR:%[a-z0-9]+]] = xor i32 [[AND]], 4096
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[XOR]], %y
@@ -903,7 +903,7 @@ define i32 @select_icmp_ne_0_and_4096_or_4096(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_eq_and_4096_0_or_4096
+; CHECK-LABEL: @select_icmp_eq_and_4096_0_or_4096(
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %x, 4096
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[AND]], %y
; CHECK-NEXT: ret i32 [[OR]]
@@ -915,7 +915,7 @@ define i32 @select_icmp_eq_and_4096_0_or_4096(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_eq_0_and_1_or_1
+; CHECK-LABEL: @select_icmp_eq_0_and_1_or_1(
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i64 %x, 1
; CHECK-NEXT: [[ZEXT:%[a-z0-9]+]] = trunc i64 [[AND]] to i32
; CHECK-NEXT: [[OR:%[a-z0-9]+]] = or i32 [[XOR]], %y
@@ -928,7 +928,7 @@ define i32 @select_icmp_eq_0_and_1_or_1(i64 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_ne_0_and_4096_or_32
+; CHECK-LABEL: @select_icmp_ne_0_and_4096_or_32(
; CHECK-NEXT: [[LSHR:%[a-z0-9]+]] = lshr i32 %x, 7
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[LSHR]], 32
; CHECK-NEXT: [[XOR:%[a-z0-9]+]] = xor i32 [[AND]], 32
@@ -942,7 +942,7 @@ define i32 @select_icmp_ne_0_and_4096_or_32(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_ne_0_and_32_or_4096
+; CHECK-LABEL: @select_icmp_ne_0_and_32_or_4096(
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl i32 %x, 7
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[SHL]], 4096
; CHECK-NEXT: [[XOR:%[a-z0-9]+]] = xor i32 [[AND]], 4096
@@ -956,7 +956,7 @@ define i32 @select_icmp_ne_0_and_32_or_4096(i32 %x, i32 %y) {
ret i32 %select
}
-; CHECK: @select_icmp_ne_0_and_1073741824_or_8
+; CHECK-LABEL: @select_icmp_ne_0_and_1073741824_or_8(
; CHECK-NEXT: [[LSHR:%[a-z0-9]+]] = lshr i32 %x, 27
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 [[LSHR]], 8
; CHECK-NEXT: [[TRUNC:%[a-z0-9]+]] = trunc i32 [[AND]] to i8
@@ -971,7 +971,7 @@ define i8 @select_icmp_ne_0_and_1073741824_or_8(i32 %x, i8 %y) {
ret i8 %select
}
-; CHECK: @select_icmp_ne_0_and_8_or_1073741824
+; CHECK-LABEL: @select_icmp_ne_0_and_8_or_1073741824(
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i8 %x, 8
; CHECK-NEXT: [[ZEXT:%[a-z0-9]+]] = zext i8 [[AND]] to i32
; CHECK-NEXT: [[SHL:%[a-z0-9]+]] = shl nuw nsw i32 [[ZEXT]], 27
@@ -985,3 +985,49 @@ define i32 @select_icmp_ne_0_and_8_or_1073741824(i8 %x, i32 %y) {
%select = select i1 %cmp, i32 %y, i32 %or
ret i32 %select
}
+
+; We can't combine here, because the cmp is scalar and the or vector.
+; Just make sure we don't assert.
+define <2 x i32> @select_icmp_eq_and_1_0_or_vector_of_2s(i32 %x, <2 x i32> %y) {
+ %and = and i32 %x, 1
+ %cmp = icmp eq i32 %and, 0
+ %or = or <2 x i32> %y, <i32 2, i32 2>
+ %select = select i1 %cmp, <2 x i32> %y, <2 x i32> %or
+ ret <2 x i32> %select
+}
+
+define i32 @test65(i64 %x) {
+ %1 = and i64 %x, 16
+ %2 = icmp ne i64 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK-LABEL: @test65(
+; CHECK: and i64 %x, 16
+; CHECK: trunc i64 %1 to i32
+; CHECK: lshr exact i32 %2, 3
+; CHECK: xor i32 %3, 42
+}
+
+define i32 @test66(i64 %x) {
+ %1 = and i64 %x, 4294967296
+ %2 = icmp ne i64 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK-LABEL: @test66(
+; CHECK: select
+}
+
+define i32 @test67(i16 %x) {
+ %1 = and i16 %x, 4
+ %2 = icmp ne i16 %1, 0
+ %3 = select i1 %2, i32 40, i32 42
+ ret i32 %3
+
+; CHECK-LABEL: @test67(
+; CHECK: and i16 %x, 4
+; CHECK: zext i16 %1 to i32
+; CHECK: lshr exact i32 %2, 1
+; CHECK: xor i32 %3, 42
+}
diff --git a/test/Transforms/InstCombine/sext.ll b/test/Transforms/InstCombine/sext.ll
index 968f37c9c129..b8dfe2257b18 100644
--- a/test/Transforms/InstCombine/sext.ll
+++ b/test/Transforms/InstCombine/sext.ll
@@ -11,7 +11,7 @@ define i64 @test1(i32 %x) {
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: zext i32 %t
}
@@ -20,7 +20,7 @@ define i64 @test2(i32 %x) {
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: zext i32 %t
}
@@ -29,7 +29,7 @@ define i64 @test3(i32 %x) {
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: zext i32 %t
}
@@ -38,7 +38,7 @@ define i64 @test4(i32 %x) {
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: zext i32 %t
}
@@ -46,7 +46,7 @@ define i64 @test5(i32 %x) {
%t = urem i32 %x, 30000
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: zext i32 %t
}
@@ -55,7 +55,7 @@ define i64 @test6(i32 %x) {
%t = mul i32 %u, 3
%s = sext i32 %t to i64
ret i64 %s
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: zext i32 %t
}
@@ -64,7 +64,7 @@ define i64 @test7(i32 %x) {
%u = sub i32 20000, %t
%s = sext i32 %u to i64
ret i64 %s
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: zext i32 %u to i64
}
@@ -74,7 +74,7 @@ define i32 @test8(i8 %a, i32 %f, i1 %p, i32* %z) {
%s = trunc i32 %e to i16
%n = sext i16 %s to i32
ret i32 %n
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: %d = lshr i32 %f, 24
; CHECK: %n = select i1 %p, i32 %d, i32 0
; CHECK: ret i32 %n
@@ -92,7 +92,7 @@ F:
%V = phi i32 [%t2, %T], [42, %entry]
%W = trunc i32 %V to i16
ret i16 %W
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: T:
; CHECK-NEXT: br label %F
; CHECK: F:
@@ -108,7 +108,7 @@ entry:
%a = ashr i8 %tmp16, 6
%b = sext i8 %a to i32
ret i32 %b
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: shl i32 %i, 30
; CHECK-NEXT: ashr exact i32
; CHECK-NEXT: ret i32
@@ -120,7 +120,7 @@ define void @test11(<2 x i16> %srcA, <2 x i16> %srcB, <2 x i16>* %dst) {
%tmask = ashr <2 x i16> %sext, <i16 15, i16 15>
store <2 x i16> %tmask, <2 x i16>* %dst
ret void
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK-NEXT: icmp eq
; CHECK-NEXT: sext <2 x i1>
; CHECK-NEXT: store <2 x i16>
@@ -132,7 +132,7 @@ define i64 @test12(i32 %x) nounwind {
%sub = sub nsw i32 0, %shr
%conv = sext i32 %sub to i64
ret i64 %conv
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK: sext
; CHECK: ret
}
@@ -142,7 +142,7 @@ define i32 @test13(i32 %x) nounwind {
%cmp = icmp eq i32 %and, 0
%ext = sext i1 %cmp to i32
ret i32 %ext
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK-NEXT: %and = lshr i32 %x, 3
; CHECK-NEXT: %1 = and i32 %and, 1
; CHECK-NEXT: %sext = add i32 %1, -1
@@ -154,7 +154,7 @@ define i32 @test14(i16 %x) nounwind {
%cmp = icmp ne i16 %and, 16
%ext = sext i1 %cmp to i32
ret i32 %ext
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK-NEXT: %and = lshr i16 %x, 4
; CHECK-NEXT: %1 = and i16 %and, 1
; CHECK-NEXT: %sext = add i16 %1, -1
@@ -167,7 +167,7 @@ define i32 @test15(i32 %x) nounwind {
%cmp = icmp ne i32 %and, 0
%ext = sext i1 %cmp to i32
ret i32 %ext
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK-NEXT: %1 = shl i32 %x, 27
; CHECK-NEXT: %sext = ashr i32 %1, 31
; CHECK-NEXT: ret i32 %sext
@@ -178,7 +178,7 @@ define i32 @test16(i16 %x) nounwind {
%cmp = icmp eq i16 %and, 8
%ext = sext i1 %cmp to i32
ret i32 %ext
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK-NEXT: %1 = shl i16 %x, 12
; CHECK-NEXT: %sext = ashr i16 %1, 15
; CHECK-NEXT: %ext = sext i16 %sext to i32
@@ -189,7 +189,7 @@ define i32 @test17(i1 %x) nounwind {
%c1 = sext i1 %x to i32
%c2 = sub i32 0, %c1
ret i32 %c2
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK-NEXT: [[TEST17:%.*]] = zext i1 %x to i32
; CHECK-NEXT: ret i32 [[TEST17]]
}
diff --git a/test/Transforms/InstCombine/shift-sra.ll b/test/Transforms/InstCombine/shift-sra.ll
index a578bbe4d4fc..75235500d513 100644
--- a/test/Transforms/InstCombine/shift-sra.ll
+++ b/test/Transforms/InstCombine/shift-sra.ll
@@ -7,7 +7,7 @@ define i32 @test1(i32 %X, i8 %A) {
%Y = ashr i32 %X, %shift.upgrd.1 ; <i32> [#uses=1]
%Z = and i32 %Y, 1 ; <i32> [#uses=1]
ret i32 %Z
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: lshr i32 %X, %shift.upgrd.1
}
@@ -16,7 +16,7 @@ define i32 @test2(i8 %tmp) {
%tmp4 = add i32 %tmp3, 7 ; <i32> [#uses=1]
%tmp5 = ashr i32 %tmp4, 3 ; <i32> [#uses=1]
ret i32 %tmp5
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: lshr i32 %tmp4, 3
}
@@ -33,7 +33,7 @@ C:
%S = ashr i64 %P, 12
ret i64 %S
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: %P = phi i64
; CHECK-NEXT: ret i64 %P
}
@@ -52,7 +52,7 @@ C:
%S = ashr i64 %R, 12
ret i64 %S
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: %P = phi i64
; CHECK-NEXT: ret i64 %P
}
@@ -70,7 +70,7 @@ D:
%P = phi i32 [0, %A], [0, %B], [%Y, %C]
%S = ashr i32 %P, 16
ret i32 %S
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %P = phi i32
; CHECK-NEXT: ashr i32 %P, 16
E:
diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll
index 41f8aa9ee812..b1082f06ef74 100644
--- a/test/Transforms/InstCombine/shift.ll
+++ b/test/Transforms/InstCombine/shift.ll
@@ -3,14 +3,14 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @test1(i32 %A) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 %A
%B = shl i32 %A, 0 ; <i32> [#uses=1]
ret i32 %B
}
define i32 @test2(i8 %A) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret i32 0
%shift.upgrd.1 = zext i8 %A to i32 ; <i32> [#uses=1]
%B = shl i32 0, %shift.upgrd.1 ; <i32> [#uses=1]
@@ -18,14 +18,14 @@ define i32 @test2(i8 %A) {
}
define i32 @test3(i32 %A) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i32 %A
%B = ashr i32 %A, 0 ; <i32> [#uses=1]
ret i32 %B
}
define i32 @test4(i8 %A) {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ret i32 0
%shift.upgrd.2 = zext i8 %A to i32 ; <i32> [#uses=1]
%B = ashr i32 0, %shift.upgrd.2 ; <i32> [#uses=1]
@@ -34,35 +34,35 @@ define i32 @test4(i8 %A) {
define i32 @test5(i32 %A) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: ret i32 undef
%B = lshr i32 %A, 32 ;; shift all bits out
ret i32 %B
}
define i32 @test5a(i32 %A) {
-; CHECK: @test5a
+; CHECK-LABEL: @test5a(
; CHECK: ret i32 undef
%B = shl i32 %A, 32 ;; shift all bits out
ret i32 %B
}
define i32 @test5b() {
-; CHECK: @test5b
+; CHECK-LABEL: @test5b(
; CHECK: ret i32 -1
%B = ashr i32 undef, 2 ;; top two bits must be equal, so not undef
ret i32 %B
}
define i32 @test5b2(i32 %A) {
-; CHECK: @test5b2
+; CHECK-LABEL: @test5b2(
; CHECK: ret i32 -1
%B = ashr i32 undef, %A ;; top %A bits must be equal, so not undef
ret i32 %B
}
define i32 @test6(i32 %A) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: mul i32 %A, 6
; CHECK-NEXT: ret i32
%B = shl i32 %A, 1 ;; convert to an mul instruction
@@ -71,7 +71,7 @@ define i32 @test6(i32 %A) {
}
define i32 @test6a(i32 %A) {
-; CHECK: @test6a
+; CHECK-LABEL: @test6a(
; CHECK-NEXT: mul i32 %A, 6
; CHECK-NEXT: ret i32
%B = mul i32 %A, 3
@@ -80,7 +80,7 @@ define i32 @test6a(i32 %A) {
}
define i32 @test7(i8 %A) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: ret i32 -1
%shift.upgrd.3 = zext i8 %A to i32
%B = ashr i32 -1, %shift.upgrd.3 ;; Always equal to -1
@@ -89,7 +89,7 @@ define i32 @test7(i8 %A) {
;; (A << 5) << 3 === A << 8 == 0
define i8 @test8(i8 %A) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: ret i8 0
%B = shl i8 %A, 5 ; <i8> [#uses=1]
%C = shl i8 %B, 3 ; <i8> [#uses=1]
@@ -98,7 +98,7 @@ define i8 @test8(i8 %A) {
;; (A << 7) >> 7 === A & 1
define i8 @test9(i8 %A) {
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: and i8 %A, 1
; CHECK-NEXT: ret i8
%B = shl i8 %A, 7 ; <i8> [#uses=1]
@@ -110,7 +110,7 @@ define i8 @test9(i8 %A) {
;; (A >> 7) << 7 === A & 128
;; The shl may be valuable to scalar evolution.
define i8 @test10(i8 %A) {
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK-NEXT: and i8 %A, -128
; CHECK-NEXT: ret i8
%B = lshr i8 %A, 7 ; <i8> [#uses=1]
@@ -120,7 +120,7 @@ define i8 @test10(i8 %A) {
;; Allow the simplification when the lshr shift is exact.
define i8 @test10a(i8 %A) {
-; CHECK: @test10a
+; CHECK-LABEL: @test10a(
; CHECK-NEXT: ret i8 %A
%B = lshr exact i8 %A, 7
%C = shl i8 %B, 7
@@ -131,7 +131,7 @@ define i8 @test10a(i8 %A) {
;; (A >> 3) << 4 === (A & 0x1F) << 1
;; The shl may be valuable to scalar evolution.
define i8 @test11(i8 %A) {
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: shl i8
; CHECK-NEXT: ret i8
%a = mul i8 %A, 3 ; <i8> [#uses=1]
@@ -142,7 +142,7 @@ define i8 @test11(i8 %A) {
;; Allow the simplification in InstCombine when the lshr shift is exact.
define i8 @test11a(i8 %A) {
-; CHECK: @test11a
+; CHECK-LABEL: @test11a(
; CHECK-NEXT: mul i8 %A, 6
; CHECK-NEXT: ret i8
%a = mul i8 %A, 3
@@ -154,7 +154,7 @@ define i8 @test11a(i8 %A) {
;; This is deferred to DAGCombine unless %B is single-use.
;; (A >> 8) << 8 === A & -256
define i32 @test12(i32 %A) {
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NEXT: and i32 %A, -256
; CHECK-NEXT: ret i32
%B = ashr i32 %A, 8 ; <i32> [#uses=1]
@@ -166,7 +166,7 @@ define i32 @test12(i32 %A) {
;; (A >> 3) << 4 === (A & -8) * 2
;; The shl may be valuable to scalar evolution.
define i8 @test13(i8 %A) {
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: shl i8
; CHECK-NEXT: ret i8
%a = mul i8 %A, 3 ; <i8> [#uses=1]
@@ -176,7 +176,7 @@ define i8 @test13(i8 %A) {
}
define i8 @test13a(i8 %A) {
-; CHECK: @test13a
+; CHECK-LABEL: @test13a(
; CHECK-NEXT: mul i8 %A, 6
; CHECK-NEXT: ret i8
%a = mul i8 %A, 3
@@ -187,7 +187,7 @@ define i8 @test13a(i8 %A) {
;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
define i32 @test14(i32 %A) {
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK-NEXT: %B = and i32 %A, -19760
; CHECK-NEXT: or i32 %B, 19744
; CHECK-NEXT: ret i32
@@ -199,7 +199,7 @@ define i32 @test14(i32 %A) {
;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
define i32 @test14a(i32 %A) {
-; CHECK: @test14a
+; CHECK-LABEL: @test14a(
; CHECK-NEXT: and i32 %A, 77
; CHECK-NEXT: ret i32
%B = shl i32 %A, 4 ; <i32> [#uses=1]
@@ -209,7 +209,7 @@ define i32 @test14a(i32 %A) {
}
define i32 @test15(i1 %C) {
-; CHECK: @test15
+; CHECK-LABEL: @test15(
; CHECK-NEXT: select i1 %C, i32 12, i32 4
; CHECK-NEXT: ret i32
%A = select i1 %C, i32 3, i32 1 ; <i32> [#uses=1]
@@ -218,7 +218,7 @@ define i32 @test15(i1 %C) {
}
define i32 @test15a(i1 %C) {
-; CHECK: @test15a
+; CHECK-LABEL: @test15a(
; CHECK-NEXT: select i1 %C, i32 512, i32 128
; CHECK-NEXT: ret i32
%A = select i1 %C, i8 3, i8 1 ; <i8> [#uses=1]
@@ -228,7 +228,7 @@ define i32 @test15a(i1 %C) {
}
define i1 @test16(i32 %X) {
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK-NEXT: and i32 %X, 16
; CHECK-NEXT: icmp ne i32
; CHECK-NEXT: ret i1
@@ -239,7 +239,7 @@ define i1 @test16(i32 %X) {
}
define i1 @test17(i32 %A) {
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK-NEXT: and i32 %A, -8
; CHECK-NEXT: icmp eq i32
; CHECK-NEXT: ret i1
@@ -250,7 +250,7 @@ define i1 @test17(i32 %A) {
define i1 @test18(i8 %A) {
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: ret i1 false
%B = lshr i8 %A, 7 ; <i8> [#uses=1]
@@ -260,7 +260,7 @@ define i1 @test18(i8 %A) {
}
define i1 @test19(i32 %A) {
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK-NEXT: icmp ult i32 %A, 4
; CHECK-NEXT: ret i1
%B = ashr i32 %A, 2 ; <i32> [#uses=1]
@@ -271,18 +271,17 @@ define i1 @test19(i32 %A) {
define i1 @test19a(i32 %A) {
-; CHECK: @test19a
-; CHECK-NEXT: and i32 %A, -4
-; CHECK-NEXT: icmp eq i32
+; CHECK-LABEL: @test19a(
+; CHECK-NEXT: icmp ugt i32 %A, -5
; CHECK-NEXT: ret i1
%B = ashr i32 %A, 2 ; <i32> [#uses=1]
- ;; (X & -4) == -4
+ ;; X >u ~4
%C = icmp eq i32 %B, -1 ; <i1> [#uses=1]
ret i1 %C
}
define i1 @test20(i8 %A) {
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK: ret i1 false
%B = ashr i8 %A, 7 ; <i8> [#uses=1]
;; false
@@ -291,7 +290,7 @@ define i1 @test20(i8 %A) {
}
define i1 @test21(i8 %A) {
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK-NEXT: and i8 %A, 15
; CHECK-NEXT: icmp eq i8
; CHECK-NEXT: ret i1
@@ -301,7 +300,7 @@ define i1 @test21(i8 %A) {
}
define i1 @test22(i8 %A) {
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK-NEXT: and i8 %A, 15
; CHECK-NEXT: icmp eq i8
; CHECK-NEXT: ret i1
@@ -311,7 +310,7 @@ define i1 @test22(i8 %A) {
}
define i8 @test23(i32 %A) {
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK-NEXT: trunc i32 %A to i8
; CHECK-NEXT: ret i8
@@ -323,7 +322,7 @@ define i8 @test23(i32 %A) {
}
define i8 @test24(i8 %X) {
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK-NEXT: and i8 %X, 3
; CHECK-NEXT: ret i8
%Y = and i8 %X, -5 ; <i8> [#uses=1]
@@ -333,7 +332,7 @@ define i8 @test24(i8 %X) {
}
define i32 @test25(i32 %tmp.2, i32 %AA) {
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK-NEXT: and i32 %tmp.2, -131072
; CHECK-NEXT: add i32 %{{[^,]*}}, %AA
; CHECK-NEXT: and i32 %{{[^,]*}}, -131072
@@ -347,7 +346,7 @@ define i32 @test25(i32 %tmp.2, i32 %AA) {
;; handle casts between shifts.
define i32 @test26(i32 %A) {
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK-NEXT: and i32 %A, -2
; CHECK-NEXT: ret i32
%B = lshr i32 %A, 1 ; <i32> [#uses=1]
@@ -358,7 +357,7 @@ define i32 @test26(i32 %A) {
define i1 @test27(i32 %x) nounwind {
-; CHECK: @test27
+; CHECK-LABEL: @test27(
; CHECK-NEXT: and i32 %x, 8
; CHECK-NEXT: icmp ne i32
; CHECK-NEXT: ret i1
@@ -369,7 +368,7 @@ define i1 @test27(i32 %x) nounwind {
define i8 @test28(i8 %x) {
entry:
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; CHECK: icmp slt i8 %x, 0
; CHECK-NEXT: br i1
%tmp1 = lshr i8 %x, 7
@@ -386,7 +385,7 @@ bb2:
define i8 @test28a(i8 %x, i8 %y) {
entry:
; This shouldn't be transformed.
-; CHECK: @test28a
+; CHECK-LABEL: @test28a(
; CHECK: %tmp1 = lshr i8 %x, 7
; CHECK: %cond1 = icmp eq i8 %tmp1, 0
; CHECK: br i1 %cond1, label %bb2, label %bb1
@@ -407,7 +406,7 @@ entry:
%tmp917 = trunc i64 %tmp916 to i32
%tmp10 = lshr i32 %tmp917, 31
ret i32 %tmp10
-; CHECK: @test29
+; CHECK-LABEL: @test29(
; CHECK: %tmp916 = lshr i64 %d18, 63
; CHECK: %tmp10 = trunc i64 %tmp916 to i32
}
@@ -418,7 +417,7 @@ define i32 @test30(i32 %A, i32 %B, i32 %C) {
%Y = shl i32 %B, %C
%Z = and i32 %X, %Y
ret i32 %Z
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; CHECK: %X1 = and i32 %A, %B
; CHECK: %Z = shl i32 %X1, %C
}
@@ -428,7 +427,7 @@ define i32 @test31(i32 %A, i32 %B, i32 %C) {
%Y = lshr i32 %B, %C
%Z = or i32 %X, %Y
ret i32 %Z
-; CHECK: @test31
+; CHECK-LABEL: @test31(
; CHECK: %X1 = or i32 %A, %B
; CHECK: %Z = lshr i32 %X1, %C
}
@@ -438,7 +437,7 @@ define i32 @test32(i32 %A, i32 %B, i32 %C) {
%Y = ashr i32 %B, %C
%Z = xor i32 %X, %Y
ret i32 %Z
-; CHECK: @test32
+; CHECK-LABEL: @test32(
; CHECK: %X1 = xor i32 %A, %B
; CHECK: %Z = ashr i32 %X1, %C
; CHECK: ret i32 %Z
@@ -448,7 +447,7 @@ define i1 @test33(i32 %X) {
%tmp1 = shl i32 %X, 7
%tmp2 = icmp slt i32 %tmp1, 0
ret i1 %tmp2
-; CHECK: @test33
+; CHECK-LABEL: @test33(
; CHECK: %tmp1.mask = and i32 %X, 16777216
; CHECK: %tmp2 = icmp ne i32 %tmp1.mask, 0
}
@@ -457,7 +456,7 @@ define i1 @test34(i32 %X) {
%tmp1 = lshr i32 %X, 7
%tmp2 = icmp slt i32 %tmp1, 0
ret i1 %tmp2
-; CHECK: @test34
+; CHECK-LABEL: @test34(
; CHECK: ret i1 false
}
@@ -465,7 +464,7 @@ define i1 @test35(i32 %X) {
%tmp1 = ashr i32 %X, 7
%tmp2 = icmp slt i32 %tmp1, 0
ret i1 %tmp2
-; CHECK: @test35
+; CHECK-LABEL: @test35(
; CHECK: %tmp2 = icmp slt i32 %X, 0
; CHECK: ret i1 %tmp2
}
@@ -478,7 +477,7 @@ entry:
%tmp45 = lshr i128 %ins, 64
ret i128 %tmp45
-; CHECK: @test36
+; CHECK-LABEL: @test36(
; CHECK: %tmp231 = or i128 %B, %A
; CHECK: %ins = and i128 %tmp231, 18446744073709551615
; CHECK: ret i128 %ins
@@ -494,7 +493,7 @@ entry:
%tmp46 = trunc i128 %tmp45 to i64
ret i64 %tmp46
-; CHECK: @test37
+; CHECK-LABEL: @test37(
; CHECK: %tmp23 = shl nuw nsw i128 %tmp22, 32
; CHECK: %ins = or i128 %tmp23, %A
; CHECK: %tmp46 = trunc i128 %ins to i64
@@ -504,14 +503,14 @@ define i32 @test38(i32 %x) nounwind readnone {
%rem = srem i32 %x, 32
%shl = shl i32 1, %rem
ret i32 %shl
-; CHECK: @test38
+; CHECK-LABEL: @test38(
; CHECK-NEXT: and i32 %x, 31
; CHECK-NEXT: shl i32 1
; CHECK-NEXT: ret i32
}
; <rdar://problem/8756731>
-; CHECK: @test39
+; CHECK-LABEL: @test39(
define i8 @test39(i32 %a0) {
entry:
%tmp4 = trunc i32 %a0 to i8
@@ -537,7 +536,7 @@ define i32 @test40(i32 %a, i32 %b) nounwind {
%shl2 = shl i32 %shl1, 2
%div = udiv i32 %a, %shl2
ret i32 %div
-; CHECK: @test40
+; CHECK-LABEL: @test40(
; CHECK-NEXT: add i32 %b, 2
; CHECK-NEXT: lshr i32 %a
; CHECK-NEXT: ret i32
@@ -547,7 +546,7 @@ define i32 @test41(i32 %a, i32 %b) nounwind {
%1 = shl i32 1, %b
%2 = shl i32 %1, 3
ret i32 %2
-; CHECK: @test41
+; CHECK-LABEL: @test41(
; CHECK-NEXT: shl i32 8, %b
; CHECK-NEXT: ret i32
}
@@ -556,7 +555,7 @@ define i32 @test42(i32 %a, i32 %b) nounwind {
%div = lshr i32 4096, %b ; must be exact otherwise we'd divide by zero
%div2 = udiv i32 %a, %div
ret i32 %div2
-; CHECK: @test42
+; CHECK-LABEL: @test42(
; CHECK-NEXT: lshr exact i32 4096, %b
}
@@ -564,7 +563,7 @@ define i32 @test43(i32 %a, i32 %b) nounwind {
%div = shl i32 4096, %b ; must be exact otherwise we'd divide by zero
%div2 = udiv i32 %a, %div
ret i32 %div2
-; CHECK: @test43
+; CHECK-LABEL: @test43(
; CHECK-NEXT: add i32 %b, 12
; CHECK-NEXT: lshr
; CHECK-NEXT: ret
@@ -574,7 +573,7 @@ define i32 @test44(i32 %a) nounwind {
%y = shl nuw i32 %a, 1
%z = shl i32 %y, 4
ret i32 %z
-; CHECK: @test44
+; CHECK-LABEL: @test44(
; CHECK-NEXT: %y = shl i32 %a, 5
; CHECK-NEXT: ret i32 %y
}
@@ -583,7 +582,7 @@ define i32 @test45(i32 %a) nounwind {
%y = lshr exact i32 %a, 1
%z = lshr i32 %y, 4
ret i32 %z
-; CHECK: @test45
+; CHECK-LABEL: @test45(
; CHECK-NEXT: %y = lshr i32 %a, 5
; CHECK-NEXT: ret i32 %y
}
@@ -592,7 +591,7 @@ define i32 @test46(i32 %a) {
%y = ashr exact i32 %a, 3
%z = shl i32 %y, 1
ret i32 %z
-; CHECK: @test46
+; CHECK-LABEL: @test46(
; CHECK-NEXT: %z = ashr exact i32 %a, 2
; CHECK-NEXT: ret i32 %z
}
@@ -601,7 +600,7 @@ define i32 @test47(i32 %a) {
%y = lshr exact i32 %a, 3
%z = shl i32 %y, 1
ret i32 %z
-; CHECK: @test47
+; CHECK-LABEL: @test47(
; CHECK-NEXT: %z = lshr exact i32 %a, 2
; CHECK-NEXT: ret i32 %z
}
@@ -610,7 +609,7 @@ define i32 @test48(i32 %x) {
%A = lshr exact i32 %x, 1
%B = shl i32 %A, 3
ret i32 %B
-; CHECK: @test48
+; CHECK-LABEL: @test48(
; CHECK-NEXT: %B = shl i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -619,7 +618,7 @@ define i32 @test49(i32 %x) {
%A = ashr exact i32 %x, 1
%B = shl i32 %A, 3
ret i32 %B
-; CHECK: @test49
+; CHECK-LABEL: @test49(
; CHECK-NEXT: %B = shl i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -628,7 +627,7 @@ define i32 @test50(i32 %x) {
%A = shl nsw i32 %x, 1
%B = ashr i32 %A, 3
ret i32 %B
-; CHECK: @test50
+; CHECK-LABEL: @test50(
; CHECK-NEXT: %B = ashr i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -637,7 +636,7 @@ define i32 @test51(i32 %x) {
%A = shl nuw i32 %x, 1
%B = lshr i32 %A, 3
ret i32 %B
-; CHECK: @test51
+; CHECK-LABEL: @test51(
; CHECK-NEXT: %B = lshr i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -646,7 +645,7 @@ define i32 @test52(i32 %x) {
%A = shl nsw i32 %x, 3
%B = ashr i32 %A, 1
ret i32 %B
-; CHECK: @test52
+; CHECK-LABEL: @test52(
; CHECK-NEXT: %B = shl nsw i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -655,7 +654,7 @@ define i32 @test53(i32 %x) {
%A = shl nuw i32 %x, 3
%B = lshr i32 %A, 1
ret i32 %B
-; CHECK: @test53
+; CHECK-LABEL: @test53(
; CHECK-NEXT: %B = shl nuw i32 %x, 2
; CHECK-NEXT: ret i32 %B
}
@@ -665,7 +664,7 @@ define i32 @test54(i32 %x) {
%shl = shl i32 %shr2, 4
%and = and i32 %shl, 16
ret i32 %and
-; CHECK: @test54
+; CHECK-LABEL: @test54(
; CHECK: shl i32 %x, 3
}
@@ -675,7 +674,7 @@ define i32 @test55(i32 %x) {
%shl = shl i32 %shr2, 4
%or = or i32 %shl, 8
ret i32 %or
-; CHECK: @test55
+; CHECK-LABEL: @test55(
; CHECK: shl i32 %x, 3
}
@@ -684,7 +683,7 @@ define i32 @test56(i32 %x) {
%shl = shl i32 %shr2, 4
%or = or i32 %shl, 7
ret i32 %or
-; CHECK: @test56
+; CHECK-LABEL: @test56(
; CHECK: shl i32 %shr2, 4
}
@@ -694,7 +693,7 @@ define i32 @test57(i32 %x) {
%shl = shl i32 %shr, 4
%and = and i32 %shl, 16
ret i32 %and
-; CHECK: @test57
+; CHECK-LABEL: @test57(
; CHECK: shl i32 %x, 3
}
@@ -703,7 +702,7 @@ define i32 @test58(i32 %x) {
%shl = shl i32 %shr, 4
%or = or i32 %shl, 8
ret i32 %or
-; CHECK: @test58
+; CHECK-LABEL: @test58(
; CHECK: shl i32 %x, 3
}
@@ -712,7 +711,7 @@ define i32 @test59(i32 %x) {
%shl = shl i32 %shr, 4
%or = or i32 %shl, 7
ret i32 %or
-; CHECK: @test59
+; CHECK-LABEL: @test59(
; CHECK: %shl = shl i32 %shr1, 4
}
@@ -722,7 +721,7 @@ define i32 @test60(i32 %x) {
%shl = shl i32 %shr, 1
%or = or i32 %shl, 1
ret i32 %or
-; CHECK: @test60
+; CHECK-LABEL: @test60(
; CHECK: ashr i32 %x, 3
}
@@ -732,7 +731,7 @@ define i32 @test61(i32 %x) {
%shl = shl i32 %shr, 1
%or = or i32 %shl, 2
ret i32 %or
-; CHECK: @test61
+; CHECK-LABEL: @test61(
; CHECK: ashr i32 %x, 4
}
@@ -742,6 +741,42 @@ define i32 @test62(i32 %x) {
%shl = shl i32 %shr, 1
%or = or i32 %shl, 1
ret i32 %or
-; CHECK: @test62
+; CHECK-LABEL: @test62(
; CHECK: ashr exact i32 %x, 3
}
+
+; PR17026
+; CHECK-LABEL: @test63(
+; CHECK-NOT: sh
+; CHECK: ret
+define void @test63(i128 %arg) {
+bb:
+ br i1 undef, label %bb1, label %bb12
+
+bb1: ; preds = %bb11, %bb
+ br label %bb2
+
+bb2: ; preds = %bb7, %bb1
+ br i1 undef, label %bb3, label %bb7
+
+bb3: ; preds = %bb2
+ %tmp = lshr i128 %arg, 36893488147419103232
+ %tmp4 = shl i128 %tmp, 0
+ %tmp5 = or i128 %tmp4, undef
+ %tmp6 = trunc i128 %tmp5 to i16
+ br label %bb8
+
+bb7: ; preds = %bb2
+ br i1 undef, label %bb8, label %bb2
+
+bb8: ; preds = %bb7, %bb3
+ %tmp9 = phi i16 [ %tmp6, %bb3 ], [ undef, %bb7 ]
+ %tmp10 = icmp eq i16 %tmp9, 0
+ br i1 %tmp10, label %bb11, label %bb12
+
+bb11: ; preds = %bb8
+ br i1 undef, label %bb1, label %bb12
+
+bb12: ; preds = %bb11, %bb8, %bb
+ ret void
+}
diff --git a/test/Transforms/InstCombine/sign-test-and-or.ll b/test/Transforms/InstCombine/sign-test-and-or.ll
index a6066d80020d..95ed9b976ba3 100644
--- a/test/Transforms/InstCombine/sign-test-and-or.ll
+++ b/test/Transforms/InstCombine/sign-test-and-or.ll
@@ -8,7 +8,7 @@ define void @test1(i32 %a, i32 %b) nounwind {
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: %1 = or i32 %a, %b
; CHECK-NEXT: %2 = icmp slt i32 %1, 0
; CHECK-NEXT: br
@@ -27,7 +27,7 @@ define void @test2(i32 %a, i32 %b) nounwind {
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: %1 = and i32 %a, %b
; CHECK-NEXT: %2 = icmp sgt i32 %1, -1
; CHECK-NEXT: br
@@ -46,7 +46,7 @@ define void @test3(i32 %a, i32 %b) nounwind {
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: %1 = and i32 %a, %b
; CHECK-NEXT: %2 = icmp slt i32 %1, 0
; CHECK-NEXT: br
@@ -65,7 +65,7 @@ define void @test4(i32 %a, i32 %b) nounwind {
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: %1 = or i32 %a, %b
; CHECK-NEXT: %2 = icmp sgt i32 %1, -1
; CHECK-NEXT: br
@@ -85,7 +85,7 @@ define void @test5(i32 %a) nounwind {
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: %1 = and i32 %a, -2013265920
; CHECK-NEXT: %2 = icmp eq i32 %1, 0
; CHECK-NEXT: br i1 %2, label %if.then, label %if.end
@@ -105,7 +105,7 @@ define void @test6(i32 %a) nounwind {
%or.cond = and i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: %1 = and i32 %a, -2013265920
; CHECK-NEXT: %2 = icmp eq i32 %1, 0
; CHECK-NEXT: br i1 %2, label %if.then, label %if.end
@@ -125,7 +125,7 @@ define void @test7(i32 %a) nounwind {
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: %1 = and i32 %a, -2013265920
; CHECK-NEXT: %2 = icmp eq i32 %1, 0
; CHECK-NEXT: br i1 %2, label %if.end, label %if.the
@@ -145,7 +145,7 @@ define void @test8(i32 %a) nounwind {
%or.cond = or i1 %1, %2
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NEXT: %1 = and i32 %a, -2013265920
; CHECK-NEXT: %2 = icmp eq i32 %1, 0
; CHECK-NEXT: br i1 %2, label %if.end, label %if.the
@@ -165,7 +165,7 @@ define void @test9(i32 %a) nounwind {
%or.cond = and i1 %2, %3
br i1 %or.cond, label %if.then, label %if.end
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: %1 = and i32 %a, -1073741824
; CHECK-NEXT: %2 = icmp eq i32 %1, 1073741824
; CHECK-NEXT: br i1 %2, label %if.then, label %if.end
diff --git a/test/Transforms/InstCombine/signext.ll b/test/Transforms/InstCombine/signext.ll
index 5ed1cd5590ae..d7004977cd63 100644
--- a/test/Transforms/InstCombine/signext.ll
+++ b/test/Transforms/InstCombine/signext.ll
@@ -7,7 +7,7 @@ define i32 @test1(i32 %x) {
%tmp.2 = xor i32 %tmp.1, -32768 ; <i32> [#uses=1]
%tmp.3 = add i32 %tmp.2, 32768 ; <i32> [#uses=1]
ret i32 %tmp.3
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %sext = shl i32 %x, 16
; CHECK: %tmp.3 = ashr exact i32 %sext, 16
; CHECK: ret i32 %tmp.3
@@ -18,7 +18,7 @@ define i32 @test2(i32 %x) {
%tmp.2 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
%tmp.3 = add i32 %tmp.2, -32768 ; <i32> [#uses=1]
ret i32 %tmp.3
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: %sext = shl i32 %x, 16
; CHECK: %tmp.3 = ashr exact i32 %sext, 16
; CHECK: ret i32 %tmp.3
@@ -29,7 +29,7 @@ define i32 @test3(i16 %P) {
%tmp.4 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
%tmp.5 = add i32 %tmp.4, -32768 ; <i32> [#uses=1]
ret i32 %tmp.5
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: %tmp.5 = sext i16 %P to i32
; CHECK: ret i32 %tmp.5
}
@@ -39,7 +39,7 @@ define i32 @test4(i16 %P) {
%tmp.4 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
%tmp.5 = add i32 %tmp.4, -32768 ; <i32> [#uses=1]
ret i32 %tmp.5
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: %tmp.5 = sext i16 %P to i32
; CHECK: ret i32 %tmp.5
}
@@ -49,7 +49,7 @@ define i32 @test5(i32 %x) {
%tmp.2 = xor i32 %tmp.1, 128 ; <i32> [#uses=1]
%tmp.3 = add i32 %tmp.2, -128 ; <i32> [#uses=1]
ret i32 %tmp.3
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %sext = shl i32 %x, 24
; CHECK: %tmp.3 = ashr exact i32 %sext, 24
; CHECK: ret i32 %tmp.3
@@ -59,7 +59,7 @@ define i32 @test6(i32 %x) {
%tmp.2 = shl i32 %x, 16 ; <i32> [#uses=1]
%tmp.4 = ashr i32 %tmp.2, 16 ; <i32> [#uses=1]
ret i32 %tmp.4
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: %tmp.2 = shl i32 %x, 16
; CHECK: %tmp.4 = ashr exact i32 %tmp.2, 16
; CHECK: ret i32 %tmp.4
@@ -70,7 +70,7 @@ define i32 @test7(i16 %P) {
%sext1 = shl i32 %tmp.1, 16 ; <i32> [#uses=1]
%tmp.5 = ashr i32 %sext1, 16 ; <i32> [#uses=1]
ret i32 %tmp.5
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %tmp.5 = sext i16 %P to i32
; CHECK: ret i32 %tmp.5
}
@@ -81,7 +81,7 @@ entry:
%xor = xor i32 %shr, 67108864 ; <i32> [#uses=1]
%sub = add i32 %xor, -67108864 ; <i32> [#uses=1]
ret i32 %sub
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: %sub = ashr i32 %x, 5
; CHECK: ret i32 %sub
}
diff --git a/test/Transforms/InstCombine/simplify-libcalls.ll b/test/Transforms/InstCombine/simplify-libcalls.ll
new file mode 100644
index 000000000000..fae3e6e3d9be
--- /dev/null
+++ b/test/Transforms/InstCombine/simplify-libcalls.ll
@@ -0,0 +1,144 @@
+; RUN: opt -S < %s -instcombine | FileCheck %s
+
+@G = constant [3 x i8] c"%s\00" ; <[3 x i8]*> [#uses=1]
+
+declare i32 @sprintf(i8*, i8*, ...)
+
+define void @foo(i8* %P, i32* %X) {
+ call i32 (i8*, i8*, ...)* @sprintf( i8* %P, i8* getelementptr ([3 x i8]* @G, i32 0, i32 0), i32* %X ) ; <i32>:1 [#uses=0]
+ ret void
+}
+
+; PR1307
+@str = internal constant [5 x i8] c"foog\00"
+@str1 = internal constant [8 x i8] c"blahhh!\00"
+@str2 = internal constant [5 x i8] c"Ponk\00"
+
+define i8* @test1() {
+ %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str, i32 0, i32 2), i32 103 ) ; <i8*> [#uses=1]
+ ret i8* %tmp3
+
+; CHECK-LABEL: @test1(
+; CHECK: ret i8* getelementptr inbounds ([5 x i8]* @str, i32 0, i64 3)
+}
+
+declare i8* @strchr(i8*, i32)
+
+define i8* @test2() {
+ %tmp3 = tail call i8* @strchr( i8* getelementptr ([8 x i8]* @str1, i32 0, i32 2), i32 0 ) ; <i8*> [#uses=1]
+ ret i8* %tmp3
+
+; CHECK-LABEL: @test2(
+; CHECK: ret i8* getelementptr inbounds ([8 x i8]* @str1, i32 0, i64 7)
+}
+
+define i8* @test3() {
+entry:
+ %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str2, i32 0, i32 1), i32 80 ) ; <i8*> [#uses=1]
+ ret i8* %tmp3
+
+; CHECK-LABEL: @test3(
+; CHECK: ret i8* null
+}
+
+@_2E_str = external constant [5 x i8] ; <[5 x i8]*> [#uses=1]
+
+declare i32 @memcmp(i8*, i8*, i32) nounwind readonly
+
+define i1 @PR2341(i8** %start_addr) {
+entry:
+ %tmp4 = load i8** %start_addr, align 4 ; <i8*> [#uses=1]
+ %tmp5 = call i32 @memcmp( i8* %tmp4, i8* getelementptr ([5 x i8]* @_2E_str, i32 0, i32 0), i32 4 ) nounwind readonly ; <i32> [#uses=1]
+ %tmp6 = icmp eq i32 %tmp5, 0 ; <i1> [#uses=1]
+ ret i1 %tmp6
+
+; CHECK-LABEL: @PR2341(
+; CHECK: i32
+}
+
+define i32 @PR4284() nounwind {
+entry:
+ %c0 = alloca i8, align 1 ; <i8*> [#uses=2]
+ %c2 = alloca i8, align 1 ; <i8*> [#uses=2]
+ store i8 64, i8* %c0
+ store i8 -127, i8* %c2
+ %call = call i32 @memcmp(i8* %c0, i8* %c2, i32 1) ; <i32> [#uses=1]
+ ret i32 %call
+
+; CHECK-LABEL: @PR4284(
+; CHECK: ret i32 -65
+}
+
+%struct.__sFILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, i8*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64, %struct.pthread_mutex*, %struct.pthread*, i32, i32, %union.anon }
+%struct.__sbuf = type { i8*, i32, [4 x i8] }
+%struct.pthread = type opaque
+%struct.pthread_mutex = type opaque
+%union.anon = type { i64, [120 x i8] }
+@.str13 = external constant [2 x i8] ; <[2 x i8]*> [#uses=1]
+@.str14 = external constant [2 x i8] ; <[2 x i8]*> [#uses=1]
+
+define i32 @PR4641(i32 %argc, i8** %argv) nounwind {
+entry:
+ call void @exit(i32 0) nounwind
+ %cond392 = select i1 undef, i8* getelementptr ([2 x i8]* @.str13, i32 0, i32 0), i8* getelementptr ([2 x i8]* @.str14, i32 0, i32 0) ; <i8*> [#uses=1]
+ %call393 = call %struct.__sFILE* @fopen(i8* undef, i8* %cond392) nounwind ; <%struct.__sFILE*> [#uses=0]
+ unreachable
+}
+
+declare %struct.__sFILE* @fopen(i8*, i8*)
+
+declare void @exit(i32)
+
+define i32 @PR4645() {
+entry:
+ br label %if.then
+
+lor.lhs.false: ; preds = %while.body
+ br i1 undef, label %if.then, label %for.cond
+
+if.then: ; preds = %lor.lhs.false, %while.body
+ call void @exit(i32 1)
+ br label %for.cond
+
+for.cond: ; preds = %for.end, %if.then, %lor.lhs.false
+ %j.0 = phi i32 [ %inc47, %for.end ], [ 0, %if.then ], [ 0, %lor.lhs.false ] ; <i32> [#uses=1]
+ unreachable
+
+for.end: ; preds = %for.cond20
+ %inc47 = add i32 %j.0, 1 ; <i32> [#uses=1]
+ br label %for.cond
+}
+
+@h = constant [2 x i8] c"h\00" ; <[2 x i8]*> [#uses=1]
+@hel = constant [4 x i8] c"hel\00" ; <[4 x i8]*> [#uses=1]
+@hello_u = constant [8 x i8] c"hello_u\00" ; <[8 x i8]*> [#uses=1]
+
+define i32 @MemCpy() {
+ %h_p = getelementptr [2 x i8]* @h, i32 0, i32 0
+ %hel_p = getelementptr [4 x i8]* @hel, i32 0, i32 0
+ %hello_u_p = getelementptr [8 x i8]* @hello_u, i32 0, i32 0
+ %target = alloca [1024 x i8]
+ %target_p = getelementptr [1024 x i8]* %target, i32 0, i32 0
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %h_p, i32 2, i32 2, i1 false)
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hel_p, i32 4, i32 4, i1 false)
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %target_p, i8* %hello_u_p, i32 8, i32 8, i1 false)
+ ret i32 0
+
+; CHECK-LABEL: @MemCpy(
+; CHECK-NOT: llvm.memcpy
+; CHECK: ret i32 0
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
+
+declare i32 @strcmp(i8*, i8*) #0
+
+define void @test9(i8* %x) {
+; CHECK-LABEL: @test9(
+; CHECK-NOT: strcmp
+ %y = call i32 @strcmp(i8* %x, i8* %x) #1
+ ret void
+}
+
+attributes #0 = { nobuiltin }
+attributes #1 = { builtin }
diff --git a/test/Transforms/InstCombine/sincospi.ll b/test/Transforms/InstCombine/sincospi.ll
new file mode 100644
index 000000000000..0d1a6027a00a
--- /dev/null
+++ b/test/Transforms/InstCombine/sincospi.ll
@@ -0,0 +1,91 @@
+; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.9 | FileCheck %s --check-prefix=CHECK-FLOAT-IN-VEC
+; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios7.0 | FileCheck %s
+; RUN: opt -instcombine -S < %s -mtriple=x86_64-apple-macosx10.8 | FileCheck %s --check-prefix=CHECK-NO-SINCOS
+; RUN: opt -instcombine -S < %s -mtriple=arm-apple-ios6.0 | FileCheck %s --check-prefix=CHECK-NO-SINCOS
+; RUN: opt -instcombine -S < %s -mtriple=x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-NO-SINCOS
+
+
+attributes #0 = { readnone nounwind }
+
+declare float @__sinpif(float %x) #0
+declare float @__cospif(float %x) #0
+
+declare double @__sinpi(double %x) #0
+declare double @__cospi(double %x) #0
+
+@var32 = global float 0.0
+@var64 = global double 0.0
+
+define float @test_instbased_f32() {
+ %val = load float* @var32
+ %sin = call float @__sinpif(float %val) #0
+ %cos = call float @__cospif(float %val) #0
+ %res = fadd float %sin, %cos
+ ret float %res
+; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load float* @var32
+; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float [[VAL]])
+; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0
+; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1
+
+; CHECK: [[VAL:%[a-z0-9]+]] = load float* @var32
+; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float [[VAL]])
+; CHECK: extractvalue { float, float } [[SINCOS]], 0
+; CHECK: extractvalue { float, float } [[SINCOS]], 1
+
+; CHECK-NO-SINCOS: call float @__sinpif
+; CHECK-NO-SINCOS: call float @__cospif
+}
+
+define float @test_constant_f32() {
+ %sin = call float @__sinpif(float 1.0) #0
+ %cos = call float @__cospif(float 1.0) #0
+ %res = fadd float %sin, %cos
+ ret float %res
+; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call <2 x float> @__sincospi_stretf(float 1.000000e+00)
+; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 0
+; CHECK-FLOAT-IN-VEC: extractelement <2 x float> [[SINCOS]], i32 1
+
+; CHECK: [[SINCOS:%[a-z0-9]+]] = call { float, float } @__sincospi_stretf(float 1.000000e+00)
+; CHECK: extractvalue { float, float } [[SINCOS]], 0
+; CHECK: extractvalue { float, float } [[SINCOS]], 1
+
+; CHECK-NO-SINCOS: call float @__sinpif
+; CHECK-NO-SINCOS: call float @__cospif
+}
+
+define double @test_instbased_f64() {
+ %val = load double* @var64
+ %sin = call double @__sinpi(double %val) #0
+ %cos = call double @__cospi(double %val) #0
+ %res = fadd double %sin, %cos
+ ret double %res
+; CHECK-FLOAT-IN-VEC: [[VAL:%[a-z0-9]+]] = load double* @var64
+; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]])
+; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0
+; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1
+
+; CHECK: [[VAL:%[a-z0-9]+]] = load double* @var64
+; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double [[VAL]])
+; CHECK: extractvalue { double, double } [[SINCOS]], 0
+; CHECK: extractvalue { double, double } [[SINCOS]], 1
+
+; CHECK-NO-SINCOS: call double @__sinpi
+; CHECK-NO-SINCOS: call double @__cospi
+}
+
+define double @test_constant_f64() {
+ %sin = call double @__sinpi(double 1.0) #0
+ %cos = call double @__cospi(double 1.0) #0
+ %res = fadd double %sin, %cos
+ ret double %res
+; CHECK-FLOAT-IN-VEC: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
+; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 0
+; CHECK-FLOAT-IN-VEC: extractvalue { double, double } [[SINCOS]], 1
+
+; CHECK: [[SINCOS:%[a-z0-9]+]] = call { double, double } @__sincospi_stret(double 1.000000e+00)
+; CHECK: extractvalue { double, double } [[SINCOS]], 0
+; CHECK: extractvalue { double, double } [[SINCOS]], 1
+
+; CHECK-NO-SINCOS: call double @__sinpi
+; CHECK-NO-SINCOS: call double @__cospi
+}
diff --git a/test/Transforms/InstCombine/sink_instruction.ll b/test/Transforms/InstCombine/sink_instruction.ll
index 5c4019a98df5..1bbd6b763841 100644
--- a/test/Transforms/InstCombine/sink_instruction.ll
+++ b/test/Transforms/InstCombine/sink_instruction.ll
@@ -4,7 +4,7 @@
;; arm of the 'if'.
define i32 @test1(i1 %C, i32 %A, i32 %B) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
entry:
%tmp.2 = sdiv i32 %A, %B ; <i32> [#uses=1]
%tmp.9 = add i32 %B, %A ; <i32> [#uses=1]
@@ -22,7 +22,7 @@ endif: ; preds = %entry
;; PHI use, sink divide before call.
define i32 @test2(i32 %x) nounwind ssp {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: sdiv i32
entry:
br label %bb
diff --git a/test/Transforms/InstCombine/sprintf-1.ll b/test/Transforms/InstCombine/sprintf-1.ll
index 9b8c8b1b12c7..78dd7aa7df47 100644
--- a/test/Transforms/InstCombine/sprintf-1.ll
+++ b/test/Transforms/InstCombine/sprintf-1.ll
@@ -1,7 +1,7 @@
; Test that the sprintf library call simplifier works correctly.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
-; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=IPRINTF
+; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefix=CHECK-IPRINTF
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
@@ -19,7 +19,7 @@ declare i32 @sprintf(i8*, i8*, ...)
; Check sprintf(dst, fmt) -> llvm.memcpy(str, fmt, strlen(fmt) + 1, 1).
define void @test_simplify1(i8* %dst) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%fmt = getelementptr [13 x i8]* @hello_world, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt)
; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dst, i8* getelementptr inbounds ([13 x i8]* @hello_world, i32 0, i32 0), i32 13, i32 1, i1 false)
@@ -28,7 +28,7 @@ define void @test_simplify1(i8* %dst) {
}
define void @test_simplify2(i8* %dst) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%fmt = getelementptr [1 x i8]* @null, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt)
; CHECK-NEXT: store i8 0, i8* %dst, align 1
@@ -37,7 +37,7 @@ define void @test_simplify2(i8* %dst) {
}
define void @test_simplify3(i8* %dst) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%fmt = getelementptr [7 x i8]* @null_hello, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt)
; CHECK-NEXT: store i8 0, i8* %dst, align 1
@@ -48,7 +48,7 @@ define void @test_simplify3(i8* %dst) {
; Check sprintf(dst, "%c", chr) -> *(i8*)dst = chr; *((i8*)dst + 1) = 0.
define void @test_simplify4(i8* %dst) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%fmt = getelementptr [3 x i8]* @percent_c, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, i8 104)
; CHECK-NEXT: store i8 104, i8* %dst, align 1
@@ -61,7 +61,7 @@ define void @test_simplify4(i8* %dst) {
; Check sprintf(dst, "%s", str) -> llvm.memcpy(dest, str, strlen(str) + 1, 1).
define void @test_simplify5(i8* %dst, i8* %str) {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%fmt = getelementptr [3 x i8]* @percent_s, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, i8* %str)
; CHECK-NEXT: [[STRLEN:%[a-z0-9]+]] = call i32 @strlen(i8* %str)
@@ -74,7 +74,7 @@ define void @test_simplify5(i8* %dst, i8* %str) {
; Check sprintf(dst, format, ...) -> siprintf(str, format, ...) if no floating.
define void @test_simplify6(i8* %dst) {
-; CHECK-IPRINTF: @test_simplify6
+; CHECK-IPRINTF-LABEL: @test_simplify6(
%fmt = getelementptr [3 x i8]* @percent_d, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, i32 187)
; CHECK-NEXT-IPRINTF: call i32 (i8*, i8*, ...)* @siprintf(i8* %dst, i8* getelementptr inbounds ([3 x i8]* @percent_d, i32 0, i32 0), i32 187)
@@ -83,7 +83,7 @@ define void @test_simplify6(i8* %dst) {
}
define void @test_no_simplify1(i8* %dst) {
-; CHECK-IPRINTF: @test_no_simplify1
+; CHECK-IPRINTF-LABEL: @test_no_simplify1(
%fmt = getelementptr [3 x i8]* @percent_f, i32 0, i32 0
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, double 1.87)
; CHECK-NEXT-IPRINTF: call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* getelementptr inbounds ([3 x i8]* @percent_f, i32 0, i32 0), double 1.870000e+00)
@@ -92,7 +92,7 @@ define void @test_no_simplify1(i8* %dst) {
}
define void @test_no_simplify2(i8* %dst, i8* %fmt, double %d) {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, double %d)
; CHECK-NEXT: call i32 (i8*, i8*, ...)* @sprintf(i8* %dst, i8* %fmt, double %d)
ret void
diff --git a/test/Transforms/InstCombine/sqrt.ll b/test/Transforms/InstCombine/sqrt.ll
index 440b9748518d..650b10c6e966 100644
--- a/test/Transforms/InstCombine/sqrt.ll
+++ b/test/Transforms/InstCombine/sqrt.ll
@@ -2,7 +2,7 @@
define float @test1(float %x) nounwind readnone ssp {
entry:
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NOT: fpext
; CHECK-NOT: sqrt(
; CHECK: sqrtf(
@@ -17,7 +17,7 @@ entry:
; PR8096
define float @test2(float %x) nounwind readnone ssp {
entry:
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: fpext
; CHECK-NOT: sqrt(
; CHECK: sqrtf(
@@ -34,7 +34,7 @@ entry:
; use of sqrt result.
define float @test3(float* %v) nounwind uwtable ssp {
entry:
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: sqrt(
; CHECK-NOT: sqrtf(
; CHECK: fptrunc
diff --git a/test/Transforms/InstCombine/store.ll b/test/Transforms/InstCombine/store.ll
index 164ba7632684..b64c800e546c 100644
--- a/test/Transforms/InstCombine/store.ll
+++ b/test/Transforms/InstCombine/store.ll
@@ -5,7 +5,7 @@ define void @test1(i32* %P) {
store i32 123, i32* undef
store i32 124, i32* null
ret void
-; CHECK: @test1(
+; CHECK-LABEL: @test1(
; CHECK-NEXT: store i32 123, i32* undef
; CHECK-NEXT: store i32 undef, i32* null
; CHECK-NEXT: ret void
@@ -16,7 +16,7 @@ define void @test2(i32* %P) {
%Y = add i32 %X, 0 ; <i32> [#uses=1]
store i32 %Y, i32* %P
ret void
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: ret void
}
@@ -38,7 +38,7 @@ Cond2:
Cont:
%V = load i32* %A
ret i32 %V
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NOT: alloca
; CHECK: Cont:
; CHECK-NEXT: %storemerge = phi i32 [ 47, %Cond2 ], [ -987654321, %Cond ]
@@ -58,7 +58,7 @@ Cond:
Cont:
%V = load i32* %A
ret i32 %V
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NOT: alloca
; CHECK: Cont:
; CHECK-NEXT: %storemerge = phi i32 [ -987654321, %Cond ], [ 47, %0 ]
@@ -76,7 +76,7 @@ Cond:
Cont:
ret void
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: Cont:
; CHECK-NEXT: %storemerge = phi i32
; CHECK-NEXT: store i32 %storemerge, i32* %P, align 1
@@ -107,13 +107,14 @@ for.body: ; preds = %for.cond
for.end: ; preds = %for.cond
ret void
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: for.cond:
; CHECK-NEXT: phi i32 [ 42
; CHECK-NEXT: store i32 %storemerge, i32* %gi, align 4, !tbaa !0
}
-!0 = metadata !{metadata !"int", metadata !1}
+!0 = metadata !{metadata !4, metadata !4, i64 0}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA"}
!3 = metadata !{metadata !"float", metadata !1}
+!4 = metadata !{metadata !"int", metadata !1}
diff --git a/test/Transforms/InstCombine/stpcpy-1.ll b/test/Transforms/InstCombine/stpcpy-1.ll
index 8b6bb0e0d509..b918c9e9e890 100644
--- a/test/Transforms/InstCombine/stpcpy-1.ll
+++ b/test/Transforms/InstCombine/stpcpy-1.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i8* @stpcpy(i8*, i8*)
define i8* @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
@@ -24,7 +24,7 @@ define i8* @test_simplify1() {
}
define i8* @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
@@ -35,7 +35,7 @@ define i8* @test_simplify2() {
}
define i8* @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [32 x i8]* @b, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/stpcpy-2.ll b/test/Transforms/InstCombine/stpcpy-2.ll
index 2e92c0895ed4..6a0f7530d5a8 100644
--- a/test/Transforms/InstCombine/stpcpy-2.ll
+++ b/test/Transforms/InstCombine/stpcpy-2.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16* @stpcpy(i8*, i8*)
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/stpcpy_chk-1.ll b/test/Transforms/InstCombine/stpcpy_chk-1.ll
index 05603918c642..8a02529c61ca 100644
--- a/test/Transforms/InstCombine/stpcpy_chk-1.ll
+++ b/test/Transforms/InstCombine/stpcpy_chk-1.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
; Check cases where slen >= strlen (src).
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -32,7 +32,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -44,7 +44,7 @@ define void @test_simplify3() {
; Check cases where there are no string constants.
define void @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
@@ -56,12 +56,12 @@ define void @test_simplify4() {
; Check case where the string length is not constant.
define i8* @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
; CHECK: @__memcpy_chk
- %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
+ %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
%ret = call i8* @__stpcpy_chk(i8* %dst, i8* %src, i32 %len)
; CHECK: ret i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 11)
ret i8* %ret
@@ -70,12 +70,12 @@ define i8* @test_simplify5() {
; Check case where the source and destination are the same.
define i8* @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
; CHECK: [[LEN:%[a-z]+]] = call i32 @strlen
; CHECK-NEXT: getelementptr inbounds [60 x i8]* @a, i32 0, i32 [[LEN]]
- %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
+ %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
%ret = call i8* @__stpcpy_chk(i8* %dst, i8* %dst, i32 %len)
ret i8* %ret
}
@@ -83,7 +83,7 @@ define i8* @test_simplify6() {
; Check case where slen < strlen (src).
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
@@ -93,4 +93,4 @@ define void @test_no_simplify1() {
}
declare i8* @__stpcpy_chk(i8*, i8*, i32) nounwind
-declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
diff --git a/test/Transforms/InstCombine/stpcpy_chk-2.ll b/test/Transforms/InstCombine/stpcpy_chk-2.ll
index 46c2139276e2..b503da9c191c 100644
--- a/test/Transforms/InstCombine/stpcpy_chk-2.ll
+++ b/test/Transforms/InstCombine/stpcpy_chk-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@.str = private constant [8 x i8] c"abcdefg\00"
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = getelementptr inbounds [60 x i16]* @a, i32 0, i32 0
%src = getelementptr inbounds [8 x i8]* @.str, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strcat-1.ll b/test/Transforms/InstCombine/strcat-1.ll
index 3c05d6b06fa0..131ad4834837 100644
--- a/test/Transforms/InstCombine/strcat-1.ll
+++ b/test/Transforms/InstCombine/strcat-1.ll
@@ -13,7 +13,7 @@ declare i8* @strcat(i8*, i8*)
declare i32 @puts(i8*)
define i32 @main() {
-; CHECK: @main
+; CHECK-LABEL: @main(
; CHECK-NOT: call i8* @strcat
; CHECK: call i32 @puts
diff --git a/test/Transforms/InstCombine/strcat-2.ll b/test/Transforms/InstCombine/strcat-2.ll
index 379ee7495317..48f82670c325 100644
--- a/test/Transforms/InstCombine/strcat-2.ll
+++ b/test/Transforms/InstCombine/strcat-2.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i8* @strcat(i8*, i8*)
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
; CHECK-NOT: call i8* @strcat
; CHECK: ret void
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
; CHECK-NEXT: ret void
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strcat-3.ll b/test/Transforms/InstCombine/strcat-3.ll
index 15aff2f1aa28..e3396df73d37 100644
--- a/test/Transforms/InstCombine/strcat-3.ll
+++ b/test/Transforms/InstCombine/strcat-3.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16* @strcat(i8*, i8*)
define void @test_nosimplify1() {
-; CHECK: @test_nosimplify1
+; CHECK-LABEL: @test_nosimplify1(
; CHECK: call i16* @strcat
; CHECK: ret void
diff --git a/test/Transforms/InstCombine/strchr-1.ll b/test/Transforms/InstCombine/strchr-1.ll
index 5efab9ec4bee..d2c989462156 100644
--- a/test/Transforms/InstCombine/strchr-1.ll
+++ b/test/Transforms/InstCombine/strchr-1.ll
@@ -52,3 +52,14 @@ define void @test_simplify4(i32 %chr) {
store i8* %dst, i8** @chp
ret void
}
+
+define void @test_simplify5() {
+; CHECK: store i8* getelementptr inbounds ([14 x i8]* @hello, i32 0, i32 13)
+; CHECK-NOT: call i8* @strchr
+; CHECK: ret void
+
+ %src = getelementptr [14 x i8]* @hello, i32 0, i32 0
+ %dst = call i8* @strchr(i8* %src, i32 65280)
+ store i8* %dst, i8** @chp
+ ret void
+}
diff --git a/test/Transforms/InstCombine/strcmp-1.ll b/test/Transforms/InstCombine/strcmp-1.ll
index 0679246e0915..fc58ffcb8cb0 100644
--- a/test/Transforms/InstCombine/strcmp-1.ll
+++ b/test/Transforms/InstCombine/strcmp-1.ll
@@ -12,7 +12,7 @@ declare i32 @strcmp(i8*, i8*)
; strcmp("", x) -> -*x
define i32 @test1(i8* %str2) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %strcmpload = load i8* %str
; CHECK: %1 = zext i8 %strcmpload to i32
; CHECK: %2 = sub i32 0, %1
@@ -26,7 +26,7 @@ define i32 @test1(i8* %str2) {
; strcmp(x, "") -> *x
define i32 @test2(i8* %str1) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: %strcmpload = load i8* %str
; CHECK: %1 = zext i8 %strcmpload to i32
; CHECK: ret i32 %1
@@ -38,7 +38,7 @@ define i32 @test2(i8* %str1) {
; strcmp(x, y) -> cnst
define i32 @test3() {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i32 -1
%str1 = getelementptr inbounds [5 x i8]* @hell, i32 0, i32 0
@@ -48,7 +48,7 @@ define i32 @test3() {
}
define i32 @test4() {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ret i32 1
%str1 = getelementptr inbounds [5 x i8]* @hell, i32 0, i32 0
@@ -60,7 +60,7 @@ define i32 @test4() {
; strcmp(x, y) -> memcmp(x, y, <known length>)
; (This transform is rather difficult to trigger in a useful manner)
define i32 @test5(i1 %b) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %memcmp = call i32 @memcmp(i8* getelementptr inbounds ([6 x i8]* @hello, i32 0, i32 0), i8* %str2, i32 5)
; CHECK: ret i32 %memcmp
@@ -74,7 +74,7 @@ define i32 @test5(i1 %b) {
; strcmp(x,x) -> 0
define i32 @test6(i8* %str) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: ret i32 0
%temp1 = call i32 @strcmp(i8* %str, i8* %str)
diff --git a/test/Transforms/InstCombine/strcmp-2.ll b/test/Transforms/InstCombine/strcmp-2.ll
index 20518960f302..f0ef51652270 100644
--- a/test/Transforms/InstCombine/strcmp-2.ll
+++ b/test/Transforms/InstCombine/strcmp-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16 @strcmp(i8*, i8*)
define i16 @test_nosimplify() {
-; CHECK: @test_nosimplify
+; CHECK-LABEL: @test_nosimplify(
; CHECK: call i16 @strcmp
; CHECK: ret i16 %temp1
diff --git a/test/Transforms/InstCombine/strcpy-1.ll b/test/Transforms/InstCombine/strcpy-1.ll
index b6cf048b2a81..7c253f6f9fca 100644
--- a/test/Transforms/InstCombine/strcpy-1.ll
+++ b/test/Transforms/InstCombine/strcpy-1.ll
@@ -13,7 +13,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i8* @strcpy(i8*, i8*)
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
@@ -24,7 +24,7 @@ define void @test_simplify1() {
}
define i8* @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
@@ -34,7 +34,7 @@ define i8* @test_simplify2() {
}
define i8* @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [32 x i8]* @b, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strcpy-2.ll b/test/Transforms/InstCombine/strcpy-2.ll
index 779e9fdd9598..bad392d7c648 100644
--- a/test/Transforms/InstCombine/strcpy-2.ll
+++ b/test/Transforms/InstCombine/strcpy-2.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16* @strcpy(i8*, i8*)
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strcpy_chk-1.ll b/test/Transforms/InstCombine/strcpy_chk-1.ll
index 3e48f4fd3057..8e7fec76ef5c 100644
--- a/test/Transforms/InstCombine/strcpy_chk-1.ll
+++ b/test/Transforms/InstCombine/strcpy_chk-1.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
; Check cases where slen >= strlen (src).
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -32,7 +32,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -44,7 +44,7 @@ define void @test_simplify3() {
; Check cases where there are no string constants.
define void @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
@@ -56,12 +56,12 @@ define void @test_simplify4() {
; Check case where the string length is not constant.
define void @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
; CHECK: @__memcpy_chk
- %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
+ %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
call i8* @__strcpy_chk(i8* %dst, i8* %src, i32 %len)
ret void
}
@@ -69,11 +69,11 @@ define void @test_simplify5() {
; Check case where the source and destination are the same.
define i8* @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
; CHECK: getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0)
- %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
+ %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
%ret = call i8* @__strcpy_chk(i8* %dst, i8* %dst, i32 %len)
ret i8* %ret
}
@@ -81,7 +81,7 @@ define i8* @test_simplify6() {
; Check case where slen < strlen (src).
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
@@ -91,4 +91,4 @@ define void @test_no_simplify1() {
}
declare i8* @__strcpy_chk(i8*, i8*, i32) nounwind
-declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
+declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
diff --git a/test/Transforms/InstCombine/strcpy_chk-2.ll b/test/Transforms/InstCombine/strcpy_chk-2.ll
index d76ea5d068bc..1eff5a822e78 100644
--- a/test/Transforms/InstCombine/strcpy_chk-2.ll
+++ b/test/Transforms/InstCombine/strcpy_chk-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@.str = private constant [8 x i8] c"abcdefg\00"
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = getelementptr inbounds [60 x i16]* @a, i32 0, i32 0
%src = getelementptr inbounds [8 x i8]* @.str, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strcpy_chk-64.ll b/test/Transforms/InstCombine/strcpy_chk-64.ll
index 036fcbe6de1d..31447d9569e1 100644
--- a/test/Transforms/InstCombine/strcpy_chk-64.ll
+++ b/test/Transforms/InstCombine/strcpy_chk-64.ll
@@ -3,7 +3,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
target triple = "x86_64-apple-darwin10.0.0"
define void @func(i8* %i) nounwind ssp {
-; CHECK: @func
+; CHECK-LABEL: @func(
; CHECK: @__strcpy_chk(i8* %arraydecay, i8* %i, i64 32)
entry:
%s = alloca [32 x i8], align 16
diff --git a/test/Transforms/InstCombine/strcspn-1.ll b/test/Transforms/InstCombine/strcspn-1.ll
index 60fad897b2c8..b3b52b5025a5 100644
--- a/test/Transforms/InstCombine/strcspn-1.ll
+++ b/test/Transforms/InstCombine/strcspn-1.ll
@@ -13,7 +13,7 @@ declare i64 @strcspn(i8*, i8*)
; Check strcspn(s, "") -> strlen(s).
define i64 @test_simplify1(i8* %str) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%pat = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i64 @strcspn(i8* %str, i8* %pat)
@@ -25,7 +25,7 @@ define i64 @test_simplify1(i8* %str) {
; Check strcspn("", s) -> 0.
define i64 @test_simplify2(i8* %pat) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%str = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i64 @strcspn(i8* %str, i8* %pat)
@@ -36,7 +36,7 @@ define i64 @test_simplify2(i8* %pat) {
; Check strcspn(s1, s2), where s1 and s2 are constants.
define i64 @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr [6 x i8]* @abcba, i32 0, i32 0
%pat = getelementptr [4 x i8]* @abc, i32 0, i32 0
@@ -48,7 +48,7 @@ define i64 @test_simplify3() {
; Check cases that shouldn't be simplified.
define i64 @test_no_simplify1(i8* %str, i8* %pat) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i64 @strcspn(i8* %str, i8* %pat)
; CHECK-NEXT: %ret = call i64 @strcspn(i8* %str, i8* %pat)
diff --git a/test/Transforms/InstCombine/strcspn-2.ll b/test/Transforms/InstCombine/strcspn-2.ll
index 4e2393686c7d..ecfa27d3b6ba 100644
--- a/test/Transforms/InstCombine/strcspn-2.ll
+++ b/test/Transforms/InstCombine/strcspn-2.ll
@@ -11,7 +11,7 @@ declare double @strcspn(i8*, i8*)
; Check that strcspn functions with the wrong prototype aren't simplified.
define double @test_no_simplify1(i8* %pat) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%str = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call double @strcspn(i8* %str, i8* %pat)
diff --git a/test/Transforms/InstCombine/strlen-1.ll b/test/Transforms/InstCombine/strlen-1.ll
index 6d7464a4cc80..4fa5b4fdb62f 100644
--- a/test/Transforms/InstCombine/strlen-1.ll
+++ b/test/Transforms/InstCombine/strlen-1.ll
@@ -15,7 +15,7 @@ declare i32 @strlen(i8*)
; Check strlen(string constant) -> integer constant.
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0
%hello_l = call i32 @strlen(i8* %hello_p)
ret i32 %hello_l
@@ -23,7 +23,7 @@ define i32 @test_simplify1() {
}
define i32 @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
%null_l = call i32 @strlen(i8* %null_p)
ret i32 %null_l
@@ -31,7 +31,7 @@ define i32 @test_simplify2() {
}
define i32 @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%null_hello_p = getelementptr [7 x i8]* @null_hello, i32 0, i32 0
%null_hello_l = call i32 @strlen(i8* %null_hello_p)
ret i32 %null_hello_l
@@ -39,7 +39,7 @@ define i32 @test_simplify3() {
}
define i32 @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%len = tail call i32 @strlen(i8* @nullstring) nounwind
ret i32 %len
; CHECK-NEXT: ret i32 0
@@ -48,7 +48,7 @@ define i32 @test_simplify4() {
; Check strlen(x) == 0 --> *x == 0.
define i1 @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0
%hello_l = call i32 @strlen(i8* %hello_p)
%eq_hello = icmp eq i32 %hello_l, 0
@@ -57,7 +57,7 @@ define i1 @test_simplify5() {
}
define i1 @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
%null_l = call i32 @strlen(i8* %null_p)
%eq_null = icmp eq i32 %null_l, 0
@@ -68,7 +68,7 @@ define i1 @test_simplify6() {
; Check strlen(x) != 0 --> *x != 0.
define i1 @test_simplify7() {
-; CHECK: @test_simplify7
+; CHECK-LABEL: @test_simplify7(
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0
%hello_l = call i32 @strlen(i8* %hello_p)
%ne_hello = icmp ne i32 %hello_l, 0
@@ -77,7 +77,7 @@ define i1 @test_simplify7() {
}
define i1 @test_simplify8() {
-; CHECK: @test_simplify8
+; CHECK-LABEL: @test_simplify8(
%null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
%null_l = call i32 @strlen(i8* %null_p)
%ne_null = icmp ne i32 %null_l, 0
@@ -88,7 +88,7 @@ define i1 @test_simplify8() {
; Check cases that shouldn't be simplified.
define i32 @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%a_p = getelementptr [32 x i8]* @a, i32 0, i32 0
%a_l = call i32 @strlen(i8* %a_p)
; CHECK-NEXT: %a_l = call i32 @strlen
diff --git a/test/Transforms/InstCombine/strlen-2.ll b/test/Transforms/InstCombine/strlen-2.ll
index c4fd54c06db9..6652a310ba6a 100644
--- a/test/Transforms/InstCombine/strlen-2.ll
+++ b/test/Transforms/InstCombine/strlen-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i32 @strlen(i8*, i32)
define i32 @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0
%hello_l = call i32 @strlen(i8* %hello_p, i32 187)
; CHECK-NEXT: %hello_l = call i32 @strlen
diff --git a/test/Transforms/InstCombine/strncat-1.ll b/test/Transforms/InstCombine/strncat-1.ll
index ad2a18b1465d..8eae3dae2e23 100644
--- a/test/Transforms/InstCombine/strncat-1.ll
+++ b/test/Transforms/InstCombine/strncat-1.ll
@@ -12,7 +12,7 @@ declare i8* @strncat(i8*, i8*, i32)
declare i32 @puts(i8*)
define i32 @main() {
-; CHECK: @main
+; CHECK-LABEL: @main(
; CHECK-NOT: call i8* @strncat
; CHECK: call i32 @puts
diff --git a/test/Transforms/InstCombine/strncat-2.ll b/test/Transforms/InstCombine/strncat-2.ll
index c56deacd39bb..b09fa1260a03 100644
--- a/test/Transforms/InstCombine/strncat-2.ll
+++ b/test/Transforms/InstCombine/strncat-2.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i8* @strncat(i8*, i8*, i32)
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
; CHECK-NOT: call i8* @strncat
; CHECK: ret void
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
; CHECK-NEXT: ret void
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
@@ -32,7 +32,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
; CHECK-NEXT: ret void
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
@@ -42,7 +42,7 @@ define void @test_simplify3() {
}
define void @test_nosimplify1() {
-; CHECK: @test_nosimplify1
+; CHECK-LABEL: @test_nosimplify1(
; CHECK: call i8* @strncat
; CHECK: ret void
diff --git a/test/Transforms/InstCombine/strncat-3.ll b/test/Transforms/InstCombine/strncat-3.ll
index 3cd797168705..1b25b4aca1ae 100644
--- a/test/Transforms/InstCombine/strncat-3.ll
+++ b/test/Transforms/InstCombine/strncat-3.ll
@@ -11,7 +11,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16* @strncat(i8*, i8*, i32)
define void @test_nosimplify1() {
-; CHECK: @test_nosimplify1
+; CHECK-LABEL: @test_nosimplify1(
; CHECK: call i16* @strncat
; CHECK: ret void
diff --git a/test/Transforms/InstCombine/strncmp-1.ll b/test/Transforms/InstCombine/strncmp-1.ll
index 187c2fa50e82..df30dd100443 100644
--- a/test/Transforms/InstCombine/strncmp-1.ll
+++ b/test/Transforms/InstCombine/strncmp-1.ll
@@ -12,7 +12,7 @@ declare i32 @strncmp(i8*, i8*, i32)
; strncmp("", x, n) -> -*x
define i32 @test1(i8* %str2) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %strcmpload = load i8* %str
; CHECK: %1 = zext i8 %strcmpload to i32
; CHECK: %2 = sub i32 0, %1
@@ -25,7 +25,7 @@ define i32 @test1(i8* %str2) {
; strncmp(x, "", n) -> *x
define i32 @test2(i8* %str1) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: %strcmpload = load i8* %str1
; CHECK: %1 = zext i8 %strcmpload to i32
; CHECK: ret i32 %1
@@ -37,7 +37,7 @@ define i32 @test2(i8* %str1) {
; strncmp(x, y, n) -> cnst
define i32 @test3() {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i32 -1
%str1 = getelementptr inbounds [5 x i8]* @hell, i32 0, i32 0
@@ -47,7 +47,7 @@ define i32 @test3() {
}
define i32 @test4() {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: ret i32 1
%str1 = getelementptr inbounds [5 x i8]* @hell, i32 0, i32 0
@@ -57,7 +57,7 @@ define i32 @test4() {
}
define i32 @test5() {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: ret i32 0
%str1 = getelementptr inbounds [5 x i8]* @hell, i32 0, i32 0
@@ -68,7 +68,7 @@ define i32 @test5() {
; strncmp(x,y,1) -> memcmp(x,y,1)
define i32 @test6(i8* %str1, i8* %str2) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: [[LOAD1:%[a-z]+]] = load i8* %str1, align 1
; CHECK: [[ZEXT1:%[a-z]+]] = zext i8 [[LOAD1]] to i32
; CHECK: [[LOAD2:%[a-z]+]] = load i8* %str2, align 1
@@ -82,7 +82,7 @@ define i32 @test6(i8* %str1, i8* %str2) {
; strncmp(x,y,0) -> 0
define i32 @test7(i8* %str1, i8* %str2) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: ret i32 0
%temp1 = call i32 @strncmp(i8* %str1, i8* %str2, i32 0)
@@ -91,7 +91,7 @@ define i32 @test7(i8* %str1, i8* %str2) {
; strncmp(x,x,n) -> 0
define i32 @test8(i8* %str, i32 %n) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: ret i32 0
%temp1 = call i32 @strncmp(i8* %str, i8* %str, i32 %n)
diff --git a/test/Transforms/InstCombine/strncmp-2.ll b/test/Transforms/InstCombine/strncmp-2.ll
index 3fc43a6fd4f5..16ad8a4f62a7 100644
--- a/test/Transforms/InstCombine/strncmp-2.ll
+++ b/test/Transforms/InstCombine/strncmp-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
declare i16 @strncmp(i8*, i8*, i32)
define i16 @test_nosimplify() {
-; CHECK: @test_nosimplify
+; CHECK-LABEL: @test_nosimplify(
; CHECK: call i16 @strncmp
; CHECK: ret i16 %temp1
diff --git a/test/Transforms/InstCombine/strncpy-1.ll b/test/Transforms/InstCombine/strncpy-1.ll
index 3ce2b9b5eecc..c70197f12e28 100644
--- a/test/Transforms/InstCombine/strncpy-1.ll
+++ b/test/Transforms/InstCombine/strncpy-1.ll
@@ -16,7 +16,7 @@ declare i32 @puts(i8*)
; Check a bunch of strncpy invocations together.
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
; CHECK-NOT: call i8* @strncpy
; CHECK: call i32 @puts
%target = alloca [1024 x i8]
@@ -39,7 +39,7 @@ define i32 @test_simplify1() {
; Check strncpy(x, "", y) -> memset(x, '\0', y, 1).
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [1 x i8]* @null, i32 0, i32 0
@@ -51,7 +51,7 @@ define void @test_simplify2() {
; Check strncpy(x, y, 0) -> x.
define i8* @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
@@ -63,7 +63,7 @@ define i8* @test_simplify3() {
; Check strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant].
define void @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
@@ -75,7 +75,7 @@ define void @test_simplify4() {
; Check cases that shouldn't be simplified.
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [32 x i8]* @b, i32 0, i32 0
@@ -85,7 +85,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2() {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strncpy-2.ll b/test/Transforms/InstCombine/strncpy-2.ll
index ac28ea655009..acc2878648fc 100644
--- a/test/Transforms/InstCombine/strncpy-2.ll
+++ b/test/Transforms/InstCombine/strncpy-2.ll
@@ -12,7 +12,7 @@ declare i16* @strncpy(i8*, i8*, i32)
; Check that 'strncpy' functions with the wrong prototype aren't simplified.
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr [32 x i8]* @a, i32 0, i32 0
%src = getelementptr [6 x i8]* @hello, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strncpy_chk-1.ll b/test/Transforms/InstCombine/strncpy_chk-1.ll
index aadff4268ec2..90b4173ced77 100644
--- a/test/Transforms/InstCombine/strncpy_chk-1.ll
+++ b/test/Transforms/InstCombine/strncpy_chk-1.ll
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
; Check cases where dstlen >= len
define void @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -22,7 +22,7 @@ define void @test_simplify1() {
}
define void @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -32,7 +32,7 @@ define void @test_simplify2() {
}
define void @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
@@ -44,7 +44,7 @@ define void @test_simplify3() {
; Check cases where dstlen < len
define void @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
@@ -54,7 +54,7 @@ define void @test_no_simplify1() {
}
define void @test_no_simplify2() {
-; CHECK: @test_no_simplify2
+; CHECK-LABEL: @test_no_simplify2(
%dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i8]* @b, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strncpy_chk-2.ll b/test/Transforms/InstCombine/strncpy_chk-2.ll
index a0f132ebf63b..829a4798f09a 100644
--- a/test/Transforms/InstCombine/strncpy_chk-2.ll
+++ b/test/Transforms/InstCombine/strncpy_chk-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@b = common global [60 x i16] zeroinitializer, align 1
define void @test_no_simplify() {
-; CHECK: @test_no_simplify
+; CHECK-LABEL: @test_no_simplify(
%dst = getelementptr inbounds [60 x i16]* @a, i32 0, i32 0
%src = getelementptr inbounds [60 x i16]* @b, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strpbrk-1.ll b/test/Transforms/InstCombine/strpbrk-1.ll
index a5d0d86501b1..58b2d9e88d2c 100644
--- a/test/Transforms/InstCombine/strpbrk-1.ll
+++ b/test/Transforms/InstCombine/strpbrk-1.ll
@@ -13,7 +13,7 @@ declare i8* @strpbrk(i8*, i8*)
; Check strpbrk(s, "") -> NULL.
define i8* @test_simplify1(i8* %str) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%pat = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i8* @strpbrk(i8* %str, i8* %pat)
@@ -24,7 +24,7 @@ define i8* @test_simplify1(i8* %str) {
; Check strpbrk("", s) -> NULL.
define i8* @test_simplify2(i8* %pat) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%str = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i8* @strpbrk(i8* %str, i8* %pat)
@@ -35,7 +35,7 @@ define i8* @test_simplify2(i8* %pat) {
; Check strpbrk(s1, s2), where s1 and s2 are constants.
define i8* @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr [12 x i8]* @hello, i32 0, i32 0
%pat = getelementptr [2 x i8]* @w, i32 0, i32 0
@@ -47,7 +47,7 @@ define i8* @test_simplify3() {
; Check strpbrk(s, "a") -> strchr(s, 'a').
define i8* @test_simplify4(i8* %str) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%pat = getelementptr [2 x i8]* @w, i32 0, i32 0
%ret = call i8* @strpbrk(i8* %str, i8* %pat)
@@ -59,7 +59,7 @@ define i8* @test_simplify4(i8* %str) {
; Check cases that shouldn't be simplified.
define i8* @test_no_simplify1(i8* %str, i8* %pat) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i8* @strpbrk(i8* %str, i8* %pat)
; CHECK-NEXT: %ret = call i8* @strpbrk(i8* %str, i8* %pat)
diff --git a/test/Transforms/InstCombine/strpbrk-2.ll b/test/Transforms/InstCombine/strpbrk-2.ll
index 31ac2905df2c..b797d7a59527 100644
--- a/test/Transforms/InstCombine/strpbrk-2.ll
+++ b/test/Transforms/InstCombine/strpbrk-2.ll
@@ -12,7 +12,7 @@ declare i16* @strpbrk(i8*, i8*)
; Check that 'strpbrk' functions with the wrong prototype aren't simplified.
define i16* @test_no_simplify1() {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%str = getelementptr [12 x i8]* @hello, i32 0, i32 0
%pat = getelementptr [2 x i8]* @w, i32 0, i32 0
diff --git a/test/Transforms/InstCombine/strrchr-1.ll b/test/Transforms/InstCombine/strrchr-1.ll
index 854ce45bffb2..4615f5f2bd25 100644
--- a/test/Transforms/InstCombine/strrchr-1.ll
+++ b/test/Transforms/InstCombine/strrchr-1.ll
@@ -42,8 +42,19 @@ define void @test_simplify3() {
ret void
}
+define void @test_simplify4() {
+; CHECK: store i8* getelementptr inbounds ([14 x i8]* @hello, i32 0, i32 13)
+; CHECK-NOT: call i8* @strrchr
+; CHECK: ret void
+
+ %src = getelementptr [14 x i8]* @hello, i32 0, i32 0
+ %dst = call i8* @strrchr(i8* %src, i32 65280)
+ store i8* %dst, i8** @chp
+ ret void
+}
+
define void @test_nosimplify1(i32 %chr) {
-; CHECK: @test_nosimplify1
+; CHECK-LABEL: @test_nosimplify1(
; CHECK: call i8* @strrchr
; CHECK: ret void
diff --git a/test/Transforms/InstCombine/strspn-1.ll b/test/Transforms/InstCombine/strspn-1.ll
index 393f88735bd4..ac940cce9e56 100644
--- a/test/Transforms/InstCombine/strspn-1.ll
+++ b/test/Transforms/InstCombine/strspn-1.ll
@@ -13,7 +13,7 @@ declare i64 @strspn(i8*, i8*)
; Check strspn(s, "") -> 0.
define i64 @test_simplify1(i8* %str) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%pat = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i64 @strspn(i8* %str, i8* %pat)
@@ -24,7 +24,7 @@ define i64 @test_simplify1(i8* %str) {
; Check strspn("", s) -> 0.
define i64 @test_simplify2(i8* %pat) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%str = getelementptr [1 x i8]* @null, i32 0, i32 0
%ret = call i64 @strspn(i8* %str, i8* %pat)
@@ -35,7 +35,7 @@ define i64 @test_simplify2(i8* %pat) {
; Check strspn(s1, s2), where s1 and s2 are constants.
define i64 @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr [6 x i8]* @abcba, i32 0, i32 0
%pat = getelementptr [4 x i8]* @abc, i32 0, i32 0
@@ -47,7 +47,7 @@ define i64 @test_simplify3() {
; Check cases that shouldn't be simplified.
define i64 @test_no_simplify1(i8* %str, i8* %pat) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%ret = call i64 @strspn(i8* %str, i8* %pat)
; CHECK-NEXT: %ret = call i64 @strspn(i8* %str, i8* %pat)
diff --git a/test/Transforms/InstCombine/strstr-1.ll b/test/Transforms/InstCombine/strstr-1.ll
index 81f52718747d..a946dd32779a 100644
--- a/test/Transforms/InstCombine/strstr-1.ll
+++ b/test/Transforms/InstCombine/strstr-1.ll
@@ -14,7 +14,7 @@ declare i8* @strstr(i8*, i8*)
; Check strstr(str, "") -> str.
define i8* @test_simplify1(i8* %str) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%pat = getelementptr inbounds [1 x i8]* @.str, i32 0, i32 0
%ret = call i8* @strstr(i8* %str, i8* %pat)
ret i8* %ret
@@ -24,7 +24,7 @@ define i8* @test_simplify1(i8* %str) {
; Check strstr(str, "a") -> strchr(str, 'a').
define i8* @test_simplify2(i8* %str) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%pat = getelementptr inbounds [2 x i8]* @.str1, i32 0, i32 0
%ret = call i8* @strstr(i8* %str, i8* %pat)
ret i8* %ret
@@ -34,7 +34,7 @@ define i8* @test_simplify2(i8* %str) {
; Check strstr("abcde", "bcd") -> "abcde" + 1.
define i8* @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%str = getelementptr inbounds [6 x i8]* @.str2, i32 0, i32 0
%pat = getelementptr inbounds [4 x i8]* @.str3, i32 0, i32 0
%ret = call i8* @strstr(i8* %str, i8* %pat)
@@ -45,7 +45,7 @@ define i8* @test_simplify3() {
; Check strstr(str, str) -> str.
define i8* @test_simplify4(i8* %str) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%ret = call i8* @strstr(i8* %str, i8* %str)
ret i8* %ret
; CHECK-NEXT: ret i8* %str
@@ -54,7 +54,7 @@ define i8* @test_simplify4(i8* %str) {
; Check strstr(str, pat) == str -> strncmp(str, pat, strlen(str)) == 0.
define i1 @test_simplify5(i8* %str, i8* %pat) {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%ret = call i8* @strstr(i8* %str, i8* %pat)
%cmp = icmp eq i8* %ret, %str
ret i1 %cmp
diff --git a/test/Transforms/InstCombine/strstr-2.ll b/test/Transforms/InstCombine/strstr-2.ll
index 5092f9b4f803..7b28ed0e691e 100644
--- a/test/Transforms/InstCombine/strstr-2.ll
+++ b/test/Transforms/InstCombine/strstr-2.ll
@@ -9,7 +9,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
declare i8 @strstr(i8*, i8*)
define i8 @test_no_simplify1(i8* %str) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
%pat = getelementptr inbounds [1 x i8]* @null, i32 0, i32 0
%ret = call i8 @strstr(i8* %str, i8* %pat)
; CHECK-NEXT: call i8 @strstr
diff --git a/test/Transforms/InstCombine/strto-1.ll b/test/Transforms/InstCombine/strto-1.ll
index 7139972fe043..fc35dddcae5a 100644
--- a/test/Transforms/InstCombine/strto-1.ll
+++ b/test/Transforms/InstCombine/strto-1.ll
@@ -5,77 +5,77 @@
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
declare i64 @strtol(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare i64 @strtol(i8*, i8** nocapture, i32)
+; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32)
declare double @strtod(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare double @strtod(i8*, i8** nocapture, i32)
+; CHECK: declare double @strtod(i8* readonly, i8** nocapture, i32)
declare float @strtof(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare float @strtof(i8*, i8** nocapture, i32)
+; CHECK: declare float @strtof(i8* readonly, i8** nocapture, i32)
declare i64 @strtoul(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare i64 @strtoul(i8*, i8** nocapture, i32)
+; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32)
declare i64 @strtoll(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare i64 @strtoll(i8*, i8** nocapture, i32)
+; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32)
declare double @strtold(i8* %s, i8** %endptr)
-; CHECK: declare double @strtold(i8*, i8** nocapture)
+; CHECK: declare double @strtold(i8* readonly, i8** nocapture)
declare i64 @strtoull(i8* %s, i8** %endptr, i32 %base)
-; CHECK: declare i64 @strtoull(i8*, i8** nocapture, i32)
+; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32)
define void @test_simplify1(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
call i64 @strtol(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call i64 @strtol(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_simplify2(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
call double @strtod(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call double @strtod(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_simplify3(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
call float @strtof(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call float @strtof(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_simplify4(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
call i64 @strtoul(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call i64 @strtoul(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_simplify5(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
call i64 @strtoll(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call i64 @strtoll(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_simplify6(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
call double @strtold(i8* %x, i8** null)
; CHECK-NEXT: call double @strtold(i8* nocapture %x, i8** null)
ret void
}
define void @test_simplify7(i8* %x, i8** %endptr) {
-; CHECK: @test_simplify7
+; CHECK-LABEL: @test_simplify7(
call i64 @strtoull(i8* %x, i8** null, i32 10)
; CHECK-NEXT: call i64 @strtoull(i8* nocapture %x, i8** null, i32 10)
ret void
}
define void @test_no_simplify1(i8* %x, i8** %endptr) {
-; CHECK: @test_no_simplify1
+; CHECK-LABEL: @test_no_simplify1(
call i64 @strtol(i8* %x, i8** %endptr, i32 10)
; CHECK-NEXT: call i64 @strtol(i8* %x, i8** %endptr, i32 10)
ret void
diff --git a/test/Transforms/InstCombine/struct-assign-tbaa.ll b/test/Transforms/InstCombine/struct-assign-tbaa.ll
index 33a771e6d8b6..c80e31ae3ddc 100644
--- a/test/Transforms/InstCombine/struct-assign-tbaa.ll
+++ b/test/Transforms/InstCombine/struct-assign-tbaa.ll
@@ -24,7 +24,7 @@ entry:
%struct.test2 = type { i32 (i8*, i32*, double*)** }
define i32 (i8*, i32*, double*)*** @test2() {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: memcpy
; CHECK: ret
%tmp = alloca %struct.test2, align 8
@@ -35,10 +35,12 @@ define i32 (i8*, i32*, double*)*** @test2() {
ret i32 (i8*, i32*, double*)*** %tmp2
}
-; CHECK: !0 = metadata !{metadata !"float", metadata !1}
+; CHECK: !0 = metadata !{metadata !1, metadata !1, i64 0}
+; CHECK: !1 = metadata !{metadata !"float", metadata !2}
!0 = metadata !{metadata !"Simple C/C++ TBAA"}
!1 = metadata !{metadata !"omnipotent char", metadata !0}
-!2 = metadata !{metadata !"float", metadata !0}
+!2 = metadata !{metadata !5, metadata !5, i64 0}
!3 = metadata !{i64 0, i64 4, metadata !2}
!4 = metadata !{i64 0, i64 8, null}
+!5 = metadata !{metadata !"float", metadata !0}
diff --git a/test/Transforms/InstCombine/sub-xor.ll b/test/Transforms/InstCombine/sub-xor.ll
index 1d14852bc803..e7aff00ba8d0 100644
--- a/test/Transforms/InstCombine/sub-xor.ll
+++ b/test/Transforms/InstCombine/sub-xor.ll
@@ -5,7 +5,7 @@ define i32 @test1(i32 %x) nounwind {
%sub = sub i32 63, %and
ret i32 %sub
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NEXT: and i32 %x, 31
; CHECK-NEXT: xor i32 %and, 63
; CHECK-NEXT: ret
@@ -18,7 +18,7 @@ define i32 @test2(i32 %x) nounwind {
%sub = sub i32 31, %count
ret i32 %sub
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: ctlz
; CHECK-NEXT: xor i32 %count, 31
; CHECK-NEXT: ret
@@ -30,7 +30,7 @@ define i32 @test3(i32 %x) nounwind {
%add = add i32 %sub, 42
ret i32 %add
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: and i32 %x, 31
; CHECK-NEXT: sub i32 73, %and
; CHECK-NEXT: ret
@@ -41,7 +41,7 @@ define i32 @test4(i32 %x) nounwind {
%add = add i32 %sub, 42
ret i32 %add
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: add i32 %x, -2147483606
; CHECK-NEXT: ret
}
diff --git a/test/Transforms/InstCombine/sub.ll b/test/Transforms/InstCombine/sub.ll
index b71ec8c98f83..36c523bd7b75 100644
--- a/test/Transforms/InstCombine/sub.ll
+++ b/test/Transforms/InstCombine/sub.ll
@@ -1,156 +1,156 @@
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
; Optimize subtracts.
;
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @test1(i32 %A) {
- %B = sub i32 %A, %A
+ %B = sub i32 %A, %A
ret i32 %B
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret i32 0
}
define i32 @test2(i32 %A) {
- %B = sub i32 %A, 0
+ %B = sub i32 %A, 0
ret i32 %B
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret i32 %A
}
define i32 @test3(i32 %A) {
- %B = sub i32 0, %A
- %C = sub i32 0, %B
+ %B = sub i32 0, %A
+ %C = sub i32 0, %B
ret i32 %C
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret i32 %A
}
define i32 @test4(i32 %A, i32 %x) {
- %B = sub i32 0, %A
- %C = sub i32 %x, %B
+ %B = sub i32 0, %A
+ %C = sub i32 %x, %B
ret i32 %C
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: %C = add i32 %x, %A
; CHECK: ret i32 %C
}
define i32 @test5(i32 %A, i32 %B, i32 %C) {
- %D = sub i32 %B, %C
- %E = sub i32 %A, %D
+ %D = sub i32 %B, %C
+ %E = sub i32 %A, %D
ret i32 %E
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %D1 = sub i32 %C, %B
; CHECK: %E = add
; CHECK: ret i32 %E
}
define i32 @test6(i32 %A, i32 %B) {
- %C = and i32 %A, %B
- %D = sub i32 %A, %C
+ %C = and i32 %A, %B
+ %D = sub i32 %A, %C
ret i32 %D
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: xor i32 %B, -1
-; CHECK-NEXT: %D = and i32
+; CHECK-NEXT: %D = and i32
; CHECK-NEXT: ret i32 %D
}
define i32 @test7(i32 %A) {
- %B = sub i32 -1, %A
+ %B = sub i32 -1, %A
ret i32 %B
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %B = xor i32 %A, -1
; CHECK: ret i32 %B
}
define i32 @test8(i32 %A) {
- %B = mul i32 9, %A
- %C = sub i32 %B, %A
+ %B = mul i32 9, %A
+ %C = sub i32 %B, %A
ret i32 %C
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: %C = shl i32 %A, 3
; CHECK: ret i32 %C
}
define i32 @test9(i32 %A) {
- %B = mul i32 3, %A
- %C = sub i32 %A, %B
+ %B = mul i32 3, %A
+ %C = sub i32 %A, %B
ret i32 %C
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: %C = mul i32 %A, -2
; CHECK: ret i32 %C
}
define i32 @test10(i32 %A, i32 %B) {
- %C = sub i32 0, %A
- %D = sub i32 0, %B
- %E = mul i32 %C, %D
+ %C = sub i32 0, %A
+ %D = sub i32 0, %B
+ %E = mul i32 %C, %D
ret i32 %E
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: %E = mul i32 %A, %B
; CHECK: ret i32 %E
}
define i32 @test10a(i32 %A) {
- %C = sub i32 0, %A
- %E = mul i32 %C, 7
+ %C = sub i32 0, %A
+ %E = mul i32 %C, 7
ret i32 %E
-; CHECK: @test10a
+; CHECK-LABEL: @test10a(
; CHECK: %E = mul i32 %A, -7
; CHECK: ret i32 %E
}
define i1 @test11(i8 %A, i8 %B) {
- %C = sub i8 %A, %B
- %cD = icmp ne i8 %C, 0
+ %C = sub i8 %A, %B
+ %cD = icmp ne i8 %C, 0
ret i1 %cD
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK: %cD = icmp ne i8 %A, %B
; CHECK: ret i1 %cD
}
define i32 @test12(i32 %A) {
- %B = ashr i32 %A, 31
- %C = sub i32 0, %B
+ %B = ashr i32 %A, 31
+ %C = sub i32 0, %B
ret i32 %C
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK: %C = lshr i32 %A, 31
; CHECK: ret i32 %C
}
define i32 @test13(i32 %A) {
- %B = lshr i32 %A, 31
- %C = sub i32 0, %B
+ %B = lshr i32 %A, 31
+ %C = sub i32 0, %B
ret i32 %C
-; CHECK: @test13
+; CHECK-LABEL: @test13(
; CHECK: %C = ashr i32 %A, 31
; CHECK: ret i32 %C
}
define i32 @test14(i32 %A) {
- %B = lshr i32 %A, 31
- %C = bitcast i32 %B to i32
- %D = sub i32 0, %C
+ %B = lshr i32 %A, 31
+ %C = bitcast i32 %B to i32
+ %D = sub i32 0, %C
ret i32 %D
-; CHECK: @test14
+; CHECK-LABEL: @test14(
; CHECK: %D = ashr i32 %A, 31
; CHECK: ret i32 %D
}
define i32 @test15(i32 %A, i32 %B) {
- %C = sub i32 0, %A
- %D = srem i32 %B, %C
+ %C = sub i32 0, %A
+ %D = srem i32 %B, %C
ret i32 %D
-; CHECK: @test15
-; CHECK: %D = srem i32 %B, %A
+; CHECK-LABEL: @test15(
+; CHECK: %D = srem i32 %B, %A
; CHECK: ret i32 %D
}
define i32 @test16(i32 %A) {
- %X = sdiv i32 %A, 1123
- %Y = sub i32 0, %X
+ %X = sdiv i32 %A, 1123
+ %Y = sub i32 0, %X
ret i32 %Y
-; CHECK: @test16
+; CHECK-LABEL: @test16(
; CHECK: %Y = sdiv i32 %A, -1123
; CHECK: ret i32 %Y
}
@@ -158,57 +158,57 @@ define i32 @test16(i32 %A) {
; Can't fold subtract here because negation it might oveflow.
; PR3142
define i32 @test17(i32 %A) {
- %B = sub i32 0, %A
- %C = sdiv i32 %B, 1234
+ %B = sub i32 0, %A
+ %C = sdiv i32 %B, 1234
ret i32 %C
-; CHECK: @test17
+; CHECK-LABEL: @test17(
; CHECK: %B = sub i32 0, %A
; CHECK: %C = sdiv i32 %B, 1234
; CHECK: ret i32 %C
}
define i64 @test18(i64 %Y) {
- %tmp.4 = shl i64 %Y, 2
- %tmp.12 = shl i64 %Y, 2
- %tmp.8 = sub i64 %tmp.4, %tmp.12
+ %tmp.4 = shl i64 %Y, 2
+ %tmp.12 = shl i64 %Y, 2
+ %tmp.8 = sub i64 %tmp.4, %tmp.12
ret i64 %tmp.8
-; CHECK: @test18
+; CHECK-LABEL: @test18(
; CHECK: ret i64 0
}
define i32 @test19(i32 %X, i32 %Y) {
- %Z = sub i32 %X, %Y
- %Q = add i32 %Z, %Y
+ %Z = sub i32 %X, %Y
+ %Q = add i32 %Z, %Y
ret i32 %Q
-; CHECK: @test19
+; CHECK-LABEL: @test19(
; CHECK: ret i32 %X
}
define i1 @test20(i32 %g, i32 %h) {
- %tmp.2 = sub i32 %g, %h
- %tmp.4 = icmp ne i32 %tmp.2, %g
+ %tmp.2 = sub i32 %g, %h
+ %tmp.4 = icmp ne i32 %tmp.2, %g
ret i1 %tmp.4
-; CHECK: @test20
+; CHECK-LABEL: @test20(
; CHECK: %tmp.4 = icmp ne i32 %h, 0
; CHECK: ret i1 %tmp.4
}
define i1 @test21(i32 %g, i32 %h) {
- %tmp.2 = sub i32 %g, %h
- %tmp.4 = icmp ne i32 %tmp.2, %g
+ %tmp.2 = sub i32 %g, %h
+ %tmp.4 = icmp ne i32 %tmp.2, %g
ret i1 %tmp.4
-; CHECK: @test21
+; CHECK-LABEL: @test21(
; CHECK: %tmp.4 = icmp ne i32 %h, 0
; CHECK: ret i1 %tmp.4
}
; PR2298
define zeroext i1 @test22(i32 %a, i32 %b) nounwind {
- %tmp2 = sub i32 0, %a
- %tmp4 = sub i32 0, %b
- %tmp5 = icmp eq i32 %tmp2, %tmp4
+ %tmp2 = sub i32 0, %a
+ %tmp4 = sub i32 0, %b
+ %tmp5 = icmp eq i32 %tmp2, %tmp4
ret i1 %tmp5
-; CHECK: @test22
+; CHECK-LABEL: @test22(
; CHECK: %tmp5 = icmp eq i32 %b, %a
; CHECK: ret i1 %tmp5
}
@@ -222,32 +222,67 @@ define i32 @test23(i8* %P, i64 %A){
%F = trunc i64 %E to i32
%G = sub i32 %D, %F
ret i32 %G
-; CHECK: @test23
+; CHECK-LABEL: @test23(
; CHECK-NEXT: = trunc i64 %A to i32
; CHECK-NEXT: ret i32
}
+define i8 @test23_as1(i8 addrspace(1)* %P, i16 %A) {
+; CHECK: @test23_as1
+; CHECK-NEXT: = trunc i16 %A to i8
+; CHECK-NEXT: ret i8
+ %B = getelementptr inbounds i8 addrspace(1)* %P, i16 %A
+ %C = ptrtoint i8 addrspace(1)* %B to i16
+ %D = trunc i16 %C to i8
+ %E = ptrtoint i8 addrspace(1)* %P to i16
+ %F = trunc i16 %E to i8
+ %G = sub i8 %D, %F
+ ret i8 %G
+}
+
define i64 @test24(i8* %P, i64 %A){
%B = getelementptr inbounds i8* %P, i64 %A
%C = ptrtoint i8* %B to i64
%E = ptrtoint i8* %P to i64
%G = sub i64 %C, %E
ret i64 %G
-; CHECK: @test24
+; CHECK-LABEL: @test24(
; CHECK-NEXT: ret i64 %A
}
+define i16 @test24_as1(i8 addrspace(1)* %P, i16 %A) {
+; CHECK: @test24_as1
+; CHECK-NEXT: ret i16 %A
+ %B = getelementptr inbounds i8 addrspace(1)* %P, i16 %A
+ %C = ptrtoint i8 addrspace(1)* %B to i16
+ %E = ptrtoint i8 addrspace(1)* %P to i16
+ %G = sub i16 %C, %E
+ ret i16 %G
+}
+
define i64 @test24a(i8* %P, i64 %A){
%B = getelementptr inbounds i8* %P, i64 %A
%C = ptrtoint i8* %B to i64
%E = ptrtoint i8* %P to i64
%G = sub i64 %E, %C
ret i64 %G
-; CHECK: @test24a
+; CHECK-LABEL: @test24a(
; CHECK-NEXT: sub i64 0, %A
-; CHECK-NEXT: ret i64
+; CHECK-NEXT: ret i64
}
+define i16 @test24a_as1(i8 addrspace(1)* %P, i16 %A) {
+; CHECK: @test24a_as1
+; CHECK-NEXT: sub i16 0, %A
+; CHECK-NEXT: ret i16
+ %B = getelementptr inbounds i8 addrspace(1)* %P, i16 %A
+ %C = ptrtoint i8 addrspace(1)* %B to i16
+ %E = ptrtoint i8 addrspace(1)* %P to i16
+ %G = sub i16 %E, %C
+ ret i16 %G
+}
+
+
@Arr = external global [42 x i16]
define i64 @test24b(i8* %P, i64 %A){
@@ -255,9 +290,9 @@ define i64 @test24b(i8* %P, i64 %A){
%C = ptrtoint i16* %B to i64
%G = sub i64 %C, ptrtoint ([42 x i16]* @Arr to i64)
ret i64 %G
-; CHECK: @test24b
+; CHECK-LABEL: @test24b(
; CHECK-NEXT: shl nuw i64 %A, 1
-; CHECK-NEXT: ret i64
+; CHECK-NEXT: ret i64
}
@@ -266,17 +301,31 @@ define i64 @test25(i8* %P, i64 %A){
%C = ptrtoint i16* %B to i64
%G = sub i64 %C, ptrtoint (i16* getelementptr ([42 x i16]* @Arr, i64 1, i64 0) to i64)
ret i64 %G
-; CHECK: @test25
+; CHECK-LABEL: @test25(
; CHECK-NEXT: shl nuw i64 %A, 1
; CHECK-NEXT: add i64 {{.*}}, -84
-; CHECK-NEXT: ret i64
+; CHECK-NEXT: ret i64
+}
+
+@Arr_as1 = external addrspace(1) global [42 x i16]
+
+define i16 @test25_as1(i8 addrspace(1)* %P, i64 %A) {
+; CHECK: @test25_as1
+; CHECK-NEXT: %1 = trunc i64 %A to i16
+; CHECK-NEXT: shl nuw i16 %1, 1
+; CHECK-NEXT: add i16 {{.*}}, -84
+; CHECK-NEXT: ret i16
+ %B = getelementptr inbounds [42 x i16] addrspace(1)* @Arr_as1, i64 0, i64 %A
+ %C = ptrtoint i16 addrspace(1)* %B to i16
+ %G = sub i16 %C, ptrtoint (i16 addrspace(1)* getelementptr ([42 x i16] addrspace(1)* @Arr_as1, i64 1, i64 0) to i16)
+ ret i16 %G
}
define i32 @test26(i32 %x) {
%shl = shl i32 3, %x
%neg = sub i32 0, %shl
ret i32 %neg
-; CHECK: @test26
+; CHECK-LABEL: @test26(
; CHECK-NEXT: shl i32 -3
; CHECK-NEXT: ret i32
}
@@ -285,7 +334,7 @@ define i32 @test27(i32 %x, i32 %y) {
%mul = mul i32 %y, -8
%sub = sub i32 %x, %mul
ret i32 %sub
-; CHECK: @test27
+; CHECK-LABEL: @test27(
; CHECK-NEXT: shl i32 %y, 3
; CHECK-NEXT: add i32
; CHECK-NEXT: ret i32
@@ -296,7 +345,7 @@ define i32 @test28(i32 %x, i32 %y, i32 %z) {
%mul = mul i32 %neg, %y
%sub = sub i32 %x, %mul
ret i32 %sub
-; CHECK: @test28
+; CHECK-LABEL: @test28(
; CHECK-NEXT: mul i32 %z, %y
; CHECK-NEXT: add i32
; CHECK-NEXT: ret i32
@@ -309,7 +358,7 @@ define i64 @test29(i8* %foo, i64 %i, i64 %j) {
%cast2 = ptrtoint i8* %gep2 to i64
%sub = sub i64 %cast1, %cast2
ret i64 %sub
-; CHECK: @test29
+; CHECK-LABEL: @test29(
; CHECK-NEXT: sub i64 %i, %j
; CHECK-NEXT: ret i64
}
@@ -322,8 +371,24 @@ define i64 @test30(i8* %foo, i64 %i, i64 %j) {
%cast2 = ptrtoint i8* %gep2 to i64
%sub = sub i64 %cast1, %cast2
ret i64 %sub
-; CHECK: @test30
+; CHECK-LABEL: @test30(
; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2
; CHECK-NEXT: sub i64 %gep1.idx, %j
; CHECK-NEXT: ret i64
}
+
+define i16 @test30_as1(i8 addrspace(1)* %foo, i16 %i, i16 %j) {
+; CHECK-LABEL: @test30_as1(
+; CHECK-NEXT: %gep1.idx = shl nuw i16 %i, 2
+; CHECK-NEXT: sub i16 %gep1.idx, %j
+; CHECK-NEXT: ret i16
+ %bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
+ %gep1 = getelementptr inbounds i32 addrspace(1)* %bit, i16 %i
+ %gep2 = getelementptr inbounds i8 addrspace(1)* %foo, i16 %j
+ %cast1 = ptrtoint i32 addrspace(1)* %gep1 to i16
+ %cast2 = ptrtoint i8 addrspace(1)* %gep2 to i16
+ %sub = sub i16 %cast1, %cast2
+ ret i16 %sub
+}
+
+
diff --git a/test/Transforms/InstCombine/toascii-1.ll b/test/Transforms/InstCombine/toascii-1.ll
index c4a13e229393..f5e18983e122 100644
--- a/test/Transforms/InstCombine/toascii-1.ll
+++ b/test/Transforms/InstCombine/toascii-1.ll
@@ -9,49 +9,49 @@ declare i32 @toascii(i32)
; Check isascii(c) -> c & 0x7f.
define i32 @test_simplify1() {
-; CHECK: @test_simplify1
+; CHECK-LABEL: @test_simplify1(
%ret = call i32 @toascii(i32 0)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify2() {
-; CHECK: @test_simplify2
+; CHECK-LABEL: @test_simplify2(
%ret = call i32 @toascii(i32 1)
ret i32 %ret
; CHECK-NEXT: ret i32 1
}
define i32 @test_simplify3() {
-; CHECK: @test_simplify3
+; CHECK-LABEL: @test_simplify3(
%ret = call i32 @toascii(i32 127)
ret i32 %ret
; CHECK-NEXT: ret i32 127
}
define i32 @test_simplify4() {
-; CHECK: @test_simplify4
+; CHECK-LABEL: @test_simplify4(
%ret = call i32 @toascii(i32 128)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify5() {
-; CHECK: @test_simplify5
+; CHECK-LABEL: @test_simplify5(
%ret = call i32 @toascii(i32 255)
ret i32 %ret
; CHECK-NEXT: ret i32 127
}
define i32 @test_simplify6() {
-; CHECK: @test_simplify6
+; CHECK-LABEL: @test_simplify6(
%ret = call i32 @toascii(i32 256)
ret i32 %ret
; CHECK-NEXT: ret i32 0
}
define i32 @test_simplify7(i32 %x) {
-; CHECK: @test_simplify7
+; CHECK-LABEL: @test_simplify7(
%ret = call i32 @toascii(i32 %x)
; CHECK-NEXT: [[AND:%[a-z0-9]+]] = and i32 %x, 127
ret i32 %ret
diff --git a/test/Transforms/InstCombine/trunc.ll b/test/Transforms/InstCombine/trunc.ll
index cbbad7f79777..ee81cf8c3c5d 100644
--- a/test/Transforms/InstCombine/trunc.ll
+++ b/test/Transforms/InstCombine/trunc.ll
@@ -11,7 +11,7 @@ define i64 @test1(i64 %a) {
%d = zext i32 %c to i64
call void @use(i32 %b)
ret i64 %d
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK-NOT: ext
; CHECK: ret
}
@@ -22,7 +22,7 @@ define i64 @test2(i64 %a) {
%d = sext i32 %q to i64
call void @use(i32 %b)
ret i64 %d
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: shl i64 %a, 36
; CHECK: %d = ashr exact i64 {{.*}}, 36
; CHECK: ret i64 %d
@@ -33,7 +33,7 @@ define i64 @test3(i64 %a) {
%d = zext i32 %c to i64
call void @use(i32 %b)
ret i64 %d
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NOT: ext
; CHECK: ret
}
@@ -44,7 +44,7 @@ define i64 @test4(i64 %a) {
%d = zext i32 %x to i64
call void @use(i32 %b)
ret i64 %d
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: = and i64 %a, 8
; CHECK: = xor i64 {{.*}}, 8
; CHECK-NOT: ext
@@ -56,7 +56,7 @@ define i32 @test5(i32 %A) {
%C = lshr i128 %B, 16
%D = trunc i128 %C to i32
ret i32 %D
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: %C = lshr i32 %A, 16
; CHECK: ret i32 %C
}
@@ -66,7 +66,7 @@ define i32 @test6(i64 %A) {
%C = lshr i128 %B, 32
%D = trunc i128 %C to i32
ret i32 %D
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: %C = lshr i64 %A, 32
; CHECK: %D = trunc i64 %C to i32
; CHECK: ret i32 %D
@@ -77,7 +77,7 @@ define i92 @test7(i64 %A) {
%C = lshr i128 %B, 32
%D = trunc i128 %C to i92
ret i92 %D
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK: %B = zext i64 %A to i92
; CHECK: %C = lshr i92 %B, 32
; CHECK: ret i92 %C
@@ -90,7 +90,7 @@ define i64 @test8(i32 %A, i32 %B) {
%ins35 = or i128 %tmp33, %tmp38
%tmp42 = trunc i128 %ins35 to i64
ret i64 %tmp42
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK: %tmp38 = zext i32 %A to i64
; CHECK: %tmp32 = zext i32 %B to i64
; CHECK: %tmp33 = shl nuw i64 %tmp32, 32
@@ -102,7 +102,7 @@ define i8 @test9(i32 %X) {
%Y = and i32 %X, 42
%Z = trunc i32 %Y to i8
ret i8 %Z
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK: trunc
; CHECK: and
; CHECK: ret
@@ -113,7 +113,7 @@ define i8 @test10(i32 %X) {
%Y = trunc i32 %X to i8
%Z = and i8 %Y, 42
ret i8 %Z
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK: trunc
; CHECK: and
; CHECK: ret
diff --git a/test/Transforms/InstCombine/udivrem-change-width.ll b/test/Transforms/InstCombine/udivrem-change-width.ll
index b388a3b0634e..478e9ca387fc 100644
--- a/test/Transforms/InstCombine/udivrem-change-width.ll
+++ b/test/Transforms/InstCombine/udivrem-change-width.ll
@@ -9,7 +9,7 @@ define i8 @udiv_i8(i8 %a, i8 %b) nounwind {
%div = udiv i32 %conv, %conv2
%conv3 = trunc i32 %div to i8
ret i8 %conv3
-; CHECK: @udiv_i8
+; CHECK-LABEL: @udiv_i8(
; CHECK: udiv i8 %a, %b
}
@@ -19,7 +19,7 @@ define i8 @urem_i8(i8 %a, i8 %b) nounwind {
%div = urem i32 %conv, %conv2
%conv3 = trunc i32 %div to i8
ret i8 %conv3
-; CHECK: @urem_i8
+; CHECK-LABEL: @urem_i8(
; CHECK: urem i8 %a, %b
}
@@ -28,7 +28,7 @@ define i32 @udiv_i32(i8 %a, i8 %b) nounwind {
%conv2 = zext i8 %b to i32
%div = udiv i32 %conv, %conv2
ret i32 %div
-; CHECK: @udiv_i32
+; CHECK-LABEL: @udiv_i32(
; CHECK: udiv i8 %a, %b
; CHECK: zext
}
@@ -38,7 +38,7 @@ define i32 @urem_i32(i8 %a, i8 %b) nounwind {
%conv2 = zext i8 %b to i32
%div = urem i32 %conv, %conv2
ret i32 %div
-; CHECK: @urem_i32
+; CHECK-LABEL: @urem_i32(
; CHECK: urem i8 %a, %b
; CHECK: zext
}
@@ -47,7 +47,7 @@ define i32 @udiv_i32_c(i8 %a) nounwind {
%conv = zext i8 %a to i32
%div = udiv i32 %conv, 10
ret i32 %div
-; CHECK: @udiv_i32_c
+; CHECK-LABEL: @udiv_i32_c(
; CHECK: udiv i8 %a, 10
; CHECK: zext
}
@@ -56,7 +56,7 @@ define i32 @urem_i32_c(i8 %a) nounwind {
%conv = zext i8 %a to i32
%div = urem i32 %conv, 10
ret i32 %div
-; CHECK: @urem_i32_c
+; CHECK-LABEL: @urem_i32_c(
; CHECK: urem i8 %a, 10
; CHECK: zext
}
diff --git a/test/Transforms/InstCombine/vec_demanded_elts.ll b/test/Transforms/InstCombine/vec_demanded_elts.ll
index 0019a57627cb..d12412a92977 100644
--- a/test/Transforms/InstCombine/vec_demanded_elts.ll
+++ b/test/Transforms/InstCombine/vec_demanded_elts.ll
@@ -2,7 +2,7 @@
define i16 @test1(float %f) {
entry:
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: fmul float
; CHECK-NOT: insertelement {{.*}} 0.00
; CHECK-NOT: call {{.*}} @llvm.x86.sse.mul
@@ -22,7 +22,7 @@ entry:
}
define i32 @test2(float %f) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NOT: insertelement
; CHECK-NOT: extractelement
; CHECK: ret
@@ -37,7 +37,7 @@ define i32 @test2(float %f) {
}
define i64 @test3(float %f, double %d) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NOT: insertelement {{.*}} 0.00
; CHECK: ret
entry:
@@ -85,7 +85,7 @@ entry:
}
define void @get_image() nounwind {
-; CHECK: @get_image
+; CHECK-LABEL: @get_image(
; CHECK-NOT: extractelement
; CHECK: unreachable
entry:
@@ -105,7 +105,7 @@ bb3: ; preds = %bb2, %entry
; PR4340
define void @vac(<4 x float>* nocapture %a) nounwind {
-; CHECK: @vac
+; CHECK-LABEL: @vac(
; CHECK-NOT: load
; CHECK: ret
entry:
@@ -155,7 +155,7 @@ declare <4 x i32> @llvm.x86.sse41.pmovzxwd(<8 x i16>) nounwind readnone
define <4 x float> @dead_shuffle_elt(<4 x float> %x, <2 x float> %y) nounwind {
entry:
-; CHECK: define <4 x float> @dead_shuffle_elt
+; CHECK-LABEL: define <4 x float> @dead_shuffle_elt(
; CHECK: shufflevector <2 x float> %y, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%shuffle.i = shufflevector <2 x float> %y, <2 x float> %y, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
%shuffle9.i = shufflevector <4 x float> %x, <4 x float> %shuffle.i, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
@@ -163,7 +163,7 @@ entry:
}
define <2 x float> @test_fptrunc(double %f) {
-; CHECK: @test_fptrunc
+; CHECK-LABEL: @test_fptrunc(
; CHECK: insertelement
; CHECK: insertelement
; CHECK-NOT: insertelement
@@ -177,7 +177,7 @@ define <2 x float> @test_fptrunc(double %f) {
}
define <2 x double> @test_fpext(float %f) {
-; CHECK: @test_fpext
+; CHECK-LABEL: @test_fpext(
; CHECK: insertelement
; CHECK: insertelement
; CHECK-NOT: insertelement
@@ -191,7 +191,7 @@ define <2 x double> @test_fpext(float %f) {
}
define <4 x float> @test_select(float %f, float %g) {
-; CHECK: @test_select
+; CHECK-LABEL: @test_select(
; CHECK: %a0 = insertelement <4 x float> undef, float %f, i32 0
; CHECK-NOT: insertelement
; CHECK: %a3 = insertelement <4 x float> %a0, float 3.000000e+00, i32 3
diff --git a/test/Transforms/InstCombine/vec_extract_elt.ll b/test/Transforms/InstCombine/vec_extract_elt.ll
index 166066a201bf..3daf72ede509 100644
--- a/test/Transforms/InstCombine/vec_extract_elt.ll
+++ b/test/Transforms/InstCombine/vec_extract_elt.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -instcombine -S | not grep extractelement
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK-NOT: extractelement
define i32 @test(float %f) {
%tmp7 = insertelement <4 x float> undef, float %f, i32 0 ; <<4 x float>> [#uses=1]
diff --git a/test/Transforms/InstCombine/vec_insertelt.ll b/test/Transforms/InstCombine/vec_insertelt.ll
index e35fa5e551fb..3b949209c4d7 100644
--- a/test/Transforms/InstCombine/vec_insertelt.ll
+++ b/test/Transforms/InstCombine/vec_insertelt.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -instcombine -S | grep "ret <4 x i32> %A"
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: ret <4 x i32> %A
; PR1286
define <4 x i32> @test1(<4 x i32> %A) {
diff --git a/test/Transforms/InstCombine/vec_phi_extract.ll b/test/Transforms/InstCombine/vec_phi_extract.ll
index 2f10fc2c1ed2..73ec1f1bb04f 100644
--- a/test/Transforms/InstCombine/vec_phi_extract.ll
+++ b/test/Transforms/InstCombine/vec_phi_extract.ll
@@ -25,3 +25,28 @@ ret:
ret void
}
+define i1 @g(<3 x i32> %input_2) {
+; CHECK: extractelement
+entry:
+ br label %for.cond
+
+for.cond:
+; CHECK: phi i32
+ %input_2.addr.0 = phi <3 x i32> [ %input_2, %entry ], [ %div45, %for.body ]
+ %input_1.addr.1 = phi <3 x i32> [ undef, %entry ], [ %dec43, %for.body ]
+ br i1 undef, label %for.end, label %for.body
+
+; CHECK extractelement
+for.body:
+ %dec43 = add <3 x i32> %input_1.addr.1, <i32 -1, i32 -1, i32 -1>
+ %sub44 = sub <3 x i32> zeroinitializer, %dec43
+ %div45 = sdiv <3 x i32> %input_2.addr.0, %sub44
+ br label %for.cond
+
+for.end:
+ %0 = extractelement <3 x i32> %input_2.addr.0, i32 0
+ %.89 = select i1 false, i32 0, i32 %0
+ %tobool313 = icmp eq i32 %.89, 0
+ ret i1 %tobool313
+}
+
diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll
index 8f78c2e6bd50..3ee43dc63a6f 100644
--- a/test/Transforms/InstCombine/vec_shuffle.ll
+++ b/test/Transforms/InstCombine/vec_shuffle.ll
@@ -1,21 +1,21 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
define <4 x float> @test1(<4 x float> %v1) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: ret <4 x float> %v1
%v2 = shufflevector <4 x float> %v1, <4 x float> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
ret <4 x float> %v2
}
define <4 x float> @test2(<4 x float> %v1) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: ret <4 x float> %v1
%v2 = shufflevector <4 x float> %v1, <4 x float> %v1, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
ret <4 x float> %v2
}
define float @test3(<4 x float> %A, <4 x float> %B, float %f) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: ret float %f
%C = insertelement <4 x float> %A, float %f, i32 0
%D = shufflevector <4 x float> %C, <4 x float> %B, <4 x i32> <i32 5, i32 0, i32 2, i32 7>
@@ -24,7 +24,7 @@ define float @test3(<4 x float> %A, <4 x float> %B, float %f) {
}
define i32 @test4(<4 x i32> %X) {
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK-NEXT: extractelement
; CHECK-NEXT: ret
%tmp152.i53899.i = shufflevector <4 x i32> %X, <4 x i32> undef, <4 x i32> zeroinitializer
@@ -33,7 +33,7 @@ define i32 @test4(<4 x i32> %X) {
}
define i32 @test5(<4 x i32> %X) {
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK-NEXT: extractelement
; CHECK-NEXT: ret
%tmp152.i53899.i = shufflevector <4 x i32> %X, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 undef, i32 undef>
@@ -42,7 +42,7 @@ define i32 @test5(<4 x i32> %X) {
}
define float @test6(<4 x float> %X) {
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK-NEXT: extractelement
; CHECK-NEXT: ret
%X1 = bitcast <4 x float> %X to <4 x i32>
@@ -53,7 +53,7 @@ define float @test6(<4 x float> %X) {
}
define <4 x float> @test7(<4 x float> %tmp45.i) {
-; CHECK: @test7
+; CHECK-LABEL: @test7(
; CHECK-NEXT: ret <4 x float> %tmp45.i
%tmp1642.i = shufflevector <4 x float> %tmp45.i, <4 x float> undef, <4 x i32> < i32 0, i32 1, i32 6, i32 7 >
ret <4 x float> %tmp1642.i
@@ -61,7 +61,7 @@ define <4 x float> @test7(<4 x float> %tmp45.i) {
; This should turn into a single shuffle.
define <4 x float> @test8(<4 x float> %tmp, <4 x float> %tmp1) {
-; CHECK: @test8
+; CHECK-LABEL: @test8(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
%tmp4 = extractelement <4 x float> %tmp, i32 1
@@ -77,7 +77,7 @@ define <4 x float> @test8(<4 x float> %tmp, <4 x float> %tmp1) {
; Test fold of two shuffles where the first shuffle vectors inputs are a
; different length then the second.
define <4 x i8> @test9(<16 x i8> %tmp6) nounwind {
-; CHECK: @test9
+; CHECK-LABEL: @test9(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
%tmp7 = shufflevector <16 x i8> %tmp6, <16 x i8> undef, <4 x i32> < i32 13, i32 9, i32 4, i32 13 > ; <<4 x i8>> [#uses=1]
@@ -89,7 +89,7 @@ define <4 x i8> @test9(<16 x i8> %tmp6) nounwind {
; mask values of 2*N, where N is the mask length. These shuffles should not
; be folded (because [8,9,4,8] may not be a mask supported by the target).
define <4 x i8> @test9a(<16 x i8> %tmp6) nounwind {
-; CHECK: @test9a
+; CHECK-LABEL: @test9a(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
@@ -101,7 +101,7 @@ define <4 x i8> @test9a(<16 x i8> %tmp6) nounwind {
; Test fold of two shuffles where the first shuffle vectors inputs are a
; different length then the second.
define <4 x i8> @test9b(<4 x i8> %tmp6, <4 x i8> %tmp7) nounwind {
-; CHECK: @test9
+; CHECK-LABEL: @test9b(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
%tmp1 = shufflevector <4 x i8> %tmp6, <4 x i8> %tmp7, <8 x i32> <i32 0, i32 1, i32 4, i32 5, i32 4, i32 5, i32 2, i32 3> ; <<4 x i8>> [#uses=1]
@@ -111,7 +111,7 @@ define <4 x i8> @test9b(<4 x i8> %tmp6, <4 x i8> %tmp7) nounwind {
; Redundant vector splats should be removed. Radar 8597790.
define <4 x i32> @test10(<4 x i32> %tmp5) nounwind {
-; CHECK: @test10
+; CHECK-LABEL: @test10(
; CHECK-NEXT: shufflevector
; CHECK-NEXT: ret
%tmp6 = shufflevector <4 x i32> %tmp5, <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
@@ -122,7 +122,7 @@ define <4 x i32> @test10(<4 x i32> %tmp5) nounwind {
; Test fold of two shuffles where the two shufflevector inputs's op1 are
; the same
define <8 x i8> @test11(<16 x i8> %tmp6) nounwind {
-; CHECK: @test11
+; CHECK-LABEL: @test11(
; CHECK-NEXT: shufflevector <16 x i8> %tmp6, <16 x i8> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
; CHECK-NEXT: ret
%tmp1 = shufflevector <16 x i8> %tmp6, <16 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> ; <<4 x i8>> [#uses=1]
@@ -134,7 +134,7 @@ define <8 x i8> @test11(<16 x i8> %tmp6) nounwind {
; Test fold of two shuffles where the first shufflevector's inputs are
; the same as the second
define <8 x i8> @test12(<8 x i8> %tmp6, <8 x i8> %tmp2) nounwind {
-; CHECK: @test12
+; CHECK-LABEL: @test12(
; CHECK-NEXT: shufflevector <8 x i8> %tmp6, <8 x i8> %tmp2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 9, i32 8, i32 11, i32 12>
; CHECK-NEXT: ret
%tmp1 = shufflevector <8 x i8> %tmp6, <8 x i8> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 5, i32 4, i32 undef, i32 7> ; <<8 x i8>> [#uses=1]
@@ -145,7 +145,7 @@ define <8 x i8> @test12(<8 x i8> %tmp6, <8 x i8> %tmp2) nounwind {
; Test fold of two shuffles where the first shufflevector's inputs are
; the same as the second
define <8 x i8> @test12a(<8 x i8> %tmp6, <8 x i8> %tmp2) nounwind {
-; CHECK: @test12a
+; CHECK-LABEL: @test12a(
; CHECK-NEXT: shufflevector <8 x i8> %tmp2, <8 x i8> %tmp6, <8 x i32> <i32 0, i32 3, i32 1, i32 4, i32 8, i32 9, i32 10, i32 11>
; CHECK-NEXT: ret
%tmp1 = shufflevector <8 x i8> %tmp6, <8 x i8> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 5, i32 4, i32 undef, i32 7> ; <<8 x i8>> [#uses=1]
@@ -153,3 +153,78 @@ define <8 x i8> @test12a(<8 x i8> %tmp6, <8 x i8> %tmp2) nounwind {
ret <8 x i8> %tmp3
}
+define <2 x i8> @test13a(i8 %x1, i8 %x2) {
+; CHECK-LABEL: @test13a(
+; CHECK-NEXT: insertelement {{.*}} undef, i8 %x1, i32 1
+; CHECK-NEXT: insertelement {{.*}} i8 %x2, i32 0
+; CHECK-NEXT: add {{.*}} <i8 7, i8 5>
+; CHECK-NEXT: ret
+ %A = insertelement <2 x i8> undef, i8 %x1, i32 0
+ %B = insertelement <2 x i8> %A, i8 %x2, i32 1
+ %C = add <2 x i8> %B, <i8 5, i8 7>
+ %D = shufflevector <2 x i8> %C, <2 x i8> undef, <2 x i32> <i32 1, i32 0>
+ ret <2 x i8> %D
+}
+
+define <2 x i8> @test13b(i8 %x) {
+; CHECK-LABEL: @test13b(
+; CHECK-NEXT: insertelement <2 x i8> undef, i8 %x, i32 1
+; CHECK-NEXT: ret
+ %A = insertelement <2 x i8> undef, i8 %x, i32 0
+ %B = shufflevector <2 x i8> %A, <2 x i8> undef, <2 x i32> <i32 undef, i32 0>
+ ret <2 x i8> %B
+}
+
+define <2 x i8> @test13c(i8 %x1, i8 %x2) {
+; CHECK-LABEL: @test13c(
+; CHECK-NEXT: insertelement <2 x i8> {{.*}}, i32 0
+; CHECK-NEXT: insertelement <2 x i8> {{.*}}, i32 1
+; CHECK-NEXT: ret
+ %A = insertelement <4 x i8> undef, i8 %x1, i32 0
+ %B = insertelement <4 x i8> %A, i8 %x2, i32 2
+ %C = shufflevector <4 x i8> %B, <4 x i8> undef, <2 x i32> <i32 0, i32 2>
+ ret <2 x i8> %C
+}
+
+define void @test14(i16 %conv10) {
+ %tmp = alloca <4 x i16>, align 8
+ %vecinit6 = insertelement <4 x i16> undef, i16 23, i32 3
+ store <4 x i16> %vecinit6, <4 x i16>* undef
+ %tmp1 = load <4 x i16>* undef
+ %vecinit11 = insertelement <4 x i16> undef, i16 %conv10, i32 3
+ %div = udiv <4 x i16> %tmp1, %vecinit11
+ store <4 x i16> %div, <4 x i16>* %tmp
+ %tmp4 = load <4 x i16>* %tmp
+ %tmp5 = shufflevector <4 x i16> %tmp4, <4 x i16> undef, <2 x i32> <i32 2, i32 0>
+ %cmp = icmp ule <2 x i16> %tmp5, undef
+ %sext = sext <2 x i1> %cmp to <2 x i16>
+ ret void
+}
+
+; Check that sequences of insert/extract element are
+; collapsed into valid shuffle instruction with correct shuffle indexes.
+
+define <4 x float> @test15a(<4 x float> %LHS, <4 x float> %RHS) {
+; CHECK-LABEL: @test15a
+; CHECK-NEXT: shufflevector <4 x float> %LHS, <4 x float> %RHS, <4 x i32> <i32 4, i32 0, i32 6, i32 6>
+; CHECK-NEXT: ret <4 x float> %tmp4
+ %tmp1 = extractelement <4 x float> %LHS, i32 0
+ %tmp2 = insertelement <4 x float> %RHS, float %tmp1, i32 1
+ %tmp3 = extractelement <4 x float> %RHS, i32 2
+ %tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 3
+ ret <4 x float> %tmp4
+}
+
+define <4 x float> @test15b(<4 x float> %LHS, <4 x float> %RHS) {
+; CHECK-LABEL: @test15b
+; CHECK-NEXT: shufflevector <4 x float> %LHS, <4 x float> %RHS, <4 x i32> <i32 4, i32 3, i32 6, i32 6>
+; CHECK-NEXT: ret <4 x float> %tmp5
+ %tmp0 = extractelement <4 x float> %LHS, i32 3
+ %tmp1 = insertelement <4 x float> %RHS, float %tmp0, i32 0
+ %tmp2 = extractelement <4 x float> %tmp1, i32 0
+ %tmp3 = insertelement <4 x float> %RHS, float %tmp2, i32 1
+ %tmp4 = extractelement <4 x float> %RHS, i32 2
+ %tmp5 = insertelement <4 x float> %tmp3, float %tmp4, i32 3
+ ret <4 x float> %tmp5
+}
+
diff --git a/test/Transforms/InstCombine/vector-casts.ll b/test/Transforms/InstCombine/vector-casts.ll
index 2f2990b7b055..ca97b3407da6 100644
--- a/test/Transforms/InstCombine/vector-casts.ll
+++ b/test/Transforms/InstCombine/vector-casts.ll
@@ -5,7 +5,7 @@ define <2 x i1> @test1(<2 x i64> %a) {
%t = trunc <2 x i64> %a to <2 x i1>
ret <2 x i1> %t
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: and <2 x i64> %a, <i64 1, i64 1>
; CHECK: icmp ne <2 x i64> %1, zeroinitializer
}
@@ -16,7 +16,7 @@ define <2 x i64> @test2(<2 x i64> %a) {
%t = ashr <2 x i64> %b, <i64 1, i64 1>
ret <2 x i64> %t
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK: and <2 x i64> %a, <i64 65535, i64 65535>
; CHECK: lshr <2 x i64> %b, <i64 1, i64 1>
}
@@ -33,7 +33,7 @@ entry:
%conv = bitcast <4 x i32> %and to <2 x i64>
ret <2 x i64> %conv
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK: fcmp ord <4 x float> %a, %b
}
@@ -46,7 +46,7 @@ entry:
%or = or <4 x i32> %sext, %sext5
%conv = bitcast <4 x i32> %or to <2 x i64>
ret <2 x i64> %conv
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: fcmp uno <4 x float> %a, %b
}
@@ -62,7 +62,7 @@ entry:
%conv = bitcast <4 x i32> %and to <2 x i64>
ret <2 x i64> %conv
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: sext <4 x i1> %cmp to <4 x i32>
; The sext-and pair is canonicalized to a select.
; CHECK: select <4 x i1> %cmp4, <4 x i32> %sext, <4 x i32> zeroinitializer
@@ -126,7 +126,7 @@ define <2 x double> @fc(<2 x double> %t) {
; PR9228
; This was a crasher, so no CHECK statements.
define <4 x float> @f(i32 %a) nounwind alwaysinline {
-; CHECK: @f
+; CHECK-LABEL: @f(
entry:
%dim = insertelement <4 x i32> undef, i32 %a, i32 0
%dim30 = insertelement <4 x i32> %dim, i32 %a, i32 1
diff --git a/test/Transforms/InstCombine/vector-mul.ll b/test/Transforms/InstCombine/vector-mul.ll
new file mode 100644
index 000000000000..284d407ce33f
--- /dev/null
+++ b/test/Transforms/InstCombine/vector-mul.ll
@@ -0,0 +1,408 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; Check that instcombine rewrites multiply by a vector
+; of known constant power-of-2 elements with vector shift.
+
+define <4 x i8> @Zero_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 0, i8 0, i8 0, i8 0>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @Zero_i8(
+; CHECK: ret <4 x i8> zeroinitializer
+
+define <4 x i8> @Identity_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 1, i8 1, i8 1, i8 1>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @Identity_i8(
+; CHECK: ret <4 x i8> %InVec
+
+define <4 x i8> @AddToSelf_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 2, i8 2, i8 2, i8 2>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @AddToSelf_i8(
+; CHECK: shl <4 x i8> %InVec, <i8 1, i8 1, i8 1, i8 1>
+; CHECK: ret
+
+define <4 x i8> @SplatPow2Test1_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 4, i8 4, i8 4, i8 4>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test1_i8(
+; CHECK: shl <4 x i8> %InVec, <i8 2, i8 2, i8 2, i8 2>
+; CHECK: ret
+
+define <4 x i8> @SplatPow2Test2_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 8, i8 8, i8 8, i8 8>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test2_i8(
+; CHECK: shl <4 x i8> %InVec, <i8 3, i8 3, i8 3, i8 3>
+; CHECK: ret
+
+define <4 x i8> @MulTest1_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 1, i8 2, i8 4, i8 8>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @MulTest1_i8(
+; CHECK: shl <4 x i8> %InVec, <i8 0, i8 1, i8 2, i8 3>
+; CHECK: ret
+
+define <4 x i8> @MulTest2_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 3, i8 3, i8 3, i8 3>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @MulTest2_i8(
+; CHECK: mul <4 x i8> %InVec, <i8 3, i8 3, i8 3, i8 3>
+; CHECK: ret
+
+define <4 x i8> @MulTest3_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 4, i8 4, i8 2, i8 2>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @MulTest3_i8(
+; CHECK: shl <4 x i8> %InVec, <i8 2, i8 2, i8 1, i8 1>
+; CHECK: ret
+
+
+define <4 x i8> @MulTest4_i8(<4 x i8> %InVec) {
+entry:
+ %mul = mul <4 x i8> %InVec, <i8 4, i8 4, i8 0, i8 1>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @MulTest4_i8(
+; CHECK: mul <4 x i8> %InVec, <i8 4, i8 4, i8 0, i8 1>
+; CHECK: ret
+
+define <4 x i16> @Zero_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 0, i16 0, i16 0, i16 0>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @Zero_i16(
+; CHECK: ret <4 x i16> zeroinitializer
+
+define <4 x i16> @Identity_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 1, i16 1, i16 1, i16 1>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @Identity_i16(
+; CHECK: ret <4 x i16> %InVec
+
+define <4 x i16> @AddToSelf_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 2, i16 2, i16 2, i16 2>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @AddToSelf_i16(
+; CHECK: shl <4 x i16> %InVec, <i16 1, i16 1, i16 1, i16 1>
+; CHECK: ret
+
+define <4 x i16> @SplatPow2Test1_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 4, i16 4, i16 4, i16 4>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test1_i16(
+; CHECK: shl <4 x i16> %InVec, <i16 2, i16 2, i16 2, i16 2>
+; CHECK: ret
+
+define <4 x i16> @SplatPow2Test2_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 8, i16 8, i16 8, i16 8>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test2_i16(
+; CHECK: shl <4 x i16> %InVec, <i16 3, i16 3, i16 3, i16 3>
+; CHECK: ret
+
+define <4 x i16> @MulTest1_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 1, i16 2, i16 4, i16 8>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @MulTest1_i16(
+; CHECK: shl <4 x i16> %InVec, <i16 0, i16 1, i16 2, i16 3>
+; CHECK: ret
+
+define <4 x i16> @MulTest2_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 3, i16 3, i16 3, i16 3>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @MulTest2_i16(
+; CHECK: mul <4 x i16> %InVec, <i16 3, i16 3, i16 3, i16 3>
+; CHECK: ret
+
+define <4 x i16> @MulTest3_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 4, i16 4, i16 2, i16 2>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @MulTest3_i16(
+; CHECK: shl <4 x i16> %InVec, <i16 2, i16 2, i16 1, i16 1>
+; CHECK: ret
+
+define <4 x i16> @MulTest4_i16(<4 x i16> %InVec) {
+entry:
+ %mul = mul <4 x i16> %InVec, <i16 4, i16 4, i16 0, i16 2>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @MulTest4_i16(
+; CHECK: mul <4 x i16> %InVec, <i16 4, i16 4, i16 0, i16 2>
+; CHECK: ret
+
+define <4 x i32> @Zero_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 0, i32 0, i32 0, i32 0>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @Zero_i32(
+; CHECK: ret <4 x i32> zeroinitializer
+
+define <4 x i32> @Identity_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 1, i32 1, i32 1, i32 1>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @Identity_i32(
+; CHECK: ret <4 x i32> %InVec
+
+define <4 x i32> @AddToSelf_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 2, i32 2, i32 2, i32 2>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @AddToSelf_i32(
+; CHECK: shl <4 x i32> %InVec, <i32 1, i32 1, i32 1, i32 1>
+; CHECK: ret
+
+
+define <4 x i32> @SplatPow2Test1_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 4, i32 4, i32 4, i32 4>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test1_i32(
+; CHECK: shl <4 x i32> %InVec, <i32 2, i32 2, i32 2, i32 2>
+; CHECK: ret
+
+define <4 x i32> @SplatPow2Test2_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 8, i32 8, i32 8, i32 8>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test2_i32(
+; CHECK: shl <4 x i32> %InVec, <i32 3, i32 3, i32 3, i32 3>
+; CHECK: ret
+
+define <4 x i32> @MulTest1_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 1, i32 2, i32 4, i32 8>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @MulTest1_i32(
+; CHECK: shl <4 x i32> %InVec, <i32 0, i32 1, i32 2, i32 3>
+; CHECK: ret
+
+define <4 x i32> @MulTest2_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 3, i32 3, i32 3, i32 3>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @MulTest2_i32(
+; CHECK: mul <4 x i32> %InVec, <i32 3, i32 3, i32 3, i32 3>
+; CHECK: ret
+
+define <4 x i32> @MulTest3_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 4, i32 4, i32 2, i32 2>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @MulTest3_i32(
+; CHECK: shl <4 x i32> %InVec, <i32 2, i32 2, i32 1, i32 1>
+; CHECK: ret
+
+
+define <4 x i32> @MulTest4_i32(<4 x i32> %InVec) {
+entry:
+ %mul = mul <4 x i32> %InVec, <i32 4, i32 4, i32 0, i32 1>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @MulTest4_i32(
+; CHECK: mul <4 x i32> %InVec, <i32 4, i32 4, i32 0, i32 1>
+; CHECK: ret
+
+define <4 x i64> @Zero_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 0, i64 0, i64 0, i64 0>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @Zero_i64(
+; CHECK: ret <4 x i64> zeroinitializer
+
+define <4 x i64> @Identity_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 1, i64 1, i64 1, i64 1>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @Identity_i64(
+; CHECK: ret <4 x i64> %InVec
+
+define <4 x i64> @AddToSelf_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 2, i64 2, i64 2, i64 2>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @AddToSelf_i64(
+; CHECK: shl <4 x i64> %InVec, <i64 1, i64 1, i64 1, i64 1>
+; CHECK: ret
+
+define <4 x i64> @SplatPow2Test1_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 4, i64 4, i64 4, i64 4>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test1_i64(
+; CHECK: shl <4 x i64> %InVec, <i64 2, i64 2, i64 2, i64 2>
+; CHECK: ret
+
+define <4 x i64> @SplatPow2Test2_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 8, i64 8, i64 8, i64 8>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @SplatPow2Test2_i64(
+; CHECK: shl <4 x i64> %InVec, <i64 3, i64 3, i64 3, i64 3>
+; CHECK: ret
+
+define <4 x i64> @MulTest1_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 1, i64 2, i64 4, i64 8>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @MulTest1_i64(
+; CHECK: shl <4 x i64> %InVec, <i64 0, i64 1, i64 2, i64 3>
+; CHECK: ret
+
+define <4 x i64> @MulTest2_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 3, i64 3, i64 3, i64 3>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @MulTest2_i64(
+; CHECK: mul <4 x i64> %InVec, <i64 3, i64 3, i64 3, i64 3>
+; CHECK: ret
+
+define <4 x i64> @MulTest3_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 4, i64 4, i64 2, i64 2>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @MulTest3_i64(
+; CHECK: shl <4 x i64> %InVec, <i64 2, i64 2, i64 1, i64 1>
+; CHECK: ret
+
+define <4 x i64> @MulTest4_i64(<4 x i64> %InVec) {
+entry:
+ %mul = mul <4 x i64> %InVec, <i64 4, i64 4, i64 0, i64 1>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @MulTest4_i64(
+; CHECK: mul <4 x i64> %InVec, <i64 4, i64 4, i64 0, i64 1>
+; CHECK: ret
+
+; Test also that the following rewriting rule works with vectors
+; of integers as well:
+; ((X << C1)*C2) == (X * (C2 << C1))
+
+define <4 x i8> @ShiftMulTest1(<4 x i8> %InVec) {
+entry:
+ %shl = shl <4 x i8> %InVec, <i8 2, i8 2, i8 2, i8 2>
+ %mul = mul <4 x i8> %shl, <i8 3, i8 3, i8 3, i8 3>
+ ret <4 x i8> %mul
+}
+
+; CHECK-LABEL: @ShiftMulTest1(
+; CHECK: mul <4 x i8> %InVec, <i8 12, i8 12, i8 12, i8 12>
+; CHECK: ret
+
+define <4 x i16> @ShiftMulTest2(<4 x i16> %InVec) {
+entry:
+ %shl = shl <4 x i16> %InVec, <i16 2, i16 2, i16 2, i16 2>
+ %mul = mul <4 x i16> %shl, <i16 3, i16 3, i16 3, i16 3>
+ ret <4 x i16> %mul
+}
+
+; CHECK-LABEL: @ShiftMulTest2(
+; CHECK: mul <4 x i16> %InVec, <i16 12, i16 12, i16 12, i16 12>
+; CHECK: ret
+
+define <4 x i32> @ShiftMulTest3(<4 x i32> %InVec) {
+entry:
+ %shl = shl <4 x i32> %InVec, <i32 2, i32 2, i32 2, i32 2>
+ %mul = mul <4 x i32> %shl, <i32 3, i32 3, i32 3, i32 3>
+ ret <4 x i32> %mul
+}
+
+; CHECK-LABEL: @ShiftMulTest3(
+; CHECK: mul <4 x i32> %InVec, <i32 12, i32 12, i32 12, i32 12>
+; CHECK: ret
+
+define <4 x i64> @ShiftMulTest4(<4 x i64> %InVec) {
+entry:
+ %shl = shl <4 x i64> %InVec, <i64 2, i64 2, i64 2, i64 2>
+ %mul = mul <4 x i64> %shl, <i64 3, i64 3, i64 3, i64 3>
+ ret <4 x i64> %mul
+}
+
+; CHECK-LABEL: @ShiftMulTest4(
+; CHECK: mul <4 x i64> %InVec, <i64 12, i64 12, i64 12, i64 12>
+; CHECK: ret
+
diff --git a/test/Transforms/InstCombine/vector_gep2.ll b/test/Transforms/InstCombine/vector_gep2.ll
index 20165b110016..42057d60b8c8 100644
--- a/test/Transforms/InstCombine/vector_gep2.ll
+++ b/test/Transforms/InstCombine/vector_gep2.ll
@@ -4,7 +4,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
target triple = "x86_64-unknown-linux-gnu"
define <2 x i8*> @testa(<2 x i8*> %a) {
-; CHECK: @testa
+; CHECK-LABEL: @testa(
%g = getelementptr <2 x i8*> %a, <2 x i32> <i32 0, i32 1>
; CHECK: getelementptr <2 x i8*> %a, <2 x i64> <i64 0, i64 1>
ret <2 x i8*> %g
diff --git a/test/Transforms/InstCombine/weak-symbols.ll b/test/Transforms/InstCombine/weak-symbols.ll
index 0039b5962f74..ec946ead8602 100644
--- a/test/Transforms/InstCombine/weak-symbols.ll
+++ b/test/Transforms/InstCombine/weak-symbols.ll
@@ -8,7 +8,7 @@
@.str = private constant [2 x i8] c"y\00"
define i32 @foo() nounwind {
-; CHECK: define i32 @foo
+; CHECK-LABEL: define i32 @foo(
; CHECK: call i32 @strcmp
; CHECK: ret i32 %temp1
@@ -20,7 +20,7 @@ entry:
}
define i32 @bar() nounwind {
-; CHECK: define i32 @bar
+; CHECK-LABEL: define i32 @bar(
; CHECK: ret i32 0
entry:
diff --git a/test/Transforms/InstCombine/win-math.ll b/test/Transforms/InstCombine/win-math.ll
new file mode 100644
index 000000000000..e6e79e2b84a0
--- /dev/null
+++ b/test/Transforms/InstCombine/win-math.ll
@@ -0,0 +1,295 @@
+; RUN: opt -O2 -S -mtriple=i386-pc-win32 < %s | FileCheck %s -check-prefix=WIN32
+; RUN: opt -O2 -S -mtriple=x86_64-pc-win32 < %s | FileCheck %s -check-prefix=WIN64
+; RUN: opt -O2 -S -mtriple=i386-pc-mingw32 < %s | FileCheck %s -check-prefix=MINGW32
+; RUN: opt -O2 -S -mtriple=x86_64-pc-mingw32 < %s | FileCheck %s -check-prefix=MINGW64
+
+; x86 win32 msvcrt does not provide entry points for single-precision libm.
+; x86-64 win32 msvcrt does (except for fabsf)
+; msvcrt does not provide C99 math, but mingw32 does.
+
+declare double @acos(double %x)
+define float @float_acos(float %x) nounwind readnone {
+; WIN32-LABEL: @float_acos(
+; WIN32-NOT: float @acosf
+; WIN32: double @acos
+ %1 = fpext float %x to double
+ %2 = call double @acos(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @asin(double %x)
+define float @float_asin(float %x) nounwind readnone {
+; WIN32-LABEL: @float_asin(
+; WIN32-NOT: float @asinf
+; WIN32: double @asin
+ %1 = fpext float %x to double
+ %2 = call double @asin(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @atan(double %x)
+define float @float_atan(float %x) nounwind readnone {
+; WIN32-LABEL: @float_atan(
+; WIN32-NOT: float @atanf
+; WIN32: double @atan
+ %1 = fpext float %x to double
+ %2 = call double @atan(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @atan2(double %x, double %y)
+define float @float_atan2(float %x, float %y) nounwind readnone {
+; WIN32-LABEL: @float_atan2(
+; WIN32-NOT: float @atan2f
+; WIN32: double @atan2
+ %1 = fpext float %x to double
+ %2 = fpext float %y to double
+ %3 = call double @atan2(double %1, double %2)
+ %4 = fptrunc double %3 to float
+ ret float %4
+}
+
+declare double @ceil(double %x)
+define float @float_ceil(float %x) nounwind readnone {
+; WIN32-LABEL: @float_ceil(
+; WIN32-NOT: float @ceilf
+; WIN32: double @ceil
+; WIN64-LABEL: @float_ceil(
+; WIN64: float @ceilf
+; WIN64-NOT: double @ceil
+; MINGW32-LABEL: @float_ceil(
+; MINGW32: float @ceilf
+; MINGW32-NOT: double @ceil
+; MINGW64-LABEL: @float_ceil(
+; MINGW64: float @ceilf
+; MINGW64-NOT: double @ceil
+ %1 = fpext float %x to double
+ %2 = call double @ceil(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @_copysign(double %x)
+define float @float_copysign(float %x) nounwind readnone {
+; WIN32-LABEL: @float_copysign(
+; WIN32-NOT: float @copysignf
+; WIN32-NOT: float @_copysignf
+; WIN32: double @_copysign
+ %1 = fpext float %x to double
+ %2 = call double @_copysign(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @cos(double %x)
+define float @float_cos(float %x) nounwind readnone {
+; WIN32-LABEL: @float_cos(
+; WIN32-NOT: float @cosf
+; WIN32: double @cos
+ %1 = fpext float %x to double
+ %2 = call double @cos(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @cosh(double %x)
+define float @float_cosh(float %x) nounwind readnone {
+; WIN32-LABEL: @float_cosh(
+; WIN32-NOT: float @coshf
+; WIN32: double @cosh
+ %1 = fpext float %x to double
+ %2 = call double @cosh(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @exp(double %x, double %y)
+define float @float_exp(float %x, float %y) nounwind readnone {
+; WIN32-LABEL: @float_exp(
+; WIN32-NOT: float @expf
+; WIN32: double @exp
+ %1 = fpext float %x to double
+ %2 = fpext float %y to double
+ %3 = call double @exp(double %1, double %2)
+ %4 = fptrunc double %3 to float
+ ret float %4
+}
+
+declare double @fabs(double %x, double %y)
+define float @float_fabs(float %x, float %y) nounwind readnone {
+; WIN32-LABEL: @float_fabs(
+; WIN32-NOT: float @fabsf
+; WIN32: double @fabs
+; WIN64-LABEL: @float_fabs(
+; WIN64-NOT: float @fabsf
+; WIN64: double @fabs
+ %1 = fpext float %x to double
+ %2 = fpext float %y to double
+ %3 = call double @fabs(double %1, double %2)
+ %4 = fptrunc double %3 to float
+ ret float %4
+}
+
+declare double @floor(double %x)
+define float @float_floor(float %x) nounwind readnone {
+; WIN32-LABEL: @float_floor(
+; WIN32-NOT: float @floorf
+; WIN32: double @floor
+; WIN64-LABEL: @float_floor(
+; WIN64: float @floorf
+; WIN64-NOT: double @floor
+; MINGW32-LABEL: @float_floor(
+; MINGW32: float @floorf
+; MINGW32-NOT: double @floor
+; MINGW64-LABEL: @float_floor(
+; MINGW64: float @floorf
+; MINGW64-NOT: double @floor
+ %1 = fpext float %x to double
+ %2 = call double @floor(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @fmod(double %x, double %y)
+define float @float_fmod(float %x, float %y) nounwind readnone {
+; WIN32-LABEL: @float_fmod(
+; WIN32-NOT: float @fmodf
+; WIN32: double @fmod
+ %1 = fpext float %x to double
+ %2 = fpext float %y to double
+ %3 = call double @fmod(double %1, double %2)
+ %4 = fptrunc double %3 to float
+ ret float %4
+}
+
+declare double @log(double %x)
+define float @float_log(float %x) nounwind readnone {
+; WIN32-LABEL: @float_log(
+; WIN32-NOT: float @logf
+; WIN32: double @log
+ %1 = fpext float %x to double
+ %2 = call double @log(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @pow(double %x, double %y)
+define float @float_pow(float %x, float %y) nounwind readnone {
+; WIN32-LABEL: @float_pow(
+; WIN32-NOT: float @powf
+; WIN32: double @pow
+ %1 = fpext float %x to double
+ %2 = fpext float %y to double
+ %3 = call double @pow(double %1, double %2)
+ %4 = fptrunc double %3 to float
+ ret float %4
+}
+
+declare double @sin(double %x)
+define float @float_sin(float %x) nounwind readnone {
+; WIN32-LABEL: @float_sin(
+; WIN32-NOT: float @sinf
+; WIN32: double @sin
+ %1 = fpext float %x to double
+ %2 = call double @sin(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @sinh(double %x)
+define float @float_sinh(float %x) nounwind readnone {
+; WIN32-LABEL: @float_sinh(
+; WIN32-NOT: float @sinhf
+; WIN32: double @sinh
+ %1 = fpext float %x to double
+ %2 = call double @sinh(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @sqrt(double %x)
+define float @float_sqrt(float %x) nounwind readnone {
+; WIN32-LABEL: @float_sqrt(
+; WIN32-NOT: float @sqrtf
+; WIN32: double @sqrt
+; WIN64-LABEL: @float_sqrt(
+; WIN64: float @sqrtf
+; WIN64-NOT: double @sqrt
+; MINGW32-LABEL: @float_sqrt(
+; MINGW32: float @sqrtf
+; MINGW32-NOT: double @sqrt
+; MINGW64-LABEL: @float_sqrt(
+; MINGW64: float @sqrtf
+; MINGW64-NOT: double @sqrt
+ %1 = fpext float %x to double
+ %2 = call double @sqrt(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @tan(double %x)
+define float @float_tan(float %x) nounwind readnone {
+; WIN32-LABEL: @float_tan(
+; WIN32-NOT: float @tanf
+; WIN32: double @tan
+ %1 = fpext float %x to double
+ %2 = call double @tan(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare double @tanh(double %x)
+define float @float_tanh(float %x) nounwind readnone {
+; WIN32-LABEL: @float_tanh(
+; WIN32-NOT: float @tanhf
+; WIN32: double @tanh
+ %1 = fpext float %x to double
+ %2 = call double @tanh(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+; win32 does not have round; mingw32 does
+declare double @round(double %x)
+define float @float_round(float %x) nounwind readnone {
+; WIN32-LABEL: @float_round(
+; WIN32-NOT: float @roundf
+; WIN32: double @round
+; WIN64-LABEL: @float_round(
+; WIN64-NOT: float @roundf
+; WIN64: double @round
+; MINGW32-LABEL: @float_round(
+; MINGW32: float @roundf
+; MINGW32-NOT: double @round
+; MINGW64-LABEL: @float_round(
+; MINGW64: float @roundf
+; MINGW64-NOT: double @round
+ %1 = fpext float %x to double
+ %2 = call double @round(double %1)
+ %3 = fptrunc double %2 to float
+ ret float %3
+}
+
+declare float @powf(float, float)
+; win32 lacks sqrtf&fabsf, win64 lacks fabsf
+define float @float_powsqrt(float %x) nounwind readnone {
+; WIN32-LABEL: @float_powsqrt(
+; WIN32-NOT: float @sqrtf
+; WIN32: float @powf
+; WIN64-LABEL: @float_powsqrt(
+; WIN64-NOT: float @sqrtf
+; WIN64: float @powf
+; MINGW32-LABEL: @float_powsqrt(
+; MINGW32: float @sqrtf
+; MINGW32: float @fabsf
+; MINGW32-NOT: float @powf
+; MINGW64-LABEL: @float_powsqrt(
+; MINGW64: float @sqrtf
+; MINGW64: float @fabsf
+; MINGW64-NOT: float @powf
+ %1 = call float @powf(float %x, float 0.5)
+ ret float %1
+}
diff --git a/test/Transforms/InstCombine/xor2.ll b/test/Transforms/InstCombine/xor2.ll
index be06d7999d84..d153e035c899 100644
--- a/test/Transforms/InstCombine/xor2.ll
+++ b/test/Transforms/InstCombine/xor2.ll
@@ -4,7 +4,7 @@
; PR1253
define i1 @test0(i32 %A) {
-; CHECK: @test0
+; CHECK-LABEL: @test0(
; CHECK: %C = icmp slt i32 %A, 0
%B = xor i32 %A, -2147483648
%C = icmp sgt i32 %B, -1
@@ -12,7 +12,7 @@ define i1 @test0(i32 %A) {
}
define i1 @test1(i32 %A) {
-; CHECK: @test1
+; CHECK-LABEL: @test1(
; CHECK: %C = icmp slt i32 %A, 0
%B = xor i32 %A, 12345
%C = icmp slt i32 %B, 0
@@ -21,7 +21,7 @@ define i1 @test1(i32 %A) {
; PR1014
define i32 @test2(i32 %tmp1) {
-; CHECK: @test2
+; CHECK-LABEL: @test2(
; CHECK-NEXT: and i32 %tmp1, 32
; CHECK-NEXT: or i32 %ovm, 8
; CHECK-NEXT: ret i32
@@ -32,7 +32,7 @@ define i32 @test2(i32 %tmp1) {
}
define i32 @test3(i32 %tmp1) {
-; CHECK: @test3
+; CHECK-LABEL: @test3(
; CHECK-NEXT: and i32 %tmp1, 32
; CHECK-NEXT: or i32 %ovm, 8
; CHECK-NEXT: ret i32
@@ -47,7 +47,7 @@ define i32 @test4(i32 %A, i32 %B) {
%2 = ashr i32 %1, %B
%3 = xor i32 %2, -1
ret i32 %3
-; CHECK: @test4
+; CHECK-LABEL: @test4(
; CHECK: %1 = ashr i32 %A, %B
; CHECK: ret i32 %1
}
@@ -62,7 +62,7 @@ test5:
%xor1 = xor i32 %shr, 1
%add = add i32 %xor1, %xor
ret i32 %add
-; CHECK: @test5
+; CHECK-LABEL: @test5(
; CHECK: lshr i32 %val1, 8
; CHECK: ret
}
@@ -78,7 +78,7 @@ define i32 @test6(i32 %x) {
%shr = lshr i32 %xor, 16
%add = add i32 %shr, %xor
ret i32 %add
-; CHECK: @test6
+; CHECK-LABEL: @test6(
; CHECK: lshr i32 %x, 16
; CHECK: ret
}
diff --git a/test/Transforms/InstCombine/zext-bool-add-sub.ll b/test/Transforms/InstCombine/zext-bool-add-sub.ll
index b5310575502b..d7f338b659b4 100644
--- a/test/Transforms/InstCombine/zext-bool-add-sub.ll
+++ b/test/Transforms/InstCombine/zext-bool-add-sub.ll
@@ -3,7 +3,7 @@
define i32 @a(i1 zeroext %x, i1 zeroext %y) {
entry:
-; CHECK: @a
+; CHECK-LABEL: @a(
; CHECK: [[TMP1:%.*]] = sext i1 %y to i32
; CHECK: [[TMP2:%.*]] = select i1 %x, i32 2, i32 1
; CHECK-NEXT: add i32 [[TMP2]], [[TMP1]]