Skip to content

Commit 4c648e3

Browse files
committed
[InstCombine] Pre-commit tests (NFC)
1 parent b7ed097 commit 4c648e3

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
@@ -466,6 +466,34 @@ define i32 @shl_sub_lshr(i32 %x, i32 %c, i32 %y) {
466466
ret i32 %lshr
467467
}
468468

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

0 commit comments

Comments
 (0)