Skip to content

Commit ad02eb5

Browse files
committed
[InstCombine] Pre-commit tests (NFC)
1 parent 31b45a9 commit ad02eb5

File tree

1 file changed

+28
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+28
-0
lines changed

llvm/test/Transforms/InstCombine/lshr.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,34 @@ define i32 @shl_sub_lshr(i32 %x, i32 %c, i32 %y) {
464464
ret i32 %lshr
465465
}
466466

467+
define i32 @shl_sub_lshr_reverse(i32 %x, i32 %c, i32 %y) {
468+
; CHECK-LABEL: @shl_sub_lshr_reverse(
469+
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 [[X:%.*]], [[C:%.*]]
470+
; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 [[Y:%.*]], [[SHL]]
471+
; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i32 [[SUB]], [[C]]
472+
; CHECK-NEXT: ret i32 [[LSHR]]
473+
;
474+
%shl = shl nuw i32 %x, %c
475+
%sub = sub nuw nsw i32 %y, %shl
476+
%lshr = lshr exact i32 %sub, %c
477+
ret i32 %lshr
478+
}
479+
480+
; Negative test
481+
482+
define i32 @shl_sub_lshr_reverse_no_exact(i32 %x, i32 %c, i32 %y) {
483+
; CHECK-LABEL: @shl_sub_lshr_reverse_no_exact(
484+
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 [[X:%.*]], [[C:%.*]]
485+
; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 [[Y:%.*]], [[SHL]]
486+
; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[SUB]], [[C]]
487+
; CHECK-NEXT: ret i32 [[LSHR]]
488+
;
489+
%shl = shl nuw i32 %x, %c
490+
%sub = sub nuw nsw i32 %y, %shl
491+
%lshr = lshr i32 %sub, %c
492+
ret i32 %lshr
493+
}
494+
467495
define i32 @shl_or_lshr(i32 %x, i32 %c, i32 %y) {
468496
; CHECK-LABEL: @shl_or_lshr(
469497
; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[Y:%.*]], [[C:%.*]]

0 commit comments

Comments
 (0)