1; RUN: opt < %s -correlated-propagation -S | FileCheck %s 2 3; CHECK-LABEL: @test_nop 4define void @test_nop(i32 %n) { 5; CHECK: udiv i32 %n, 100 6 %div = udiv i32 %n, 100 7 ret void 8} 9 10; CHECK-LABEL: @test1( 11define void @test1(i32 %n) { 12entry: 13 %cmp = icmp ule i32 %n, 65535 14 br i1 %cmp, label %bb, label %exit 15 16bb: 17; CHECK: urem i16 18 %div = urem i32 %n, 100 19 br label %exit 20 21exit: 22 ret void 23} 24 25; CHECK-LABEL: @test2( 26define void @test2(i32 %n) { 27entry: 28 %cmp = icmp ule i32 %n, 65536 29 br i1 %cmp, label %bb, label %exit 30 31bb: 32; CHECK: urem i32 %n, 100 33 %div = urem i32 %n, 100 34 br label %exit 35 36exit: 37 ret void 38} 39 40; CHECK-LABEL: @test3( 41define void @test3(i32 %m, i32 %n) { 42entry: 43 %cmp1 = icmp ult i32 %m, 65535 44 %cmp2 = icmp ult i32 %n, 65535 45 %cmp = and i1 %cmp1, %cmp2 46 br i1 %cmp, label %bb, label %exit 47 48bb: 49; CHECK: urem i16 50 %div = urem i32 %m, %n 51 br label %exit 52 53exit: 54 ret void 55} 56 57; CHECK-LABEL: @test4( 58define void @test4(i32 %m, i32 %n) { 59entry: 60 %cmp1 = icmp ult i32 %m, 65535 61 %cmp2 = icmp ule i32 %n, 65536 62 %cmp = and i1 %cmp1, %cmp2 63 br i1 %cmp, label %bb, label %exit 64 65bb: 66; CHECK: urem i32 %m, %n 67 %div = urem i32 %m, %n 68 br label %exit 69 70exit: 71 ret void 72} 73 74; CHECK-LABEL: @test5 75define void @test5(i32 %n) { 76 %trunc = and i32 %n, 63 77 ; CHECK: urem i8 78 %div = urem i32 %trunc, 42 79 ret void 80} 81 82; CHECK-LABEL: @test6 83define void @test6(i32 %n) { 84entry: 85 %cmp = icmp ule i32 %n, 255 86 br i1 %cmp, label %bb, label %exit 87 88bb: 89; CHECK: urem i8 90 %div = srem i32 %n, 100 91 br label %exit 92 93exit: 94 ret void 95} 96 97; CHECK-LABEL: @non_power_of_2 98define void @non_power_of_2(i24 %n) { 99 %div = urem i24 %n, 42 100 ret void 101} 102