Home | History | Annotate | Download | only in InstCombine
      1 ; This file contains various testcases that check to see that instcombine
      2 ; is narrowing computations when possible.
      3 ; RUN: opt < %s -instcombine -S | \
      4 ; RUN:    grep "ret i1 false"
      5 
      6 ; test1 - Eliminating the casts in this testcase (by narrowing the AND
      7 ; operation) allows instcombine to realize the function always returns false.
      8 ;
      9 define i1 @test1(i32 %A, i32 %B) {
     10         %C1 = icmp slt i32 %A, %B               ; <i1> [#uses=1]
     11         %ELIM1 = zext i1 %C1 to i32             ; <i32> [#uses=1]
     12         %C2 = icmp sgt i32 %A, %B               ; <i1> [#uses=1]
     13         %ELIM2 = zext i1 %C2 to i32             ; <i32> [#uses=1]
     14         %C3 = and i32 %ELIM1, %ELIM2            ; <i32> [#uses=1]
     15         %ELIM3 = trunc i32 %C3 to i1            ; <i1> [#uses=1]
     16         ret i1 %ELIM3
     17 }
     18 
     19