1 ; This test makes sure that these instructions are properly eliminated.
3 ; RUN: opt < %s -instcombine -S | not grep rem
6 define i32 @test1(i32 %A) {
7 %B = srem i32 %A, 1 ; ISA constant 0
11 define i32 @test2(i32 %A) { ; 0 % X = 0, we don't need to preserve traps
16 define i32 @test3(i32 %A) {
21 define i1 @test3a(i32 %A) {
23 %C = icmp ne i32 %B, 0
27 define i32 @test4(i32 %X, i1 %C) {
28 %V = select i1 %C, i32 1, i32 8
33 define i32 @test5(i32 %X, i8 %B) {
34 %shift.upgrd.1 = zext i8 %B to i32
35 %Amt = shl i32 32, %shift.upgrd.1
36 %V = urem i32 %X, %Amt
40 define i32 @test6(i32 %A) {
41 %B = srem i32 %A, 0 ;; undef
45 define i32 @test7(i32 %A) {
51 define i32 @test8(i32 %A) {
57 define i32 @test9(i32 %A) {
63 define i32 @test10(i8 %c) {
64 %tmp.1 = zext i8 %c to i32
65 %tmp.2 = mul i32 %tmp.1, 4
66 %tmp.3 = sext i32 %tmp.2 to i64
67 %tmp.5 = urem i64 %tmp.3, 4
68 %tmp.6 = trunc i64 %tmp.5 to i32
72 define i32 @test11(i32 %i) {
73 %tmp.1 = and i32 %i, -2
74 %tmp.3 = mul i32 %tmp.1, 2
75 %tmp.5 = urem i32 %tmp.3, 4
79 define i32 @test12(i32 %i) {
80 %tmp.1 = and i32 %i, -4
81 %tmp.5 = srem i32 %tmp.1, 2