diff options
Diffstat (limited to 'test/Transforms/InstCombine')
40 files changed, 1007 insertions, 83 deletions
diff --git a/test/Transforms/InstCombine/2008-05-08-StrLenSink.ll b/test/Transforms/InstCombine/2008-05-08-StrLenSink.ll index 1da28562aa..d266164fd8 100644 --- a/test/Transforms/InstCombine/2008-05-08-StrLenSink.ll +++ b/test/Transforms/InstCombine/2008-05-08-StrLenSink.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -instcombine %s | FileCheck %s +; RUN: opt -S -instcombine < %s | FileCheck %s ; PR2297 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-darwin8" diff --git a/test/Transforms/InstCombine/2010-03-03-ExtElim.ll b/test/Transforms/InstCombine/2010-03-03-ExtElim.ll index 2df12d670a..bb3159e1e6 100644 --- a/test/Transforms/InstCombine/2010-03-03-ExtElim.ll +++ b/test/Transforms/InstCombine/2010-03-03-ExtElim.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine -S %s | FileCheck %s +; 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" diff --git a/test/Transforms/InstCombine/2010-05-30-memcpy-Struct.ll b/test/Transforms/InstCombine/2010-05-30-memcpy-Struct.ll index b75fa5ad40..09a96749f2 100644 --- a/test/Transforms/InstCombine/2010-05-30-memcpy-Struct.ll +++ b/test/Transforms/InstCombine/2010-05-30-memcpy-Struct.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine %s -S -o - | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s ; PR7265 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" diff --git a/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll b/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll index 0907c490bb..2dedd44e2b 100644 --- a/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll +++ b/test/Transforms/InstCombine/2012-04-23-Neon-Intrinsics.ll @@ -50,7 +50,7 @@ entry: %b = add <4 x i32> zeroinitializer, %a ret <4 x i32> %b ; CHECK: entry: -; CHECK-NEXT: %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 2, i16 2, i16 2, i16 2>, <4 x i16> %x) nounwind +; CHECK-NEXT: %a = tail call <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16> <i16 2, i16 2, i16 2, i16 2>, <4 x i16> %x) [[NUW:#[0-9]+]] ; CHECK-NEXT: ret <4 x i32> %a } @@ -66,3 +66,7 @@ entry: declare <4 x i32> @llvm.arm.neon.vmulls.v4i32(<4 x i16>, <4 x i16>) nounwind readnone declare <4 x i32> @llvm.arm.neon.vmullu.v4i32(<4 x i16>, <4 x i16>) nounwind readnone + +; CHECK: attributes #0 = { nounwind readnone ssp } +; CHECK: attributes #1 = { nounwind readnone } +; CHECK: attributes [[NUW]] = { nounwind } diff --git a/test/Transforms/InstCombine/2012-12-14-simp-vgep.ll b/test/Transforms/InstCombine/2012-12-14-simp-vgep.ll new file mode 100644 index 0000000000..fc29b095e5 --- /dev/null +++ b/test/Transforms/InstCombine/2012-12-14-simp-vgep.ll @@ -0,0 +1,10 @@ +; RUN: opt < %s -instcombine -S + +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" + +define <4 x i32> @foo(<4 x i32*>* %in) { + %t17 = load <4 x i32*>* %in, align 8 + %t18 = icmp eq <4 x i32*> %t17, zeroinitializer + %t19 = zext <4 x i1> %t18 to <4 x i32> + ret <4 x i32> %t19 +} 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 new file mode 100644 index 0000000000..b20c3a07c0 --- /dev/null +++ b/test/Transforms/InstCombine/2013-03-05-Combine-BitcastTy-Into-Alloca.ll @@ -0,0 +1,45 @@ +; 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.9.0" + +%struct._my_struct = type <{ [12 x i8], [4 x i8] }> + +@initval = common global %struct._my_struct zeroinitializer, align 1 + +; InstCombine will try to change the %struct._my_struct alloca into an +; 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-NEXT: entry: +; CHECK-NEXT: %retval = alloca %struct._my_struct, align 8 +; CHECK-NOT: bitcast i96* %retval to %struct._my_struct* +entry: + %retval = alloca %struct._my_struct, align 8 + %k.sroa.0.0.copyload = load i96* bitcast (%struct._my_struct* @initval to i96*), align 1 + %k.sroa.1.12.copyload = load i32* bitcast ([4 x i8]* getelementptr inbounds (%struct._my_struct* @initval, i64 0, i32 1) to i32*), align 1 + %0 = zext i32 %x to i96 + %bf.value = shl nuw nsw i96 %0, 6 + %bf.clear = and i96 %k.sroa.0.0.copyload, -288230376151711744 + %1 = zext i32 %y to i96 + %bf.value2 = shl nuw nsw i96 %1, 32 + %bf.shl3 = and i96 %bf.value2, 288230371856744448 + %bf.value.masked = and i96 %bf.value, 4294967232 + %2 = zext i32 %z to i96 + %bf.value8 = and i96 %2, 63 + %bf.clear4 = or i96 %bf.shl3, %bf.value.masked + %bf.set5 = or i96 %bf.clear4, %bf.value8 + %bf.set10 = or i96 %bf.set5, %bf.clear + %retval.0.cast7 = bitcast %struct._my_struct* %retval to i96* + store i96 %bf.set10, i96* %retval.0.cast7, align 8 + %retval.12.idx8 = getelementptr inbounds %struct._my_struct* %retval, i64 0, i32 1 + %retval.12.cast9 = bitcast [4 x i8]* %retval.12.idx8 to i32* + store i32 %k.sroa.1.12.copyload, i32* %retval.12.cast9, align 4 + %trunc = trunc i96 %bf.set10 to i64 + %.fca.0.insert = insertvalue { i64, i64 } undef, i64 %trunc, 0 + %retval.8.idx12 = getelementptr inbounds %struct._my_struct* %retval, i64 0, i32 0, i64 8 + %retval.8.cast13 = bitcast i8* %retval.8.idx12 to i64* + %retval.8.load14 = load i64* %retval.8.cast13, align 8 + %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %retval.8.load14, 1 + ret { i64, i64 } %.fca.1.insert +} diff --git a/test/Transforms/InstCombine/bitcast-vector-fold.ll b/test/Transforms/InstCombine/bitcast-vector-fold.ll index 8feec22917..8fd7f35b7b 100644 --- a/test/Transforms/InstCombine/bitcast-vector-fold.ll +++ b/test/Transforms/InstCombine/bitcast-vector-fold.ll @@ -31,3 +31,8 @@ define <4 x i32> @test6() { %tmp3 = bitcast <2 x double> <double 0.5, double 1.0> to <4 x i32> ret <4 x i32> %tmp3 } + +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 8f6ae7d835..1e6113256b 100644 --- a/test/Transforms/InstCombine/bitcast.ll +++ b/test/Transforms/InstCombine/bitcast.ll @@ -11,7 +11,7 @@ define i32 @test1(i64 %a) { %t3 = xor <2 x i32> %t1, %t2 %t4 = extractelement <2 x i32> %t3, i32 0 ret i32 %t4 - + ; CHECK: @test1 ; CHECK: ret i32 0 } @@ -30,7 +30,7 @@ define float @test2(<2 x float> %A, <2 x i32> %B) { %add = fadd float %tmp24, %tmp4 ret float %add - + ; CHECK: @test2 ; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 0 ; CHECK-NEXT: bitcast <2 x i32> %B to <2 x float> @@ -55,7 +55,7 @@ define float @test3(<2 x float> %A, <2 x i64> %B) { %add = fadd float %tmp24, %tmp4 ret float %add - + ; CHECK: @test3 ; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 1 ; CHECK-NEXT: bitcast <2 x i64> %B to <4 x float> @@ -75,7 +75,7 @@ define <2 x i32> @test4(i32 %A, i32 %B){ ; CHECK: @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> + ; CHECK-NEXT: ret <2 x i32> } @@ -92,7 +92,7 @@ define <2 x float> @test5(float %A, float %B) { ; CHECK: @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> + ; CHECK-NEXT: ret <2 x float> } define <2 x float> @test6(float %A){ @@ -123,7 +123,7 @@ define i64 @Vec2(i64 %in) { } 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) + %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: ret i64 0 @@ -131,9 +131,16 @@ 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) + %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: ret i32 0 } +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: bitcast i32 %a to <2 x i16> +} diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index b4eb69d436..de738bb7c0 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -473,14 +473,12 @@ define i64 @test51(i64 %A, i1 %cond) { %F = sext i32 %E to i64 ret i64 %F ; CHECK: @test51 - -; FIXME: disabled, see PR5997 -; HECK-NEXT: %C = and i64 %A, 4294967294 -; HECK-NEXT: %D = or i64 %A, 1 -; HECK-NEXT: %E = select i1 %cond, i64 %C, i64 %D -; HECK-NEXT: %sext = shl i64 %E, 32 -; HECK-NEXT: %F = ashr i64 %sext, 32 -; HECK-NEXT: ret i64 %F +; CHECK-NEXT: %C = and i64 %A, 4294967294 +; CHECK-NEXT: %D = or i64 %A, 1 +; CHECK-NEXT: %E = select i1 %cond, i64 %C, i64 %D +; CHECK-NEXT: %sext = shl i64 %E, 32 +; CHECK-NEXT: %F = ashr exact i64 %sext, 32 +; CHECK-NEXT: ret i64 %F } define i32 @test52(i64 %A) { diff --git a/test/Transforms/InstCombine/compare-signs.ll b/test/Transforms/InstCombine/compare-signs.ll index f8e4911061..72db66e3ab 100644 --- a/test/Transforms/InstCombine/compare-signs.ll +++ b/test/Transforms/InstCombine/compare-signs.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -instcombine -S | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s ; PR5438 ; TODO: This should also optimize down. diff --git a/test/Transforms/InstCombine/constant-expr-datalayout.ll b/test/Transforms/InstCombine/constant-expr-datalayout.ll new file mode 100644 index 0000000000..9a72c77afd --- /dev/null +++ b/test/Transforms/InstCombine/constant-expr-datalayout.ll @@ -0,0 +1,12 @@ +; RUN: opt -instcombine %s -S -o - | 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" + +%test1.struct = type { i32, i32 } +@test1.aligned_glbl = global %test1.struct zeroinitializer, align 4 +define void @test1(i64 *%ptr) { + store i64 and (i64 ptrtoint (i32* getelementptr (%test1.struct* @test1.aligned_glbl, i32 0, i32 1) to i64), i64 3), i64* %ptr +; CHECK: store i64 0, i64* %ptr + ret void +} diff --git a/test/Transforms/InstCombine/debuginfo.ll b/test/Transforms/InstCombine/debuginfo.ll index f6892fc3e1..f27ab278da 100644 --- a/test/Transforms/InstCombine/debuginfo.ll +++ b/test/Transforms/InstCombine/debuginfo.ll @@ -28,22 +28,23 @@ entry: ret i8* %call, !dbg !21 } -!llvm.dbg.lv.foobar = !{!0, !7, !9} -!llvm.dbg.sp = !{!1} +!25 = metadata !{metadata !0, metadata !7, metadata !9} +!llvm.dbg.cu = !{!3} +!24 = metadata !{metadata !1} -!0 = metadata !{i32 590081, metadata !1, metadata !"__dest", metadata !2, i32 16777294, metadata !6, i32 0} ; [ DW_TAG_arg_variable ] -!1 = metadata !{i32 589870, i32 0, 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} ; [ DW_TAG_subprogram ] -!2 = metadata !{i32 589865, metadata !"string.h", metadata !"Game", metadata !3} ; [ DW_TAG_file_type ] -!3 = metadata !{i32 589841, i32 0, i32 12, metadata !"bits.c", metadata !"Game", metadata !"clang version 3.0 (trunk 127710)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!4 = metadata !{i32 589845, 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 ] +!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, i32 0, 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 ] +!2 = metadata !{i32 786473, metadata !"string.h", metadata !"Game", metadata !3} ; [ DW_TAG_file_type ] +!3 = metadata !{i32 786449, i32 0, i32 12, metadata !"bits.c", metadata !"Game", metadata !"clang version 3.0 (trunk 127710)", i1 true, 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 ] !5 = metadata !{metadata !6} -!6 = metadata !{i32 589839, metadata !3, metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ] -!7 = metadata !{i32 590081, metadata !1, metadata !"__val", metadata !2, i32 33554510, metadata !8, i32 0} ; [ DW_TAG_arg_variable ] -!8 = metadata !{i32 589860, metadata !3, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!9 = metadata !{i32 590081, metadata !1, metadata !"__len", metadata !2, i32 50331726, metadata !10, i32 0} ; [ DW_TAG_arg_variable ] +!6 = metadata !{i32 786447, metadata !3, metadata !"", null, 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 ] +!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 589860, metadata !3, metadata !"long unsigned int", null, i32 0, i64 64, i64 64, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ] +!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 ] !13 = metadata !{metadata !"any pointer", metadata !14} !14 = metadata !{metadata !"omnipotent char", metadata !15} !15 = metadata !{metadata !"Simple C/C++ TBAA", null} @@ -53,5 +54,5 @@ entry: !19 = metadata !{metadata !"long", metadata !14} !20 = metadata !{i32 78, i32 54, metadata !1, null} !21 = metadata !{i32 80, i32 3, metadata !22, null} -!22 = metadata !{i32 589835, metadata !23, i32 80, i32 3, metadata !2, i32 7} ; [ DW_TAG_lexical_block ] -!23 = metadata !{i32 589835, metadata !1, i32 79, i32 1, metadata !2, i32 6} ; [ DW_TAG_lexical_block ] +!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 ] diff --git a/test/Transforms/InstCombine/devirt.ll b/test/Transforms/InstCombine/devirt.ll index 6189dc2af4..9c7cf5d697 100644 --- a/test/Transforms/InstCombine/devirt.ll +++ b/test/Transforms/InstCombine/devirt.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine -S -o - %s | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s ; CHECK-NOT: getelementptr ; CHECK-NOT: ptrtoint diff --git a/test/Transforms/InstCombine/exact.ll b/test/Transforms/InstCombine/exact.ll index 14741e3c1c..88ca88c3b9 100644 --- a/test/Transforms/InstCombine/exact.ll +++ b/test/Transforms/InstCombine/exact.ll @@ -99,9 +99,9 @@ define i1 @ashr_icmp2(i64 %X) nounwind { ; PR9998 ; Make sure we don't transform the ashr here into an sdiv ; CHECK: @pr9998 -; CHECK: = and i32 %V, 1 -; CHECK: %Z = icmp ne -; CHECK: ret i1 %Z +; 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]] define i1 @pr9998(i32 %V) nounwind { entry: %W = shl i32 %V, 31 @@ -112,6 +112,7 @@ entry: } + ; CHECK: @udiv_icmp1 ; CHECK: icmp ne i64 %X, 0 define i1 @udiv_icmp1(i64 %X) nounwind { diff --git a/test/Transforms/InstCombine/fast-math.ll b/test/Transforms/InstCombine/fast-math.ll index b6a15677bb..3e32a2e4dd 100644 --- a/test/Transforms/InstCombine/fast-math.ll +++ b/test/Transforms/InstCombine/fast-math.ll @@ -3,19 +3,17 @@ ; testing-case "float fold(float a) { return 1.2f * a * 2.3f; }" ; 1.2f and 2.3f is supposed to be fold. define float @fold(float %a) { -fold: %mul = fmul fast float %a, 0x3FF3333340000000 %mul1 = fmul fast float %mul, 0x4002666660000000 ret float %mul1 -; CHECK: fold -; CHECK: fmul float %a, 0x4006147AE0000000 +; CHECK: @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) { -notfold: -; CHECK: notfold +; CHECK: @notfold ; CHECK: %mul = fmul fast float %a, 0x3FF3333340000000 %mul = fmul fast float %a, 0x3FF3333340000000 %mul1 = fmul float %mul, 0x4002666660000000 @@ -23,10 +21,332 @@ notfold: } define float @fold2(float %a) { -fold2: -; CHECK: fold2 -; CHECK: fmul float %a, 0x4006147AE0000000 +; CHECK: @fold2 +; CHECK: fmul fast float %a, 0x4006147AE0000000 %mul = fmul float %a, 0x3FF3333340000000 %mul1 = fmul fast float %mul, 0x4002666660000000 ret float %mul1 } + +; C * f1 + f1 = (C+1) * f1 +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: fmul fast double %f1, 3.000000e+00 +} + +; (C1 - X) + (C2 - Y) => (C1+C2) - (X + Y) +define float @fold4(float %f1, float %f2) { + %sub = fsub float 4.000000e+00, %f1 + %sub1 = fsub float 5.000000e+00, %f2 + %add = fadd fast float %sub, %sub1 + ret float %add +; CHECK: @fold4 +; CHECK: %1 = fadd fast float %f1, %f2 +; CHECK: fsub fast float 9.000000e+00, %1 +} + +; (X + C1) + C2 => X + (C1 + C2) +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: fadd fast float %f1, 9.000000e+00 +} + +; (X + X) + X => 3.0 * X +define float @fold6(float %f1) { + %t1 = fadd fast float %f1, %f1 + %t2 = fadd fast float %f1, %t1 + ret float %t2 +; CHECK: @fold6 +; CHECK: fmul fast float %f1, 3.000000e+00 +} + +; C1 * X + (X + X) = (C1 + 2) * X +define float @fold7(float %f1) { + %t1 = fmul fast float %f1, 5.000000e+00 + %t2 = fadd fast float %f1, %f1 + %t3 = fadd fast float %t1, %t2 + ret float %t3 +; CHECK: @fold7 +; CHECK: fmul fast float %f1, 7.000000e+00 +} + +; (X + X) + (X + X) => 4.0 * X +define float @fold8(float %f1) { + %t1 = fadd fast float %f1, %f1 + %t2 = fadd fast float %f1, %f1 + %t3 = fadd fast float %t1, %t2 + ret float %t3 +; CHECK: fold8 +; CHECK: fmul fast float %f1, 4.000000e+00 +} + +; X - (X + Y) => 0 - Y +define float @fold9(float %f1, float %f2) { + %t1 = fadd float %f1, %f2 + %t3 = fsub fast float %f1, %t1 + ret float %t3 + +; CHECK: @fold9 +; CHECK: fsub fast float 0.000000e+00, %f2 +} + +; Let C3 = C1 + C2. (f1 + C1) + (f2 + C2) => (f1 + f2) + C3 instead of +; "(f1 + C3) + f2" or "(f2 + C3) + f1". Placing constant-addend at the +; top of resulting simplified expression tree may potentially reveal some +; optimization opportunities in the super-expression trees. +; +define float @fold10(float %f1, float %f2) { + %t1 = fadd fast float 2.000000e+00, %f1 + %t2 = fsub fast float %f2, 3.000000e+00 + %t3 = fadd fast float %t1, %t2 + ret float %t3 +; CHECK: @fold10 +; CHECK: %t3 = fadd fast float %t2, -1.000000e+00 +; CHECK: ret float %t3 +} + +; once cause Crash/miscompilation +define float @fail1(float %f1, float %f2) { + %conv3 = fadd fast float %f1, -1.000000e+00 + %add = fadd fast float %conv3, %conv3 + %add2 = fadd fast float %add, %conv3 + ret float %add2 +; CHECK: @fail1 +; CHECK: ret +} + +define double @fail2(double %f1, double %f2) { + %t1 = fsub fast double %f1, %f2 + %t2 = fadd fast double %f1, %f2 + %t3 = fsub fast double %t1, %t2 + ret double %t3 +; CHECK: @fail2 +; CHECK: ret +} + +; ========================================================================= +; +; Testing-cases about fmul begin +; +; ========================================================================= + +; ((X*C1) + C2) * C3 => (X * (C1*C3)) + (C2*C3) (i.e. distribution) +define float @fmul_distribute1(float %f1) { + %t1 = fmul float %f1, 6.0e+3 + %t2 = fadd float %t1, 2.0e+3 + %t3 = fmul fast float %t2, 5.0e+3 + ret float %t3 +; CHECK: @fmul_distribute1 +; CHECK: %1 = fmul fast float %f1, 3.000000e+07 +; CHECK: %t3 = fadd fast float %1, 1.000000e+07 +} + +; (X/C1 + C2) * C3 => X/(C1/C3) + C2*C3 +define double @fmul_distribute2(double %f1, double %f2) { + %t1 = fdiv double %f1, 3.0e+0 + %t2 = fadd double %t1, 5.0e+1 + ; 0x10000000000000 = DBL_MIN + %t3 = fmul fast double %t2, 0x10000000000000 + ret double %t3 + +; CHECK: @fmul_distribute2 +; CHECK: %1 = fdiv fast double %f1, 0x7FE8000000000000 +; CHECK: fadd fast double %1, 0x69000000000000 +} + +; 5.0e-1 * DBL_MIN yields denormal, so "(f1*3.0 + 5.0e-1) * DBL_MIN" cannot +; be simplified into f1 * (3.0*DBL_MIN) + (5.0e-1*DBL_MIN) +define double @fmul_distribute3(double %f1) { + %t1 = fdiv double %f1, 3.0e+0 + %t2 = fadd double %t1, 5.0e-1 + %t3 = fmul fast double %t2, 0x10000000000000 + ret double %t3 + +; CHECK: @fmul_distribute3 +; CHECK: fmul fast double %t2, 0x10000000000000 +} + +; ((X*C1) + C2) * C3 => (X * (C1*C3)) + (C2*C3) (i.e. distribution) +define float @fmul_distribute4(float %f1) { + %t1 = fmul float %f1, 6.0e+3 + %t2 = fsub float 2.0e+3, %t1 + %t3 = fmul fast float %t2, 5.0e+3 + ret float %t3 +; CHECK: @fmul_distribute4 +; CHECK: %1 = fmul fast float %f1, 3.000000e+07 +; CHECK: %t3 = fsub fast float 1.000000e+07, %1 +} + +; C1/X * C2 => (C1*C2) / X +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: fdiv fast float 1.200000e+07, %f1 +} + +; 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: fmul fast float %f1, 3.000000e+00 +} + +; Rule "X/C1 * C2 => X * (C2/C1) is not applicable if C2/C1 is either a special +; value of a denormal. The 0x3810000000000000 here take value FLT_MIN +; +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: fmul fast float %t1, 0x3810000000000000 +} + +; X / C1 * C2 => X / (C2/C1) if C1/C2 is either a special value of a denormal, +; and C2/C1 is a normal value. +; +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: fdiv fast float %f1, 0x47E8000000000000 +} + +; (X*Y) * X => (X*X) * Y +define float @fmul6(float %f1, float %f2) { + %mul = fmul float %f1, %f2 + %mul1 = fmul fast float %mul, %f1 + ret float %mul1 +; CHECK: @fmul6 +; CHECK: fmul fast float %f1, %f1 +} + +; "(X*Y) * X => (X*X) * Y" is disabled if "X*Y" has multiple uses +define float @fmul7(float %f1, float %f2) { + %mul = fmul float %f1, %f2 + %mul1 = fmul fast float %mul, %f1 + %add = fadd float %mul1, %mul + ret float %add +; CHECK: @fmul7 +; CHECK: fmul fast float %mul, %f1 +} + +; ========================================================================= +; +; Testing-cases about negation +; +; ========================================================================= +define float @fneg1(float %f1, float %f2) { + %sub = fsub float -0.000000e+00, %f1 + %sub1 = fsub nsz float 0.000000e+00, %f2 + %mul = fmul float %sub, %sub1 + ret float %mul +; CHECK: @fneg1 +; CHECK: fmul float %f1, %f2 +} + +; ========================================================================= +; +; Testing-cases about div +; +; ========================================================================= + +; X/C1 / C2 => X * (1/(C2*C1)) +define float @fdiv1(float %x) { + %div = fdiv float %x, 0x3FF3333340000000 + %div1 = fdiv fast float %div, 0x4002666660000000 + ret float %div1 +; 0x3FF3333340000000 = 1.2f +; 0x4002666660000000 = 2.3f +; 0x3FD7303B60000000 = 0.36231884057971014492 +; CHECK: @fdiv1 +; CHECK: fmul fast float %x, 0x3FD7303B60000000 +} + +; X*C1 / C2 => X * (C1/C2) +define float @fdiv2(float %x) { + %mul = fmul float %x, 0x3FF3333340000000 + %div1 = fdiv fast float %mul, 0x4002666660000000 + ret float %div1 + +; 0x3FF3333340000000 = 1.2f +; 0x4002666660000000 = 2.3f +; 0x3FE0B21660000000 = 0.52173918485641479492 +; CHECK: @fdiv2 +; CHECK: fmul fast float %x, 0x3FE0B21660000000 +} + +; "X/C1 / C2 => X * (1/(C2*C1))" is disabled (for now) is C2/C1 is a denormal +; +define float @fdiv3(float %x) { + %div = fdiv float %x, 0x47EFFFFFE0000000 + %div1 = fdiv fast float %div, 0x4002666660000000 + ret float %div1 +; CHECK: @fdiv3 +; CHECK: fdiv float %x, 0x47EFFFFFE0000000 +} + +; "X*C1 / C2 => X * (C1/C2)" is disabled if C1/C2 is a denormal +define float @fdiv4(float %x) { + %mul = fmul float %x, 0x47EFFFFFE0000000 + %div = fdiv float %mul, 0x3FC99999A0000000 + ret float %div +; CHECK: @fdiv4 +; CHECK: fmul float %x, 0x47EFFFFFE0000000 +} + +; (X/Y)/Z = > X/(Y*Z) +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: fmul float %f2, %f3 +} + +; Z/(X/Y) = > (Z*Y)/X +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: fmul float %f3, %f2 +} + +; C1/(X*C2) => (C1/C2) / X +define float @fdiv7(float %x) { + %t1 = fmul float %x, 3.0e0 + %t2 = fdiv fast float 15.0e0, %t1 + ret float %t2 +; CHECK: @fdiv7 +; CHECK: fdiv fast float 5.000000e+00, %x +} + +; C1/(X/C2) => (C1*C2) / X +define float @fdiv8(float %x) { + %t1 = fdiv float %x, 3.0e0 + %t2 = fdiv fast float 15.0e0, %t1 + ret float %t2 +; CHECK: @fdiv8 +; CHECK: fdiv fast float 4.500000e+01, %x +} + +; C1/(C2/X) => (C1/C2) * X +define float @fdiv9(float %x) { + %t1 = fdiv float 3.0e0, %x + %t2 = fdiv fast float 15.0e0, %t1 + ret float %t2 +; CHECK: @fdiv9 +; CHECK: fmul fast float %x, 5.000000e+00 +} diff --git a/test/Transforms/InstCombine/fmul.ll b/test/Transforms/InstCombine/fmul.ll new file mode 100644 index 0000000000..3671b4c699 --- /dev/null +++ b/test/Transforms/InstCombine/fmul.ll @@ -0,0 +1,72 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +; (-0.0 - X) * C => X * -C +define float @test1(float %x) { + %sub = fsub float -0.000000e+00, %x + %mul = fmul float %sub, 2.0e+1 + ret float %mul + +; CHECK: @test1 +; CHECK: fmul float %x, -2.000000e+01 +} + +; (0.0 - X) * C => X * -C +define float @test2(float %x) { + %sub = fsub nsz float 0.000000e+00, %x + %mul = fmul float %sub, 2.0e+1 + ret float %mul + +; CHECK: @test2 +; CHECK: fmul float %x, -2.000000e+01 +} + +; (-0.0 - X) * (-0.0 - Y) => X * Y +define float @test3(float %x, float %y) { + %sub1 = fsub float -0.000000e+00, %x + %sub2 = fsub float -0.000000e+00, %y + %mul = fmul float %sub1, %sub2 + ret float %mul +; CHECK: @test3 +; CHECK: fmul float %x, %y +} + +; (0.0 - X) * (0.0 - Y) => X * Y +define float @test4(float %x, float %y) { + %sub1 = fsub nsz float 0.000000e+00, %x + %sub2 = fsub nsz float 0.000000e+00, %y + %mul = fmul float %sub1, %sub2 + ret float %mul +; CHECK: @test4 +; CHECK: fmul float %x, %y +} + +; (-0.0 - X) * Y => -0.0 - (X * Y) +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: %1 = fmul float %x, %y +; CHECK: %mul = fsub float -0.000000e+00, %1 +} + +; (0.0 - X) * Y => 0.0 - (X * Y) +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: %1 = fmul float %x, %y +; CHECK: %mul = fsub float -0.000000e+00, %1 +} + +; "(-0.0 - X) * Y => -0.0 - (X * Y)" is disabled if expression "-0.0 - X" +; has multiple uses. +define float @test7(float %x, float %y) { + %sub1 = fsub float -0.000000e+00, %x + %mul = fmul float %sub1, %y + %mul2 = fmul float %mul, %sub1 + ret float %mul2 +; CHECK: @test7 +; CHECK: fsub float -0.000000e+00, %x +} diff --git a/test/Transforms/InstCombine/fold-phi.ll b/test/Transforms/InstCombine/fold-phi.ll new file mode 100644 index 0000000000..bd01d58aa5 --- /dev/null +++ b/test/Transforms/InstCombine/fold-phi.ll @@ -0,0 +1,39 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +; CHECK: no_crash +define float @no_crash(float %a) nounwind { +entry: + br label %for.body + +for.body: + %sum.057 = phi float [ 0.000000e+00, %entry ], [ %add5, %bb0 ] + %add5 = fadd float %sum.057, %a ; PR14592 + br i1 undef, label %bb0, label %end + +bb0: + br label %for.body + +end: + ret float %add5 +} + +; CHECK: fold_phi +define float @fold_phi(float %a) nounwind { +entry: + br label %for.body + +for.body: +; CHECK: phi float +; CHECK-NEXT: br i1 undef + %sum.057 = phi float [ 0.000000e+00, %entry ], [ %add5, %bb0 ] + %add5 = fadd float %sum.057, 1.0 ;; Should be moved to the latch! + br i1 undef, label %bb0, label %end + +; CHECK: bb0: +bb0: +; CHECK: fadd float + br label %for.body + +end: + ret float %add5 +} diff --git a/test/Transforms/InstCombine/fpcast.ll b/test/Transforms/InstCombine/fpcast.ll index bc6aa0a689..09f053289d 100644 --- a/test/Transforms/InstCombine/fpcast.ll +++ b/test/Transforms/InstCombine/fpcast.ll @@ -13,3 +13,22 @@ define i8 @test2() { ; CHECK: ret i8 -1 } +; CHECK: test3 +define half @test3(float %a) { +; CHECK: fptrunc +; CHECK: llvm.fabs.f16 + %b = call float @llvm.fabs.f32(float %a) + %c = fptrunc float %b to half + ret half %c +} + +; CHECK: test4 +define half @test4(float %a) { +; CHECK: fptrunc +; CHECK: fsub + %b = fsub float -0.0, %a + %c = fptrunc float %b to half + ret half %c +} + +declare float @llvm.fabs.f32(float) nounwind readonly diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll index 1c120ecbe9..bb07736ef8 100644 --- a/test/Transforms/InstCombine/getelementptr.ll +++ b/test/Transforms/InstCombine/getelementptr.ll @@ -424,7 +424,7 @@ define i32 @test35() nounwind { i8* getelementptr (%t1* bitcast (%t0* @s to %t1*), i32 0, i32 1, i32 0)) nounwind ret i32 0 ; CHECK: @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)) nounwind +; 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]+]] } ; Instcombine should constant-fold the GEP so that indices that have @@ -492,3 +492,21 @@ define void @three_gep_f(%three_gep_t2* %x) { declare void @three_gep_g(i32*) declare void @three_gep_h(%three_gep_t2*) + +%struct.ham = type { i32, %struct.zot*, %struct.zot*, %struct.zot* } +%struct.zot = type { i64, i8 } + +define void @test39(%struct.ham* %arg, i8 %arg1) nounwind { + %tmp = getelementptr inbounds %struct.ham* %arg, i64 0, i32 2 + %tmp2 = load %struct.zot** %tmp, align 8 + %tmp3 = bitcast %struct.zot* %tmp2 to i8* + %tmp4 = getelementptr inbounds i8* %tmp3, i64 -8 + store i8 %arg1, i8* %tmp4, align 8 + ret void + +; CHECK: @test39 +; CHECK: getelementptr inbounds %struct.ham* %arg, i64 0, i32 2 +; CHECK: getelementptr inbounds i8* %tmp3, i64 -8 +} + +; CHECK: attributes [[NUW]] = { nounwind } diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 8e064a4f2f..331eb3f21a 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -677,3 +677,70 @@ define i1 @test66(i64 %A, i64 %B) { ; CHECK-NEXT: ret i1 true ret i1 %cmp } + +; CHECK: @test67 +; CHECK: %and = and i32 %x, 96 +; CHECK: %cmp = icmp ne i32 %and, 0 +define i1 @test67(i32 %x) nounwind uwtable { + %and = and i32 %x, 127 + %cmp = icmp sgt i32 %and, 31 + ret i1 %cmp +} + +; CHECK: @test68 +; CHECK: %cmp = icmp ugt i32 %and, 30 +define i1 @test68(i32 %x) nounwind uwtable { + %and = and i32 %x, 127 + %cmp = icmp sgt i32 %and, 30 + ret i1 %cmp +} + +; PR14708 +; CHECK: @test69 +; CHECK: %1 = and i32 %c, -33 +; CHECK: %2 = icmp eq i32 %1, 65 +; CHECK: ret i1 %2 +define i1 @test69(i32 %c) nounwind uwtable { + %1 = icmp eq i32 %c, 97 + %2 = icmp eq i32 %c, 65 + %3 = or i1 %1, %2 + ret i1 %3 +} + +; CHECK: @icmp_sext16trunc +; CHECK-NEXT: %1 = trunc i32 %x to i16 +; CHECK-NEXT: %cmp = icmp slt i16 %1, 36 +define i1 @icmp_sext16trunc(i32 %x) { + %trunc = trunc i32 %x to i16 + %sext = sext i16 %trunc to i32 + %cmp = icmp slt i32 %sext, 36 + ret i1 %cmp +} + +; CHECK: @icmp_sext8trunc +; CHECK-NEXT: %1 = trunc i32 %x to i8 +; CHECK-NEXT: %cmp = icmp slt i8 %1, 36 +define i1 @icmp_sext8trunc(i32 %x) { + %trunc = trunc i32 %x to i8 + %sext = sext i8 %trunc to i32 + %cmp = icmp slt i32 %sext, 36 + ret i1 %cmp +} + +; CHECK: @icmp_shl16 +; CHECK-NEXT: %1 = trunc i32 %x to i16 +; CHECK-NEXT: %cmp = icmp slt i16 %1, 36 +define i1 @icmp_shl16(i32 %x) { + %shl = shl i32 %x, 16 + %cmp = icmp slt i32 %shl, 2359296 + ret i1 %cmp +} + +; CHECK: @icmp_shl24 +; CHECK-NEXT: %1 = trunc i32 %x to i8 +; CHECK-NEXT: %cmp = icmp slt i8 %1, 36 +define i1 @icmp_shl24(i32 %x) { + %shl = shl i32 %x, 24 + %cmp = icmp slt i32 %shl, 603979776 + ret i1 %cmp +} diff --git a/test/Transforms/InstCombine/idioms.ll b/test/Transforms/InstCombine/idioms.ll index 6b3567fc6e..1a211668c3 100644 --- a/test/Transforms/InstCombine/idioms.ll +++ b/test/Transforms/InstCombine/idioms.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine %s -S | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s ; Check that code corresponding to the following C function is ; simplified into a single ASR operation: diff --git a/test/Transforms/InstCombine/intrinsics.ll b/test/Transforms/InstCombine/intrinsics.ll index 382e6b3857..f334b3b1e9 100644 --- a/test/Transforms/InstCombine/intrinsics.ll +++ b/test/Transforms/InstCombine/intrinsics.ll @@ -1,4 +1,4 @@ -; RUN: opt %s -instcombine -S | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s %overflow.result = type {i8, i1} @@ -220,3 +220,39 @@ define i32 @cttz_simplify1b(i32 %x) nounwind readnone ssp { ; CHECK: @cttz_simplify1b ; CHECK-NEXT: ret i32 0 } + +define i32 @ctlz_undef(i32 %Value) nounwind { + %ctlz = call i32 @llvm.ctlz.i32(i32 0, i1 true) + ret i32 %ctlz + +; CHECK: @ctlz_undef +; CHECK-NEXT: ret i32 undef +} + +define i32 @cttz_undef(i32 %Value) nounwind { + %cttz = call i32 @llvm.cttz.i32(i32 0, i1 true) + ret i32 %cttz + +; CHECK: @cttz_undef +; CHECK-NEXT: ret i32 undef +} + +define i32 @ctlz_select(i32 %Value) nounwind { + %tobool = icmp ne i32 %Value, 0 + %ctlz = call i32 @llvm.ctlz.i32(i32 %Value, i1 true) + %s = select i1 %tobool, i32 %ctlz, i32 32 + ret i32 %s + +; CHECK: @ctlz_select +; CHECK: select i1 %tobool, i32 %ctlz, i32 32 +} + +define i32 @cttz_select(i32 %Value) nounwind { + %tobool = icmp ne i32 %Value, 0 + %cttz = call i32 @llvm.cttz.i32(i32 %Value, i1 true) + %s = select i1 %tobool, i32 %cttz, i32 32 + ret i32 %s + +; CHECK: @cttz_select +; CHECK: select i1 %tobool, i32 %cttz, i32 32 +} diff --git a/test/Transforms/InstCombine/load3.ll b/test/Transforms/InstCombine/load3.ll index 35398e17db..db74426783 100644 --- a/test/Transforms/InstCombine/load3.ll +++ b/test/Transforms/InstCombine/load3.ll @@ -1,6 +1,6 @@ ; 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" -target triple = "x86_64-apple-darwin10.0.0" +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-S128" +target triple = "i386-apple-macosx10.0.0" ; Instcombine should be able to do trivial CSE of loads. @@ -24,4 +24,23 @@ define float @test2() { ; CHECK: @test2 ; CHECK: ret float 0x3806965600000000 -}
\ No newline at end of file +} + +@rslts32 = global [36 x i32] zeroinitializer, align 4 + +@expect32 = internal constant [36 x i32][ i32 1, i32 2, i32 0, i32 100, i32 3, +i32 4, i32 0, i32 -7, i32 4, i32 4, i32 8, i32 8, i32 1, i32 3, i32 8, i32 3, +i32 4, i32 -2, i32 2, i32 8, i32 83, i32 77, i32 8, i32 17, i32 77, i32 88, i32 +22, i32 33, i32 44, i32 88, i32 77, i32 4, i32 4, i32 7, i32 -7, i32 -8] , +align 4 + +; PR14986 +define void @test3() nounwind { +; This is a weird way of computing zero. + %l = load i32* getelementptr ([36 x i32]* @expect32, i32 29826161, i32 28), align 4 + store i32 %l, i32* getelementptr ([36 x i32]* @rslts32, i32 29826161, i32 28), align 4 + ret void + +; CHECK: @test3 +; CHECK: store i32 1, i32* getelementptr inbounds ([36 x i32]* @rslts32, i32 0, i32 0) +} diff --git a/test/Transforms/InstCombine/logical-select.ll b/test/Transforms/InstCombine/logical-select.ll index bb59817a4f..f8c0676845 100644 --- a/test/Transforms/InstCombine/logical-select.ll +++ b/test/Transforms/InstCombine/logical-select.ll @@ -10,8 +10,8 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %j = or i32 %g, %i ret i32 %j ; CHECK: %e = icmp slt i32 %a, %b -; CHECK: %j = select i1 %e, i32 %c, i32 %d -; CHECK: ret i32 %j +; CHECK-NEXT: [[result:%.*]] = select i1 %e, i32 %c, i32 %d +; CHECK-NEXT: ret i32 [[result]] } define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %e = icmp slt i32 %a, %b @@ -22,8 +22,8 @@ define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { %j = or i32 %i, %g ret i32 %j ; CHECK: %e = icmp slt i32 %a, %b -; CHECK: %j = select i1 %e, i32 %c, i32 %d -; CHECK: ret i32 %j +; CHECK-NEXT: [[result:%.*]] = select i1 %e, i32 %c, i32 %d +; CHECK-NEXT: ret i32 [[result]] } define i32 @goo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { @@ -36,8 +36,8 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d +; CHECK-NEXT: ret i32 [[result]] } define i32 @poo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { entry: @@ -49,8 +49,8 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d +; CHECK-NEXT: ret i32 [[result]] } define i32 @par(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { @@ -63,6 +63,6 @@ entry: %3 = or i32 %1, %2 ret i32 %3 ; CHECK: %0 = icmp slt i32 %a, %b -; CHECK: %1 = select i1 %0, i32 %c, i32 %d -; CHECK: ret i32 %1 +; CHECK-NEXT: [[result:%.*]] = select i1 %0, i32 %c, i32 %d +; CHECK-NEXT: ret i32 [[result]] } diff --git a/test/Transforms/InstCombine/malloc-free-delete.ll b/test/Transforms/InstCombine/malloc-free-delete.ll index 4e3217dc2d..cd12b29b11 100644 --- a/test/Transforms/InstCombine/malloc-free-delete.ll +++ b/test/Transforms/InstCombine/malloc-free-delete.ll @@ -91,3 +91,32 @@ define void @test5(i8* %ptr, i8** %esc) { store volatile i8 4, i8* %g ret void } + +;; When a basic block contains only a call to free and this block is accessed +;; through a test of the argument of free against null, move the call in the +;; predecessor block. +;; 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 +define void @test6(i8* %foo) minsize { +; CHECK: %tobool = icmp eq i8* %foo, null +;; Call to free moved +; CHECK-NEXT: tail call void @free(i8* %foo) +; CHECK-NEXT: br i1 %tobool, label %if.end, label %if.then +; CHECK: if.then: +;; Block is now empty and may be simplified by simplifycfg +; CHECK-NEXT: br label %if.end +; CHECK: if.end: +; CHECK-NEXT: ret void +entry: + %tobool = icmp eq i8* %foo, null + br i1 %tobool, label %if.end, label %if.then + +if.then: ; preds = %entry + tail call void @free(i8* %foo) + br label %if.end + +if.end: ; preds = %entry, %if.then + ret void +} diff --git a/test/Transforms/InstCombine/mul.ll b/test/Transforms/InstCombine/mul.ll index bbc70fe333..16213b8628 100644 --- a/test/Transforms/InstCombine/mul.ll +++ b/test/Transforms/InstCombine/mul.ll @@ -138,10 +138,8 @@ define i32 @test16(i32 %b, i1 %c) { ; e = b & (a >> 31) %e = mul i32 %d, %b ; <i32> [#uses=1] ret i32 %e -; CHECK: [[TEST16:%.*]] = zext i1 %c to i32 -; CHECK-NEXT: %1 = sub i32 0, [[TEST16]] -; CHECK-NEXT: %e = and i32 %1, %b -; CHECK-NEXT: ret i32 %e +; CHECK: [[TEST16:%.*]] = select i1 %c, i32 %b, i32 0 +; CHECK-NEXT: ret i32 [[TEST16]] } ; X * Y (when Y is 0 or 1) --> x & (0-Y) diff --git a/test/Transforms/InstCombine/obfuscated_splat.ll b/test/Transforms/InstCombine/obfuscated_splat.ll index c25dade168..fa9cb423d0 100644 --- a/test/Transforms/InstCombine/obfuscated_splat.ll +++ b/test/Transforms/InstCombine/obfuscated_splat.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine -S %s | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s define void @test(<4 x float> *%in_ptr, <4 x float> *%out_ptr) { %A = load <4 x float>* %in_ptr, align 16 diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll index 31a3cb46e4..0ead9d1237 100644 --- a/test/Transforms/InstCombine/objsize.ll +++ b/test/Transforms/InstCombine/objsize.ll @@ -256,3 +256,131 @@ xpto: return: ret i32 7 } + +declare noalias i8* @valloc(i32) nounwind + +; CHECK: @test14 +; CHECK: ret i32 6 +define i32 @test14(i32 %a) nounwind { + switch i32 %a, label %sw.default [ + i32 1, label %sw.bb + i32 2, label %sw.bb1 + ] + +sw.bb: + %call = tail call noalias i8* @malloc(i32 6) nounwind + br label %sw.epilog + +sw.bb1: + %call2 = tail call noalias i8* @calloc(i32 3, i32 2) nounwind + br label %sw.epilog + +sw.default: + %call3 = tail call noalias i8* @valloc(i32 6) nounwind + br label %sw.epilog + +sw.epilog: + %b.0 = phi i8* [ %call3, %sw.default ], [ %call2, %sw.bb1 ], [ %call, %sw.bb ] + %1 = tail call i32 @llvm.objectsize.i32(i8* %b.0, i1 false) + ret i32 %1 +} + +; CHECK: @test15 +; CHECK: llvm.objectsize +define i32 @test15(i32 %a) nounwind { + switch i32 %a, label %sw.default [ + i32 1, label %sw.bb + i32 2, label %sw.bb1 + ] + +sw.bb: + %call = tail call noalias i8* @malloc(i32 3) nounwind + br label %sw.epilog + +sw.bb1: + %call2 = tail call noalias i8* @calloc(i32 2, i32 1) nounwind + br label %sw.epilog + +sw.default: + %call3 = tail call noalias i8* @valloc(i32 3) nounwind + br label %sw.epilog + +sw.epilog: + %b.0 = phi i8* [ %call3, %sw.default ], [ %call2, %sw.bb1 ], [ %call, %sw.bb ] + %1 = tail call i32 @llvm.objectsize.i32(i8* %b.0, i1 false) + ret i32 %1 +} + +; CHECK: @test16 +; CHECK: llvm.objectsize +define i32 @test16(i8* %a, i32 %n) nounwind { + %b = alloca [5 x i8], align 1 + %c = alloca [5 x i8], align 1 + switch i32 %n, label %sw.default [ + i32 1, label %sw.bb + i32 2, label %sw.bb1 + ] + +sw.bb: + %bp = bitcast [5 x i8]* %b to i8* + br label %sw.epilog + +sw.bb1: + %cp = bitcast [5 x i8]* %c to i8* + br label %sw.epilog + +sw.default: + br label %sw.epilog + +sw.epilog: + %phi = phi i8* [ %a, %sw.default ], [ %cp, %sw.bb1 ], [ %bp, %sw.bb ] + %sz = call i32 @llvm.objectsize.i32(i8* %phi, i1 false) + ret i32 %sz +} + +; CHECK: @test17 +; CHECK: ret i32 5 +define i32 @test17(i32 %n) nounwind { + %b = alloca [5 x i8], align 1 + %c = alloca [5 x i8], align 1 + %bp = bitcast [5 x i8]* %b to i8* + switch i32 %n, label %sw.default [ + i32 1, label %sw.bb + i32 2, label %sw.bb1 + ] + +sw.bb: + br label %sw.epilog + +sw.bb1: + %cp = bitcast [5 x i8]* %c to i8* + br label %sw.epilog + +sw.default: + br label %sw.epilog + +sw.epilog: + %phi = phi i8* [ %bp, %sw.default ], [ %cp, %sw.bb1 ], [ %bp, %sw.bb ] + %sz = call i32 @llvm.objectsize.i32(i8* %phi, i1 false) + ret i32 %sz +} + +@globalalias = alias internal [60 x i8]* @a + +; CHECK: @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) + ret i32 %1 +} + +@globalalias2 = alias weak [60 x i8]* @a + +; CHECK: @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) + ret i32 %1 +} diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll index c0bb28d15c..bde2a54048 100644 --- a/test/Transforms/InstCombine/or.ll +++ b/test/Transforms/InstCombine/or.ll @@ -344,10 +344,9 @@ define <4 x i32> @test32(<4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32 %and.i = and <4 x i32> %vecinit6.i191, %neg.i ; <<4 x i32>> [#uses=1] %or.i = or <4 x i32> %and.i, %and.i129 ; <<4 x i32>> [#uses=1] ret <4 x i32> %or.i -; Don't turn this into a vector select until codegen matures to handle them -; better. +; codegen is mature enough to handle vector selects. ; CHECK: @test32 -; CHECK: or <4 x i32> %and.i, %and.i129 +; CHECK: select <4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32> %vecinit6.i191 } define i1 @test33(i1 %X, i1 %Y) { diff --git a/test/Transforms/InstCombine/pow-1.ll b/test/Transforms/InstCombine/pow-1.ll index c8e5f3806f..8a311f0b74 100644 --- a/test/Transforms/InstCombine/pow-1.ll +++ b/test/Transforms/InstCombine/pow-1.ll @@ -30,7 +30,7 @@ define double @test_simplify2(double %x) { define float @test_simplify3(float %x) { ; CHECK: @test_simplify3 %retval = call float @powf(float 2.0, float %x) -; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call float @exp2f(float %x) nounwind readonly +; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call float @exp2f(float %x) [[NUW_RO:#[0-9]+]] ret float %retval ; CHECK-NEXT: ret float [[EXP2F]] } @@ -38,7 +38,7 @@ define float @test_simplify3(float %x) { define double @test_simplify4(double %x) { ; CHECK: @test_simplify4 %retval = call double @pow(double 2.0, double %x) -; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call double @exp2(double %x) nounwind readonly +; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call double @exp2(double %x) [[NUW_RO]] ret double %retval ; CHECK-NEXT: ret double [[EXP2]] } @@ -64,8 +64,8 @@ define double @test_simplify6(double %x) { define float @test_simplify7(float %x) { ; CHECK: @test_simplify7 %retval = call float @powf(float %x, float 0.5) -; CHECK-NEXT: [[SQRTF:%[a-z0-9]+]] = call float @sqrtf(float %x) nounwind readonly -; CHECK-NEXT: [[FABSF:%[a-z0-9]+]] = call float @fabsf(float [[SQRTF]]) nounwind readonly +; 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]] ; CHECK-NEXT: [[FCMP:%[a-z0-9]+]] = fcmp oeq float %x, 0xFFF0000000000000 ; CHECK-NEXT: [[SELECT:%[a-z0-9]+]] = select i1 [[FCMP]], float 0x7FF0000000000000, float [[FABSF]] ret float %retval @@ -75,8 +75,8 @@ define float @test_simplify7(float %x) { define double @test_simplify8(double %x) { ; CHECK: @test_simplify8 %retval = call double @pow(double %x, double 0.5) -; CHECK-NEXT: [[SQRT:%[a-z0-9]+]] = call double @sqrt(double %x) nounwind readonly -; CHECK-NEXT: [[FABS:%[a-z0-9]+]] = call double @fabs(double [[SQRT]]) nounwind readonly +; 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 @@ -150,3 +150,5 @@ define double @test_simplify16(double %x) { ret double %retval ; CHECK-NEXT: ret double [[RECIPROCAL]] } + +; CHECK: attributes [[NUW_RO]] = { nounwind readonly } diff --git a/test/Transforms/InstCombine/ptr-int-cast.ll b/test/Transforms/InstCombine/ptr-int-cast.ll index 9524d449dd..7a6ecff9c0 100644 --- a/test/Transforms/InstCombine/ptr-int-cast.ll +++ b/test/Transforms/InstCombine/ptr-int-cast.ll @@ -27,3 +27,34 @@ define i64 @f0(i32 %a0) nounwind { ret i64 %t1 } +define <4 x i32> @test4(<4 x i8*> %arg) nounwind { +; CHECK: @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> + ret <4 x i32> %p1 +} + +define <4 x i128> @test5(<4 x i8*> %arg) nounwind { +; CHECK: @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> + ret <4 x i128> %p1 +} + +define <4 x i8*> @test6(<4 x i32> %arg) nounwind { +; CHECK: @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*> + ret <4 x i8*> %p1 +} + +define <4 x i8*> @test7(<4 x i128> %arg) nounwind { +; CHECK: @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*> + ret <4 x i8*> %p1 +} diff --git a/test/Transforms/InstCombine/sext.ll b/test/Transforms/InstCombine/sext.ll index f1987973f4..968f37c9c1 100644 --- a/test/Transforms/InstCombine/sext.ll +++ b/test/Transforms/InstCombine/sext.ll @@ -184,3 +184,12 @@ define i32 @test16(i16 %x) nounwind { ; CHECK-NEXT: %ext = sext i16 %sext to i32 ; CHECK-NEXT: ret i32 %ext } + +define i32 @test17(i1 %x) nounwind { + %c1 = sext i1 %x to i32 + %c2 = sub i32 0, %c1 + ret i32 %c2 +; CHECK: @test17 +; CHECK-NEXT: [[TEST17:%.*]] = zext i1 %x to i32 +; CHECK-NEXT: ret i32 [[TEST17]] +} diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index 32867761a3..41f8aa9ee8 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -735,3 +735,13 @@ define i32 @test61(i32 %x) { ; CHECK: @test61 ; CHECK: ashr i32 %x, 4 } + +; propagate "exact" trait +define i32 @test62(i32 %x) { + %shr = ashr exact i32 %x, 4 + %shl = shl i32 %shr, 1 + %or = or i32 %shl, 1 + ret i32 %or +; CHECK: @test62 +; CHECK: ashr exact i32 %x, 3 +} diff --git a/test/Transforms/InstCombine/sink_instruction.ll b/test/Transforms/InstCombine/sink_instruction.ll index e521de208f..5c4019a98d 100644 --- a/test/Transforms/InstCombine/sink_instruction.ll +++ b/test/Transforms/InstCombine/sink_instruction.ll @@ -1,4 +1,4 @@ -; RUN: opt -instcombine %s -S | FileCheck %s +; RUN: opt -instcombine -S < %s | FileCheck %s ;; This tests that the instructions in the entry blocks are sunk into each ;; arm of the 'if'. diff --git a/test/Transforms/InstCombine/sqrt.ll b/test/Transforms/InstCombine/sqrt.ll index cc78417ebb..440b974851 100644 --- a/test/Transforms/InstCombine/sqrt.ll +++ b/test/Transforms/InstCombine/sqrt.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -instcombine %s | FileCheck %s +; RUN: opt -S -instcombine < %s | FileCheck %s define float @test1(float %x) nounwind readnone ssp { entry: diff --git a/test/Transforms/InstCombine/store.ll b/test/Transforms/InstCombine/store.ll index 64460d7a6d..164ba76326 100644 --- a/test/Transforms/InstCombine/store.ll +++ b/test/Transforms/InstCombine/store.ll @@ -83,3 +83,37 @@ Cont: ; CHECK-NEXT: ret void } + +; PR14753 - merging two stores should preserve the TBAA tag. +define void @test6(i32 %n, float* %a, i32* %gi) nounwind uwtable ssp { +entry: + store i32 42, i32* %gi, align 4, !tbaa !0 + br label %for.cond + +for.cond: ; preds = %for.body, %entry + %storemerge = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %0 = load i32* %gi, align 4, !tbaa !0 + %cmp = icmp slt i32 %0, %n + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %idxprom = sext i32 %0 to i64 + %arrayidx = getelementptr inbounds float* %a, i64 %idxprom + store float 0.000000e+00, float* %arrayidx, align 4, !tbaa !3 + %1 = load i32* %gi, align 4, !tbaa !0 + %inc = add nsw i32 %1, 1 + store i32 %inc, i32* %gi, align 4, !tbaa !0 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +; CHECK: @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} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} +!3 = metadata !{metadata !"float", metadata !1} diff --git a/test/Transforms/InstCombine/vec_extract_elt.ll b/test/Transforms/InstCombine/vec_extract_elt.ll index 63e4ee2112..166066a201 100644 --- a/test/Transforms/InstCombine/vec_extract_elt.ll +++ b/test/Transforms/InstCombine/vec_extract_elt.ll @@ -7,3 +7,13 @@ define i32 @test(float %f) { ret i32 %tmp19 } +define i64 @test2(i64 %in) { + %vec = insertelement <8 x i64> undef, i64 %in, i32 0 + %splat = shufflevector <8 x i64> %vec, <8 x i64> undef, <8 x i32> zeroinitializer + %add = add <8 x i64> %splat, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7> + %scl1 = extractelement <8 x i64> %add, i32 0 + %scl2 = extractelement <8 x i64> %add, i32 0 + %r = add i64 %scl1, %scl2 + ret i64 %r +} + diff --git a/test/Transforms/InstCombine/vector-casts.ll b/test/Transforms/InstCombine/vector-casts.ll index 7bbf53c270..2f2990b7b0 100644 --- a/test/Transforms/InstCombine/vector-casts.ll +++ b/test/Transforms/InstCombine/vector-casts.ll @@ -64,7 +64,8 @@ entry: ; CHECK: @test5 ; CHECK: sext <4 x i1> %cmp to <4 x i32> -; CHECK: sext <4 x i1> %cmp4 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 } diff --git a/test/Transforms/InstCombine/vector_gep1.ll b/test/Transforms/InstCombine/vector_gep1.ll index f4c75c8009..90ca26212f 100644 --- a/test/Transforms/InstCombine/vector_gep1.ll +++ b/test/Transforms/InstCombine/vector_gep1.ll @@ -1,5 +1,5 @@ -; RUN: opt -instcombine %s -disable-output -; RUN: opt -instsimplify %s -disable-output +; RUN: opt -instcombine -disable-output < %s +; RUN: opt -instsimplify -disable-output < %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" diff --git a/test/Transforms/InstCombine/zext-bool-add-sub.ll b/test/Transforms/InstCombine/zext-bool-add-sub.ll index 78bcedbbc2..b531057550 100644 --- a/test/Transforms/InstCombine/zext-bool-add-sub.ll +++ b/test/Transforms/InstCombine/zext-bool-add-sub.ll @@ -4,9 +4,9 @@ define i32 @a(i1 zeroext %x, i1 zeroext %y) { entry: ; CHECK: @a -; CHECK: [[TMP1:%.*]] = zext i1 %y to i32 +; CHECK: [[TMP1:%.*]] = sext i1 %y to i32 ; CHECK: [[TMP2:%.*]] = select i1 %x, i32 2, i32 1 -; CHECK-NEXT: sub i32 [[TMP2]], [[TMP1]] +; CHECK-NEXT: add i32 [[TMP2]], [[TMP1]] %conv = zext i1 %x to i32 %conv3 = zext i1 %y to i32 %conv3.neg = sub i32 0, %conv3 |