Home | History | Annotate | Download | only in InstSimplify
      1 ; RUN: opt < %s -instsimplify -S | FileCheck %s
      2 
      3 ; PR8862
      4 
      5 ; CHECK: @shift1
      6 ; CHECK: ret i32 %A
      7 define i32 @shift1(i32 %A, i32 %B) {
      8   %C = lshr exact i32 %A, %B
      9   %D = shl nuw i32 %C, %B
     10   ret i32 %D
     11 }
     12 
     13 ; CHECK: @shift2
     14 ; CHECK: lshr
     15 ; CHECK: ret i32 %D
     16 define i32 @shift2(i32 %A, i32 %B) {
     17   %C = lshr i32 %A, %B
     18   %D = shl nuw i32 %C, %B
     19   ret i32 %D
     20 }
     21 
     22 ; CHECK: @shift3
     23 ; CHECK: ret i32 %A
     24 define i32 @shift3(i32 %A, i32 %B) {
     25   %C = ashr exact i32 %A, %B
     26   %D = shl nuw i32 %C, %B
     27   ret i32 %D
     28 }
     29 
     30 ; CHECK: @shift4
     31 ; CHECK: ret i32 %A
     32 define i32 @shift4(i32 %A, i32 %B) {
     33   %C = shl nuw i32 %A, %B
     34   %D = lshr i32 %C, %B
     35   ret i32 %D
     36 }
     37 
     38 ; CHECK: @shift5
     39 ; CHECK: ret i32 %A
     40 define i32 @shift5(i32 %A, i32 %B) {
     41   %C = shl nsw i32 %A, %B
     42   %D = ashr i32 %C, %B
     43   ret i32 %D
     44 }
     45