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