X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FInstCombine%2Fcast.ll;h=7fe54ef8469b784ac584071efab1e50f29bda13a;hb=b53f724f913f6db279795439a90ec83d6ee20ddd;hp=4fab92f2c11d0670e3ce0ab6e15a04d206f7bb94;hpb=f222ebe86c944fc0f13afbb619bfa69880893f7a;p=oota-llvm.git diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index 4fab92f2c11..7fe54ef8469 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -93,16 +93,36 @@ declare void @varargs(i32, ...) define void @test11(i32* %P) { %c = bitcast i32* %P to i16* ; [#uses=1] - call void (i32, ...)* @varargs( i32 5, i16* %c ) + call void (i32, ...) @varargs( i32 5, i16* %c ) ret void -; CHECK: call void (i32, ...)* @varargs(i32 5, i32* %P) +; CHECK: call void (i32, ...) @varargs(i32 5, i32* %P) ; CHECK: ret void } +declare i32 @__gxx_personality_v0(...) +define void @test_invoke_vararg_cast(i32* %a, i32* %b) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { +entry: + %0 = bitcast i32* %b to i8* + %1 = bitcast i32* %a to i64* + invoke void (i32, ...) @varargs(i32 1, i8* %0, i64* %1) + to label %invoke.cont unwind label %lpad + +invoke.cont: ; preds = %entry + ret void + +lpad: ; preds = %entry + %2 = landingpad { i8*, i32 } + cleanup + ret void +; CHECK-LABEL: test_invoke_vararg_cast +; CHECK-LABEL: entry: +; CHECK: invoke void (i32, ...) @varargs(i32 1, i32* %b, i32* %a) +} + define i8* @test13(i64 %A) { - %c = getelementptr [0 x i8]* bitcast ([32832 x i8]* @inbuf to [0 x i8]*), i64 0, i64 %A ; [#uses=1] + %c = getelementptr [0 x i8], [0 x i8]* bitcast ([32832 x i8]* @inbuf to [0 x i8]*), i64 0, i64 %A ; [#uses=1] ret i8* %c -; CHECK: %c = getelementptr [32832 x i8]* @inbuf, i64 0, i64 %A +; CHECK: %c = getelementptr [32832 x i8], [32832 x i8]* @inbuf, i64 0, i64 %A ; CHECK: ret i8* %c } @@ -167,8 +187,8 @@ define i32 @test21(i32 %X) { %c2 = sext i8 %c1 to i32 ; [#uses=1] %RV = and i32 %c2, 255 ; [#uses=1] ret i32 %RV -; CHECK: %c21 = and i32 %X, 255 -; CHECK: ret i32 %c21 +; CHECK: %c2.1 = and i32 %X, 255 +; CHECK: ret i32 %c2.1 } define i32 @test22(i32 %X) { @@ -199,15 +219,6 @@ define i1 @test24(i1 %C) { ; CHECK: ret i1 true } -define void @test25(i32** %P) { - %c = bitcast i32** %P to float** ; [#uses=1] - ;; Fold cast into null - store float* null, float** %c - ret void -; CHECK: store i32* null, i32** %P -; CHECK: ret void -} - define i32 @test26(float %F) { ;; no need to cast from float->double. %c = fpext float %F to double ; [#uses=1] @@ -220,14 +231,14 @@ define i32 @test26(float %F) { define [4 x float]* @test27([9 x [4 x float]]* %A) { %c = bitcast [9 x [4 x float]]* %A to [4 x float]* ; <[4 x float]*> [#uses=1] ret [4 x float]* %c -; CHECK: %c = getelementptr inbounds [9 x [4 x float]]* %A, i64 0, i64 0 +; CHECK: %c = getelementptr inbounds [9 x [4 x float]], [9 x [4 x float]]* %A, i64 0, i64 0 ; CHECK: ret [4 x float]* %c } define float* @test28([4 x float]* %A) { %c = bitcast [4 x float]* %A to float* ; [#uses=1] ret float* %c -; CHECK: %c = getelementptr inbounds [4 x float]* %A, i64 0, i64 0 +; CHECK: %c = getelementptr inbounds [4 x float], [4 x float]* %A, i64 0, i64 0 ; CHECK: ret float* %c } @@ -348,12 +359,30 @@ define i16 @test40(i16 %a) { ; PR1263 define i32* @test41(i32* %tmp1) { %tmp64 = bitcast i32* %tmp1 to { i32 }* - %tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0 + %tmp65 = getelementptr { i32 }, { i32 }* %tmp64, i32 0, i32 0 ret i32* %tmp65 ; CHECK-LABEL: @test41( ; CHECK: ret i32* %tmp1 } +define i32 addrspace(1)* @test41_addrspacecast_smaller(i32* %tmp1) { + %tmp64 = addrspacecast i32* %tmp1 to { i32 } addrspace(1)* + %tmp65 = getelementptr { i32 }, { i32 } addrspace(1)* %tmp64, i32 0, i32 0 + ret i32 addrspace(1)* %tmp65 +; CHECK-LABEL: @test41_addrspacecast_smaller( +; CHECK: addrspacecast i32* %tmp1 to i32 addrspace(1)* +; CHECK-NEXT: ret i32 addrspace(1)* +} + +define i32* @test41_addrspacecast_larger(i32 addrspace(1)* %tmp1) { + %tmp64 = addrspacecast i32 addrspace(1)* %tmp1 to { i32 }* + %tmp65 = getelementptr { i32 }, { i32 }* %tmp64, i32 0, i32 0 + ret i32* %tmp65 +; CHECK-LABEL: @test41_addrspacecast_larger( +; CHECK: addrspacecast i32 addrspace(1)* %tmp1 to i32* +; CHECK-NEXT: ret i32* +} + define i32 @test42(i32 %X) { %Y = trunc i32 %X to i8 ; [#uses=1] %Z = zext i8 %Y to i32 ; [#uses=1] @@ -370,7 +399,7 @@ define zeroext i64 @test43(i8 zeroext %on_off) nounwind readonly { ret i64 %C ;; Should be (add (zext i8 -> i64), -1) ; CHECK-LABEL: @test43( ; CHECK-NEXT: %A = zext i8 %on_off to i64 -; CHECK-NEXT: %B = add i64 %A, -1 +; CHECK-NEXT: %B = add nsw i64 %A, -1 ; CHECK-NEXT: ret i64 %B } @@ -699,11 +728,11 @@ define %s @test68(%s *%p, i64 %i) { ; CHECK-LABEL: @test68( %o = mul i64 %i, 12 %q = bitcast %s* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o -; CHECK-NEXT: getelementptr %s* + %pp = getelementptr inbounds i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr %s, %s* %r = bitcast i8* %pp to %s* - %l = load %s* %r -; CHECK-NEXT: load %s* + %l = load %s, %s* %r +; CHECK-NEXT: load %s, %s* ret %s %l ; CHECK-NEXT: ret %s } @@ -711,28 +740,28 @@ define %s @test68(%s *%p, i64 %i) { ; addrspacecasts should be eliminated. define %s @test68_addrspacecast(%s* %p, i64 %i) { ; CHECK-LABEL: @test68_addrspacecast( -; CHECK-NEXT: getelementptr %s* -; CHECK-NEXT: load %s* +; CHECK-NEXT: getelementptr %s, %s* +; CHECK-NEXT: load %s, %s* ; CHECK-NEXT: ret %s %o = mul i64 %i, 12 %q = addrspacecast %s* %p to i8 addrspace(2)* - %pp = getelementptr inbounds i8 addrspace(2)* %q, i64 %o + %pp = getelementptr inbounds i8, i8 addrspace(2)* %q, i64 %o %r = addrspacecast i8 addrspace(2)* %pp to %s* - %l = load %s* %r + %l = load %s, %s* %r ret %s %l } define %s @test68_addrspacecast_2(%s* %p, i64 %i) { ; CHECK-LABEL: @test68_addrspacecast_2( -; CHECK-NEXT: getelementptr %s* %p +; CHECK-NEXT: getelementptr %s, %s* %p ; CHECK-NEXT: addrspacecast -; CHECK-NEXT: load %s addrspace(1)* +; CHECK-NEXT: load %s, %s addrspace(1)* ; CHECK-NEXT: ret %s %o = mul i64 %i, 12 %q = addrspacecast %s* %p to i8 addrspace(2)* - %pp = getelementptr inbounds i8 addrspace(2)* %q, i64 %o + %pp = getelementptr inbounds i8, i8 addrspace(2)* %q, i64 %o %r = addrspacecast i8 addrspace(2)* %pp to %s addrspace(1)* - %l = load %s addrspace(1)* %r + %l = load %s, %s addrspace(1)* %r ret %s %l } @@ -740,11 +769,11 @@ 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)* + %pp = getelementptr inbounds i8, i8 addrspace(1)* %q, i32 %o +; CHECK-NEXT: getelementptr %s, %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)* + %l = load %s, %s addrspace(1)* %r +; CHECK-NEXT: load %s, %s addrspace(1)* ret %s %l ; CHECK-NEXT: ret %s } @@ -753,11 +782,11 @@ define double @test69(double *%p, i64 %i) { ; CHECK-LABEL: @test69( %o = shl nsw i64 %i, 3 %q = bitcast double* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o -; CHECK-NEXT: getelementptr inbounds double* + %pp = getelementptr inbounds i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr inbounds double, double* %r = bitcast i8* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } @@ -767,11 +796,11 @@ define %s @test70(%s *%p, i64 %i) { %o = mul nsw i64 %i, 36 ; CHECK-NEXT: mul nsw i64 %i, 3 %q = bitcast %s* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o -; CHECK-NEXT: getelementptr inbounds %s* + %pp = getelementptr inbounds i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr inbounds %s, %s* %r = bitcast i8* %pp to %s* - %l = load %s* %r -; CHECK-NEXT: load %s* + %l = load %s, %s* %r +; CHECK-NEXT: load %s, %s* ret %s %l ; CHECK-NEXT: ret %s } @@ -781,41 +810,41 @@ define double @test71(double *%p, i64 %i) { %o = shl i64 %i, 5 ; CHECK-NEXT: shl i64 %i, 2 %q = bitcast double* %p to i8* - %pp = getelementptr i8* %q, i64 %o -; CHECK-NEXT: getelementptr double* + %pp = getelementptr i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr double, double* %r = bitcast i8* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } define double @test72(double *%p, i32 %i) { ; CHECK-LABEL: @test72( - %so = mul nsw i32 %i, 8 + %so = shl nsw i32 %i, 3 %o = sext i32 %so to i64 ; CHECK-NEXT: sext i32 %i to i64 %q = bitcast double* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o -; CHECK-NEXT: getelementptr inbounds double* + %pp = getelementptr inbounds i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr inbounds double, double* %r = bitcast i8* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } define double @test73(double *%p, i128 %i) { ; CHECK-LABEL: @test73( - %lo = mul nsw i128 %i, 8 + %lo = shl nsw i128 %i, 3 %o = trunc i128 %lo to i64 ; CHECK-NEXT: trunc i128 %i to i64 %q = bitcast double* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o -; CHECK-NEXT: getelementptr double* + %pp = getelementptr inbounds i8, i8* %q, i64 %o +; CHECK-NEXT: getelementptr double, double* %r = bitcast i8* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } @@ -823,11 +852,11 @@ define double @test73(double *%p, i128 %i) { define double @test74(double *%p, i64 %i) { ; CHECK-LABEL: @test74( %q = bitcast double* %p to i64* - %pp = getelementptr inbounds i64* %q, i64 %i -; CHECK-NEXT: getelementptr inbounds double* + %pp = getelementptr inbounds i64, i64* %q, i64 %i +; CHECK-NEXT: getelementptr inbounds double, double* %r = bitcast i64* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } @@ -839,7 +868,7 @@ define i32* @test75(i32* %p, i32 %x) { %z = sext i32 %y to i64 ; CHECK-NEXT: sext i32 %y to i64 %q = bitcast i32* %p to i8* - %r = getelementptr i8* %q, i64 %z + %r = getelementptr i8, i8* %q, i64 %z %s = bitcast i8* %r to i32* ret i32* %s } @@ -850,11 +879,11 @@ define %s @test76(%s *%p, i64 %i, i64 %j) { %o2 = mul nsw i64 %o, %j ; CHECK-NEXT: %o2 = mul i64 %i, %j %q = bitcast %s* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o2 -; CHECK-NEXT: getelementptr %s* %p, i64 %o2 + %pp = getelementptr inbounds i8, i8* %q, i64 %o2 +; CHECK-NEXT: getelementptr %s, %s* %p, i64 %o2 %r = bitcast i8* %pp to %s* - %l = load %s* %r -; CHECK-NEXT: load %s* + %l = load %s, %s* %r +; CHECK-NEXT: load %s, %s* ret %s %l ; CHECK-NEXT: ret %s } @@ -866,11 +895,11 @@ define %s @test77(%s *%p, i64 %i, i64 %j) { ; CHECK-NEXT: %o = mul nsw i64 %i, 3 ; CHECK-NEXT: %o2 = mul nsw i64 %o, %j %q = bitcast %s* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %o2 -; CHECK-NEXT: getelementptr inbounds %s* %p, i64 %o2 + %pp = getelementptr inbounds i8, i8* %q, i64 %o2 +; CHECK-NEXT: getelementptr inbounds %s, %s* %p, i64 %o2 %r = bitcast i8* %pp to %s* - %l = load %s* %r -; CHECK-NEXT: load %s* + %l = load %s, %s* %r +; CHECK-NEXT: load %s, %s* ret %s %l ; CHECK-NEXT: ret %s } @@ -894,11 +923,11 @@ define %s @test78(%s *%p, i64 %i, i64 %j, i32 %k, i32 %l, i128 %m, i128 %n) { %h = mul nsw i64 %g, %j ; CHECK-NEXT: mul i64 %g, %j %q = bitcast %s* %p to i8* - %pp = getelementptr inbounds i8* %q, i64 %h -; CHECK-NEXT: getelementptr %s* %p, i64 %h + %pp = getelementptr inbounds i8, i8* %q, i64 %h +; CHECK-NEXT: getelementptr %s, %s* %p, i64 %h %r = bitcast i8* %pp to %s* - %load = load %s* %r -; CHECK-NEXT: load %s* + %load = load %s, %s* %r +; CHECK-NEXT: load %s, %s* ret %s %load ; CHECK-NEXT: ret %s } @@ -911,63 +940,63 @@ define %s @test79(%s *%p, i64 %i, i32 %j) { %c = mul i32 %b, %j %q = bitcast %s* %p to i8* ; CHECK: bitcast - %pp = getelementptr inbounds i8* %q, i32 %c + %pp = getelementptr inbounds i8, i8* %q, i32 %c %r = bitcast i8* %pp to %s* - %l = load %s* %r + %l = load %s, %s* %r ret %s %l } define double @test80([100 x double]* %p, i32 %i) { ; CHECK-LABEL: @test80( - %tmp = mul nsw i32 %i, 8 + %tmp = shl nsw i32 %i, 3 ; CHECK-NEXT: sext i32 %i to i64 %q = bitcast [100 x double]* %p to i8* - %pp = getelementptr i8* %q, i32 %tmp -; CHECK-NEXT: getelementptr [100 x double]* + %pp = getelementptr i8, i8* %q, i32 %tmp +; CHECK-NEXT: getelementptr [100 x double], [100 x double]* %r = bitcast i8* %pp to double* - %l = load double* %r -; CHECK-NEXT: load double* + %l = load double, double* %r +; CHECK-NEXT: load double, double* ret double %l ; CHECK-NEXT: ret double } define double @test80_addrspacecast([100 x double] addrspace(1)* %p, i32 %i) { ; CHECK-LABEL: @test80_addrspacecast( -; CHECK-NEXT: getelementptr [100 x double] addrspace(1)* %p -; CHECK-NEXT: load double addrspace(1)* +; CHECK-NEXT: getelementptr [100 x double], [100 x double] addrspace(1)* %p +; CHECK-NEXT: load double, double addrspace(1)* ; CHECK-NEXT: ret double - %tmp = mul nsw i32 %i, 8 + %tmp = shl nsw i32 %i, 3 %q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)* - %pp = getelementptr i8 addrspace(2)* %q, i32 %tmp + %pp = getelementptr i8, i8 addrspace(2)* %q, i32 %tmp %r = addrspacecast i8 addrspace(2)* %pp to double addrspace(1)* - %l = load double addrspace(1)* %r + %l = load double, double addrspace(1)* %r ret double %l } define double @test80_addrspacecast_2([100 x double] addrspace(1)* %p, i32 %i) { ; CHECK-LABEL: @test80_addrspacecast_2( -; CHECK-NEXT: getelementptr [100 x double] addrspace(1)* +; CHECK-NEXT: getelementptr [100 x double], [100 x double] addrspace(1)* ; CHECK-NEXT: addrspacecast double addrspace(1)* -; CHECK-NEXT: load double addrspace(3)* +; CHECK-NEXT: load double, double addrspace(3)* ; CHECK-NEXT: ret double - %tmp = mul nsw i32 %i, 8 + %tmp = shl nsw i32 %i, 3 %q = addrspacecast [100 x double] addrspace(1)* %p to i8 addrspace(2)* - %pp = getelementptr i8 addrspace(2)* %q, i32 %tmp + %pp = getelementptr i8, i8 addrspace(2)* %q, i32 %tmp %r = addrspacecast i8 addrspace(2)* %pp to double addrspace(3)* - %l = load double addrspace(3)* %r + %l = load double, double addrspace(3)* %r ret double %l } define double @test80_as1([100 x double] addrspace(1)* %p, i16 %i) { ; CHECK-LABEL: @test80_as1( - %tmp = mul nsw i16 %i, 8 + %tmp = shl nsw i16 %i, 3 ; 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)* + %pp = getelementptr i8, i8 addrspace(1)* %q, i16 %tmp +; CHECK-NEXT: getelementptr [100 x double], [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)* + %l = load double, double addrspace(1)* %r +; CHECK-NEXT: load double, double addrspace(1)* ret double %l ; CHECK-NEXT: ret double } @@ -975,9 +1004,9 @@ define double @test80_as1([100 x double] addrspace(1)* %p, i16 %i) { define double @test81(double *%p, float %f) { %i = fptosi float %f to i64 %q = bitcast double* %p to i8* - %pp = getelementptr i8* %q, i64 %i + %pp = getelementptr i8, i8* %q, i64 %i %r = bitcast i8* %pp to double* - %l = load double* %r + %l = load double, double* %r ret double %l } @@ -1004,7 +1033,107 @@ define i64 @test83(i16 %a, i64 %k) { ret i64 %sh_prom1 ; CHECK-LABEL: @test83( -; CHECK: %sub = add nsw i64 %k, 4294967295 +; CHECK: %sub = add i64 %k, 4294967295 ; CHECK: %sh_prom = trunc i64 %sub to i32 ; CHECK: %shl = shl i32 %conv, %sh_prom } + +define i8 @test84(i32 %a) { + %add = add nsw i32 %a, -16777216 + %shr = lshr exact i32 %add, 23 + %trunc = trunc i32 %shr to i8 + ret i8 %trunc + +; CHECK-LABEL: @test84( +; CHECK: [[ADD:%.*]] = add i32 %a, 2130706432 +; CHECK: [[SHR:%.*]] = lshr exact i32 [[ADD]], 23 +; CHECK: [[CST:%.*]] = trunc i32 [[SHR]] to i8 +} + +define i8 @test85(i32 %a) { + %add = add nuw i32 %a, -16777216 + %shr = lshr exact i32 %add, 23 + %trunc = trunc i32 %shr to i8 + ret i8 %trunc + +; CHECK-LABEL: @test85( +; CHECK: [[ADD:%.*]] = add i32 %a, 2130706432 +; CHECK: [[SHR:%.*]] = lshr exact i32 [[ADD]], 23 +; CHECK: [[CST:%.*]] = trunc i32 [[SHR]] to i8 +} + +; Overflow on a float to int or int to float conversion is undefined (PR21130). + +define i8 @overflow_fptosi() { + %i = fptosi double 1.56e+02 to i8 + ret i8 %i +; CHECK-LABEL: @overflow_fptosi( +; CHECK-NEXT: ret i8 undef +} + +define i8 @overflow_fptoui() { + %i = fptoui double 2.56e+02 to i8 + ret i8 %i +; CHECK-LABEL: @overflow_fptoui( +; CHECK-NEXT: ret i8 undef +} + +; The maximum float is approximately 2 ** 128 which is 3.4E38. +; The constant below is 4E38. Use a 130 bit integer to hold that +; number; 129-bits for the value + 1 bit for the sign. +define float @overflow_uitofp() { + %i = uitofp i130 400000000000000000000000000000000000000 to float + ret float %i +; CHECK-LABEL: @overflow_uitofp( +; CHECK-NEXT: ret float undef +} + +define float @overflow_sitofp() { + %i = sitofp i130 400000000000000000000000000000000000000 to float + ret float %i +; CHECK-LABEL: @overflow_sitofp( +; CHECK-NEXT: ret float undef +} + +define i32 @PR21388(i32* %v) { + %icmp = icmp slt i32* %v, null + %sext = sext i1 %icmp to i32 + ret i32 %sext +; CHECK-LABEL: @PR21388( +; CHECK-NEXT: %[[icmp:.*]] = icmp slt i32* %v, null +; CHECK-NEXT: %[[sext:.*]] = sext i1 %[[icmp]] to i32 +; CHECK-NEXT: ret i32 %[[sext]] +} + +define float @sitofp_zext(i16 %a) { +; CHECK-LABEL: @sitofp_zext( +; CHECK-NEXT: %[[sitofp:.*]] = uitofp i16 %a to float +; CHECK-NEXT: ret float %[[sitofp]] + %zext = zext i16 %a to i32 + %sitofp = sitofp i32 %zext to float + ret float %sitofp +} + +define i1 @PR23309(i32 %A, i32 %B) { +; CHECK-LABEL: @PR23309( +; CHECK-NEXT: %[[sub:.*]] = sub i32 %A, %B +; CHECK-NEXT: %[[and:.*]] = and i32 %[[sub]], 1 +; CHECK-NEXT: %[[cmp:.*]] = icmp ne i32 %[[and]], 0 +; CHECK-NEXT: ret i1 %[[cmp]] + %add = add i32 %A, -4 + %sub = sub nsw i32 %add, %B + %trunc = trunc i32 %sub to i1 + ret i1 %trunc +} + +define i1 @PR23309v2(i32 %A, i32 %B) { +; CHECK-LABEL: @PR23309v2( +; CHECK-NEXT: %[[sub:.*]] = add i32 %A, %B +; CHECK-NEXT: %[[and:.*]] = and i32 %[[sub]], 1 +; CHECK-NEXT: %[[cmp:.*]] = icmp ne i32 %[[and]], 0 +; CHECK-NEXT: ret i1 %[[cmp]] + %add = add i32 %A, -4 + %sub = add nuw i32 %add, %B + %trunc = trunc i32 %sub to i1 + ret i1 %trunc +}