1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
6 define i32 @shift1(i32 %A, i32 %B) {
7 ; CHECK-LABEL: @shift1(
8 ; CHECK-NEXT: ret i32 [[A:%.*]]
10 %C = lshr exact i32 %A, %B
11 %D = shl nuw i32 %C, %B
15 define i32 @shift2(i32 %A, i32 %B) {
16 ; CHECK-LABEL: @shift2(
17 ; CHECK-NEXT: [[C:%.*]] = lshr i32 [[A:%.*]], [[B:%.*]]
18 ; CHECK-NEXT: [[D:%.*]] = shl nuw i32 [[C]], [[B]]
19 ; CHECK-NEXT: ret i32 [[D]]
22 %D = shl nuw i32 %C, %B
26 define i32 @shift3(i32 %A, i32 %B) {
27 ; CHECK-LABEL: @shift3(
28 ; CHECK-NEXT: ret i32 [[A:%.*]]
30 %C = ashr exact i32 %A, %B
31 %D = shl nuw i32 %C, %B
35 define i32 @shift4(i32 %A, i32 %B) {
36 ; CHECK-LABEL: @shift4(
37 ; CHECK-NEXT: ret i32 [[A:%.*]]
39 %C = shl nuw i32 %A, %B
44 define i32 @shift5(i32 %A, i32 %B) {
45 ; CHECK-LABEL: @shift5(
46 ; CHECK-NEXT: ret i32 [[A:%.*]]
48 %C = shl nsw i32 %A, %B
53 define i32 @div1(i32 %V) {
55 ; CHECK-NEXT: ret i32 0
57 %A = udiv i32 %V, -2147483648
58 %B = udiv i32 %A, -2147483648
62 define i32 @div2(i32 %V) {
64 ; CHECK-NEXT: ret i32 0
67 %B = sdiv i32 %A, -2147483648