1; RUN: opt < %s -instcombine -S | FileCheck %s 2 3; Test an already canonical branch to make sure we don't flip those. 4define i32 @test0(i32 %X, i32 %Y) { 5 %C = icmp eq i32 %X, %Y 6 br i1 %C, label %T, label %F, !prof !0 7 8; CHECK-LABEL: @test0( 9; CHECK: %C = icmp eq i32 %X, %Y 10; CHECK: br i1 %C, label %T, label %F 11 12T: 13 ret i32 12 14F: 15 ret i32 123 16} 17 18define i32 @test1(i32 %X, i32 %Y) { 19 %C = icmp ne i32 %X, %Y 20 br i1 %C, label %T, label %F, !prof !1 21 22; CHECK-LABEL: @test1( 23; CHECK: %C = icmp eq i32 %X, %Y 24; CHECK: br i1 %C, label %F, label %T 25 26T: 27 ret i32 12 28F: 29 ret i32 123 30} 31 32define i32 @test2(i32 %X, i32 %Y) { 33 %C = icmp ule i32 %X, %Y 34 br i1 %C, label %T, label %F, !prof !2 35 36; CHECK-LABEL: @test2( 37; CHECK: %C = icmp ugt i32 %X, %Y 38; CHECK: br i1 %C, label %F, label %T 39 40T: 41 ret i32 12 42F: 43 ret i32 123 44} 45 46define i32 @test3(i32 %X, i32 %Y) { 47 %C = icmp uge i32 %X, %Y 48 br i1 %C, label %T, label %F, !prof !3 49 50; CHECK-LABEL: @test3( 51; CHECK: %C = icmp ult i32 %X, %Y 52; CHECK: br i1 %C, label %F, label %T 53 54T: 55 ret i32 12 56F: 57 ret i32 123 58} 59 60!0 = !{!"branch_weights", i32 1, i32 2} 61!1 = !{!"branch_weights", i32 3, i32 4} 62!2 = !{!"branch_weights", i32 5, i32 6} 63!3 = !{!"branch_weights", i32 7, i32 8} 64; Base case shouldn't change. 65; CHECK: !0 = {{.*}} i32 1, i32 2} 66; Ensure that the branch metadata is reversed to match the reversals above. 67; CHECK: !1 = {{.*}} i32 4, i32 3} 68; CHECK: !2 = {{.*}} i32 6, i32 5} 69; CHECK: !3 = {{.*}} i32 8, i32 7} 70