1 ; This test makes sure that mul instructions are properly eliminated.
2 ; RUN: opt < %s -instcombine -S | not grep mul
4 define i32 @test1(i32 %A) {
5 %B = mul i32 %A, 1 ; <i32> [#uses=1]
9 define i32 @test2(i32 %A) {
10 ; Should convert to an add instruction
11 %B = mul i32 %A, 2 ; <i32> [#uses=1]
15 define i32 @test3(i32 %A) {
16 ; This should disappear entirely
17 %B = mul i32 %A, 0 ; <i32> [#uses=1]
21 define double @test4(double %A) {
23 %B = fmul double 1.000000e+00, %A ; <double> [#uses=1]
27 define i32 @test5(i32 %A) {
28 %B = mul i32 %A, 8 ; <i32> [#uses=1]
32 define i8 @test6(i8 %A) {
33 %B = mul i8 %A, 8 ; <i8> [#uses=1]
34 %C = mul i8 %B, 8 ; <i8> [#uses=1]
38 define i32 @test7(i32 %i) {
39 %tmp = mul i32 %i, -1 ; <i32> [#uses=1]
43 define i64 @test8(i64 %i) {
45 %j = mul i64 %i, -1 ; <i64> [#uses=1]
49 define i32 @test9(i32 %i) {
51 %j = mul i32 %i, -1 ; <i32> [#uses=1]
55 define i32 @test10(i32 %a, i32 %b) {
56 %c = icmp slt i32 %a, 0 ; <i1> [#uses=1]
57 %d = zext i1 %c to i32 ; <i32> [#uses=1]
59 %e = mul i32 %d, %b ; <i32> [#uses=1]
63 define i32 @test11(i32 %a, i32 %b) {
64 %c = icmp sle i32 %a, -1 ; <i1> [#uses=1]
65 %d = zext i1 %c to i32 ; <i32> [#uses=1]
67 %e = mul i32 %d, %b ; <i32> [#uses=1]
71 define i32 @test12(i8 %a, i32 %b) {
72 %c = icmp ugt i8 %a, 127 ; <i1> [#uses=1]
73 %d = zext i1 %c to i32 ; <i32> [#uses=1]
75 %e = mul i32 %d, %b ; <i32> [#uses=1]
80 define internal void @test13(<4 x float>*) {
81 load <4 x float>* %0, align 1
82 fmul <4 x float> %2, < float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 >
83 store <4 x float> %3, <4 x float>* %0, align 1
87 define <16 x i8> @test14(<16 x i8> %a) {
88 %b = mul <16 x i8> %a, zeroinitializer
93 define i32 @test15(i32 %A, i32 %B) {
100 ; X * Y (when Y is 0 or 1) --> x & (0-Y)
101 define i32 @test16(i32 %b, i1 %c) {
102 %d = zext i1 %c to i32 ; <i32> [#uses=1]
104 %e = mul i32 %d, %b ; <i32> [#uses=1]
108 ; X * Y (when Y is 0 or 1) --> x & (0-Y)
109 define i32 @test17(i32 %a, i32 %b) {
110 %a.lobit = lshr i32 %a, 31
111 %e = mul i32 %a.lobit, %b