Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt < %s -instcombine -S | not grep call.*bswap
      2 
      3 define i1 @test1(i16 %tmp2) {
      4         %tmp10 = call i16 @llvm.bswap.i16( i16 %tmp2 )
      5         %tmp = icmp eq i16 %tmp10, 1
      6         ret i1 %tmp
      7 }
      8 
      9 define i1 @test2(i32 %tmp) {
     10         %tmp34 = tail call i32 @llvm.bswap.i32( i32 %tmp )
     11         %tmp.upgrd.1 = icmp eq i32 %tmp34, 1
     12         ret i1 %tmp.upgrd.1
     13 }
     14 
     15 declare i32 @llvm.bswap.i32(i32)
     16 
     17 define i1 @test3(i64 %tmp) {
     18         %tmp34 = tail call i64 @llvm.bswap.i64( i64 %tmp )
     19         %tmp.upgrd.2 = icmp eq i64 %tmp34, 1
     20         ret i1 %tmp.upgrd.2
     21 }
     22 
     23 declare i64 @llvm.bswap.i64(i64)
     24 
     25 declare i16 @llvm.bswap.i16(i16)
     26 
     27 ; rdar://5992453
     28 ; A & 255
     29 define i32 @test4(i32 %a) nounwind  {
     30 entry:
     31 	%tmp2 = tail call i32 @llvm.bswap.i32( i32 %a )	
     32 	%tmp4 = lshr i32 %tmp2, 24
     33 	ret i32 %tmp4
     34 }
     35 
     36 ; A
     37 define i32 @test5(i32 %a) nounwind  {
     38 entry:
     39 	%tmp2 = tail call i32 @llvm.bswap.i32( i32 %a )
     40 	%tmp4 = tail call i32 @llvm.bswap.i32( i32 %tmp2 )
     41 	ret i32 %tmp4
     42 }
     43 
     44 ; a >> 24
     45 define i32 @test6(i32 %a) nounwind  {
     46 entry:
     47 	%tmp2 = tail call i32 @llvm.bswap.i32( i32 %a )	
     48 	%tmp4 = and i32 %tmp2, 255
     49 	ret i32 %tmp4
     50 }
     51 
     52 ; PR5284
     53 define i16 @test7(i32 %A) {
     54   %B = tail call i32 @llvm.bswap.i32(i32 %A) nounwind 
     55   %C = trunc i32 %B to i16
     56   %D = tail call i16 @llvm.bswap.i16(i16 %C) nounwind
     57   ret i16 %D
     58 }
     59 
     60 define i16 @test8(i64 %A) {
     61   %B = tail call i64 @llvm.bswap.i64(i64 %A) nounwind 
     62   %C = trunc i64 %B to i16
     63   %D = tail call i16 @llvm.bswap.i16(i16 %C) nounwind
     64   ret i16 %D
     65 }
     66 
     67 ; Misc: Fold bswap(undef) to undef.
     68 define i64 @foo() {
     69   %a = call i64 @llvm.bswap.i64(i64 undef)
     70   ret i64 %a
     71 }
     72