1 ; RUN: opt < %s -instsimplify -S | FileCheck %s
5 define i32 @shift1(i32 %A, i32 %B) {
6 ; CHECK-LABEL: @shift1(
7 ; CHECK-NEXT: ret i32 %A
9 %C = lshr exact i32 %A, %B
10 %D = shl nuw i32 %C, %B
14 define i32 @shift2(i32 %A, i32 %B) {
15 ; CHECK-LABEL: @shift2(
16 ; CHECK-NEXT: [[C:%.*]] = lshr i32 %A, %B
17 ; CHECK-NEXT: [[D:%.*]] = shl nuw i32 [[C]], %B
18 ; CHECK-NEXT: ret i32 [[D]]
21 %D = shl nuw i32 %C, %B
25 define i32 @shift3(i32 %A, i32 %B) {
26 ; CHECK-LABEL: @shift3(
27 ; CHECK-NEXT: ret i32 %A
29 %C = ashr exact i32 %A, %B
30 %D = shl nuw i32 %C, %B
34 define i32 @shift4(i32 %A, i32 %B) {
35 ; CHECK-LABEL: @shift4(
36 ; CHECK-NEXT: ret i32 %A
38 %C = shl nuw i32 %A, %B
43 define i32 @shift5(i32 %A, i32 %B) {
44 ; CHECK-LABEL: @shift5(
45 ; CHECK-NEXT: ret i32 %A
47 %C = shl nsw i32 %A, %B
52 define i32 @div1(i32 %V) {
54 ; CHECK-NEXT: ret i32 0
56 %A = udiv i32 %V, -2147483648
57 %B = udiv i32 %A, -2147483648
61 define i32 @div2(i32 %V) {
63 ; CHECK-NEXT: ret i32 0
66 %B = sdiv i32 %A, -2147483648