Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt -S -instcombine < %s | FileCheck %s
      2 
      3 declare void @foo()
      4 
      5 define void @test1(i32 %a, i32 %b) nounwind {
      6   %1 = icmp slt i32 %a, 0
      7   %2 = icmp slt i32 %b, 0
      8   %or.cond = or i1 %1, %2
      9   br i1 %or.cond, label %if.then, label %if.end
     10 
     11 ; CHECK: @test1
     12 ; CHECK-NEXT: %1 = or i32 %a, %b
     13 ; CHECK-NEXT: %2 = icmp slt i32 %1, 0
     14 ; CHECK-NEXT: br
     15 
     16 if.then:
     17   tail call void @foo() nounwind
     18   ret void
     19 
     20 if.end:
     21   ret void
     22 }
     23 
     24 define void @test2(i32 %a, i32 %b) nounwind {
     25   %1 = icmp sgt i32 %a, -1
     26   %2 = icmp sgt i32 %b, -1
     27   %or.cond = or i1 %1, %2
     28   br i1 %or.cond, label %if.then, label %if.end
     29 
     30 ; CHECK: @test2
     31 ; CHECK-NEXT: %1 = and i32 %a, %b
     32 ; CHECK-NEXT: %2 = icmp sgt i32 %1, -1
     33 ; CHECK-NEXT: br
     34 
     35 if.then:
     36   tail call void @foo() nounwind
     37   ret void
     38 
     39 if.end:
     40   ret void
     41 }
     42 
     43 define void @test3(i32 %a, i32 %b) nounwind {
     44   %1 = icmp slt i32 %a, 0
     45   %2 = icmp slt i32 %b, 0
     46   %or.cond = and i1 %1, %2
     47   br i1 %or.cond, label %if.then, label %if.end
     48 
     49 ; CHECK: @test3
     50 ; CHECK-NEXT: %1 = and i32 %a, %b
     51 ; CHECK-NEXT: %2 = icmp slt i32 %1, 0
     52 ; CHECK-NEXT: br
     53 
     54 if.then:
     55   tail call void @foo() nounwind
     56   ret void
     57 
     58 if.end:
     59   ret void
     60 }
     61 
     62 define void @test4(i32 %a, i32 %b) nounwind {
     63   %1 = icmp sgt i32 %a, -1
     64   %2 = icmp sgt i32 %b, -1
     65   %or.cond = and i1 %1, %2
     66   br i1 %or.cond, label %if.then, label %if.end
     67 
     68 ; CHECK: @test4
     69 ; CHECK-NEXT: %1 = or i32 %a, %b
     70 ; CHECK-NEXT: %2 = icmp sgt i32 %1, -1
     71 ; CHECK-NEXT: br
     72 
     73 if.then:
     74   tail call void @foo() nounwind
     75   ret void
     76 
     77 if.end:
     78   ret void
     79 }
     80