2016-05-21 04:55:17 +08:00
|
|
|
; This test makes sure that rem instructions are properly eliminated.
|
2002-05-06 13:43:36 +08:00
|
|
|
;
|
2013-05-11 17:01:28 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2008-03-06 14:48:30 +08:00
|
|
|
; END.
|
2002-05-06 13:43:36 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test1(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = srem i32 %A, 1 ; ISA constant 0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2002-05-06 13:43:36 +08:00
|
|
|
}
|
|
|
|
|
2008-03-06 14:48:30 +08:00
|
|
|
define i32 @test2(i32 %A) { ; 0 % X = 0, we don't need to preserve traps
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = srem i32 0, %A
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2003-02-19 03:28:47 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test3(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: [[AND:%.*]] = and i32 %A, 7
|
|
|
|
; CHECK-NEXT: ret i32 [[AND]]
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = urem i32 %A, 8
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2003-02-19 03:28:47 +08:00
|
|
|
}
|
2004-07-06 15:38:00 +08:00
|
|
|
|
2016-05-21 04:55:17 +08:00
|
|
|
define <2 x i32> @vec_power_of_2_constant_splat_divisor(<2 x i32> %A) {
|
|
|
|
; CHECK-LABEL: @vec_power_of_2_constant_splat_divisor(
|
2016-05-22 23:41:53 +08:00
|
|
|
; CHECK-NEXT: [[B:%.*]] = and <2 x i32> %A, <i32 7, i32 7>
|
2016-05-21 04:55:17 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[B]]
|
|
|
|
;
|
|
|
|
%B = urem <2 x i32> %A, <i32 8, i32 8>
|
|
|
|
ret <2 x i32> %B
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i19> @weird_vec_power_of_2_constant_splat_divisor(<2 x i19> %A) {
|
|
|
|
; CHECK-LABEL: @weird_vec_power_of_2_constant_splat_divisor(
|
2016-05-22 23:41:53 +08:00
|
|
|
; CHECK-NEXT: [[B:%.*]] = and <2 x i19> %A, <i19 7, i19 7>
|
2016-05-21 04:55:17 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i19> [[B]]
|
|
|
|
;
|
|
|
|
%B = urem <2 x i19> %A, <i19 8, i19 8>
|
|
|
|
ret <2 x i19> %B
|
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i1 @test3a(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3a(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: [[AND:%.*]] = and i32 %A, 7
|
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[AND]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = srem i32 %A, -8
|
|
|
|
%C = icmp ne i32 %B, 0
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i1 %C
|
2004-07-06 15:38:00 +08:00
|
|
|
}
|
2004-12-13 05:40:22 +08:00
|
|
|
|
2016-07-23 04:11:08 +08:00
|
|
|
define <2 x i1> @test3a_vec(<2 x i32> %A) {
|
|
|
|
; CHECK-LABEL: @test3a_vec(
|
2016-08-04 03:48:40 +08:00
|
|
|
; CHECK-NEXT: [[B1:%.*]] = and <2 x i32> %A, <i32 7, i32 7>
|
|
|
|
; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B1]], zeroinitializer
|
2016-07-23 04:11:08 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i1> [[C]]
|
|
|
|
;
|
|
|
|
%B = srem <2 x i32> %A, <i32 -8, i32 -8>
|
|
|
|
%C = icmp ne <2 x i32> %B, zeroinitializer
|
|
|
|
ret <2 x i1> %C
|
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test4(i32 %X, i1 %C) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 %C, i32 0, i32 7
|
|
|
|
; CHECK-NEXT: [[AND:%.*]] = and i32 [[SEL]], %X
|
2008-03-06 14:48:30 +08:00
|
|
|
%V = select i1 %C, i32 1, i32 8
|
|
|
|
%R = urem i32 %X, %V
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %R
|
2004-12-13 05:40:22 +08:00
|
|
|
}
|
2006-02-05 15:52:47 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test5(i32 %X, i8 %B) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2013-05-11 17:01:28 +08:00
|
|
|
; 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]]
|
2008-03-06 14:48:30 +08:00
|
|
|
%shift.upgrd.1 = zext i8 %B to i32
|
|
|
|
%Amt = shl i32 32, %shift.upgrd.1
|
|
|
|
%V = urem i32 %X, %Amt
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %V
|
2006-02-05 15:52:47 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test6(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 undef
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = srem i32 %A, 0 ;; undef
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %B
|
2006-02-28 13:30:48 +08:00
|
|
|
}
|
2006-02-28 13:48:56 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test7(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = mul i32 %A, 8
|
|
|
|
%C = srem i32 %B, 4
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2006-02-28 13:48:56 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test8(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test8(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = shl i32 %A, 4
|
|
|
|
%C = srem i32 %B, 8
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2006-02-28 13:48:56 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test9(i32 %A) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test9(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%B = mul i32 %A, 64
|
|
|
|
%C = urem i32 %B, 32
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %C
|
2006-02-28 13:48:56 +08:00
|
|
|
}
|
2006-03-02 14:50:04 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test10(i8 %c) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test10(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%tmp.1 = zext i8 %c to i32
|
|
|
|
%tmp.2 = mul i32 %tmp.1, 4
|
|
|
|
%tmp.3 = sext i32 %tmp.2 to i64
|
|
|
|
%tmp.5 = urem i64 %tmp.3, 4
|
|
|
|
%tmp.6 = trunc i64 %tmp.5 to i32
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %tmp.6
|
2006-03-02 14:50:04 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test11(i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test11(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%tmp.1 = and i32 %i, -2
|
|
|
|
%tmp.3 = mul i32 %tmp.1, 2
|
|
|
|
%tmp.5 = urem i32 %tmp.3, 4
|
|
|
|
ret i32 %tmp.5
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test12(i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test12(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2008-03-06 14:48:30 +08:00
|
|
|
%tmp.1 = and i32 %i, -4
|
|
|
|
%tmp.5 = srem i32 %tmp.1, 2
|
2008-03-01 17:15:35 +08:00
|
|
|
ret i32 %tmp.5
|
2006-03-02 14:50:04 +08:00
|
|
|
}
|
2010-11-18 03:11:46 +08:00
|
|
|
|
|
|
|
define i32 @test13(i32 %i) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test13(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: ret i32 0
|
2010-11-18 03:11:46 +08:00
|
|
|
%x = srem i32 %i, %i
|
|
|
|
ret i32 %x
|
|
|
|
}
|
2013-05-11 17:01:28 +08:00
|
|
|
|
|
|
|
define i64 @test14(i64 %x, i32 %y) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test14(
|
2013-05-11 17:01:28 +08:00
|
|
|
; CHECK-NEXT: [[SHL:%.*]] = shl i32 1, %y
|
|
|
|
; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[SHL]] to i64
|
2014-06-03 06:01:04 +08:00
|
|
|
; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[ZEXT]], -1
|
2013-05-11 17:01:28 +08:00
|
|
|
; 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
|
|
|
|
}
|
2013-05-12 08:07:05 +08:00
|
|
|
|
|
|
|
define i64 @test15(i32 %x, i32 %y) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test15(
|
2013-05-12 08:07:05 +08:00
|
|
|
; 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
|
|
|
|
}
|
2013-05-19 03:30:37 +08:00
|
|
|
|
|
|
|
define i32 @test16(i32 %x, i32 %y) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test16(
|
2013-05-19 03:30:37 +08:00
|
|
|
; 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
|
|
|
|
}
|
2013-07-13 09:16:47 +08:00
|
|
|
|
|
|
|
define i32 @test17(i32 %X) {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test17(
|
2013-07-13 09:16:47 +08:00
|
|
|
; CHECK-NEXT: icmp ne i32 %X, 1
|
|
|
|
; CHECK-NEXT: zext i1
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
%A = urem i32 1, %X
|
|
|
|
ret i32 %A
|
|
|
|
}
|
2013-07-31 05:01:36 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2014-01-19 23:24:22 +08:00
|
|
|
|
|
|
|
define <2 x i64> @test20(<2 x i64> %X, <2 x i1> %C) {
|
|
|
|
; CHECK-LABEL: @test20(
|
|
|
|
; CHECK-NEXT: select <2 x i1> %C, <2 x i64> <i64 1, i64 2>, <2 x i64> zeroinitializer
|
|
|
|
; CHECK-NEXT: ret <2 x i64>
|
|
|
|
%V = select <2 x i1> %C, <2 x i64> <i64 1, i64 2>, <2 x i64> <i64 8, i64 9>
|
|
|
|
%R = urem <2 x i64> %V, <i64 2, i64 3>
|
|
|
|
ret <2 x i64> %R
|
|
|
|
}
|
2016-06-06 05:17:00 +08:00
|
|
|
|
|
|
|
define i32 @test21(i1 %c0, i32* %val) {
|
|
|
|
; CHECK-LABEL: @test21(
|
|
|
|
entry:
|
|
|
|
br i1 %c0, label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK-NEXT: %v = load volatile i32, i32* %val, align 4
|
|
|
|
; CHECK-NEXT: %phitmp = srem i32 %v, 5
|
|
|
|
|
|
|
|
%v = load volatile i32, i32* %val
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
; CHECK: if.end:
|
|
|
|
; CHECK-NEXT: %lhs = phi i32 [ %phitmp, %if.then ], [ 0, %entry ]
|
|
|
|
; CHECK-NEXT: ret i32 %lhs
|
|
|
|
|
|
|
|
%lhs = phi i32 [ %v, %if.then ], [ 5, %entry ]
|
|
|
|
%rem = srem i32 %lhs, 5
|
|
|
|
ret i32 %rem
|
|
|
|
}
|
2016-06-06 05:17:04 +08:00
|
|
|
|
|
|
|
@a = common global [5 x i16] zeroinitializer, align 2
|
|
|
|
@b = common global i16 0, align 2
|
|
|
|
|
|
|
|
define i32 @pr27968_0(i1 %c0, i32* %val) {
|
|
|
|
; CHECK-LABEL: @pr27968_0(
|
|
|
|
entry:
|
|
|
|
br i1 %c0, label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%v = load volatile i32, i32* %val
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK-NOT: srem
|
|
|
|
; CHECK: br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
%lhs = phi i32 [ %v, %if.then ], [ 5, %entry ]
|
|
|
|
br i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b), label %rem.is.safe, label %rem.is.unsafe
|
|
|
|
|
|
|
|
rem.is.safe:
|
|
|
|
; CHECK: rem.is.safe:
|
|
|
|
; CHECK-NEXT: %rem = srem i32 %lhs, zext (i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b) to i32)
|
|
|
|
; CHECK-NEXT: ret i32 %rem
|
|
|
|
|
|
|
|
%rem = srem i32 %lhs, zext (i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b) to i32)
|
|
|
|
ret i32 %rem
|
|
|
|
|
|
|
|
rem.is.unsafe:
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @pr27968_1(i1 %c0, i1 %always_false, i32* %val) {
|
|
|
|
; CHECK-LABEL: @pr27968_1(
|
|
|
|
entry:
|
|
|
|
br i1 %c0, label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%v = load volatile i32, i32* %val
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK-NOT: srem
|
|
|
|
; CHECK: br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
%lhs = phi i32 [ %v, %if.then ], [ 5, %entry ]
|
|
|
|
br i1 %always_false, label %rem.is.safe, label %rem.is.unsafe
|
|
|
|
|
|
|
|
rem.is.safe:
|
|
|
|
%rem = srem i32 %lhs, -2147483648
|
|
|
|
ret i32 %rem
|
|
|
|
|
|
|
|
; CHECK: rem.is.safe:
|
|
|
|
; CHECK-NEXT: %rem = srem i32 %lhs, -2147483648
|
|
|
|
; CHECK-NEXT: ret i32 %rem
|
|
|
|
|
|
|
|
rem.is.unsafe:
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @pr27968_2(i1 %c0, i32* %val) {
|
|
|
|
; CHECK-LABEL: @pr27968_2(
|
|
|
|
entry:
|
|
|
|
br i1 %c0, label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%v = load volatile i32, i32* %val
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK-NOT: urem
|
|
|
|
; CHECK: br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
%lhs = phi i32 [ %v, %if.then ], [ 5, %entry ]
|
|
|
|
br i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b), label %rem.is.safe, label %rem.is.unsafe
|
|
|
|
|
|
|
|
rem.is.safe:
|
|
|
|
; CHECK: rem.is.safe:
|
|
|
|
; CHECK-NEXT: %rem = urem i32 %lhs, zext (i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b) to i32)
|
|
|
|
; CHECK-NEXT: ret i32 %rem
|
|
|
|
|
|
|
|
%rem = urem i32 %lhs, zext (i1 icmp eq (i16* getelementptr inbounds ([5 x i16], [5 x i16]* @a, i64 0, i64 4), i16* @b) to i32)
|
|
|
|
ret i32 %rem
|
|
|
|
|
|
|
|
rem.is.unsafe:
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @pr27968_3(i1 %c0, i1 %always_false, i32* %val) {
|
|
|
|
; CHECK-LABEL: @pr27968_3(
|
|
|
|
entry:
|
|
|
|
br i1 %c0, label %if.then, label %if.end
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
%v = load volatile i32, i32* %val
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
; CHECK: if.then:
|
|
|
|
; CHECK-NEXT: %v = load volatile i32, i32* %val, align 4
|
|
|
|
; CHECK-NEXT: %phitmp = and i32 %v, 2147483647
|
|
|
|
; CHECK-NEXT: br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
%lhs = phi i32 [ %v, %if.then ], [ 5, %entry ]
|
|
|
|
br i1 %always_false, label %rem.is.safe, label %rem.is.unsafe
|
|
|
|
|
|
|
|
rem.is.safe:
|
|
|
|
%rem = urem i32 %lhs, -2147483648
|
|
|
|
ret i32 %rem
|
|
|
|
|
|
|
|
rem.is.unsafe:
|
|
|
|
ret i32 0
|
|
|
|
}
|