Skip to content

Commit

Permalink
[InstCombine] Add more tests for shl+lshr transforms; NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
bcl5980 committed Jun 6, 2022
1 parent cfdd2b1 commit 2e7d4b6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions llvm/test/Transforms/InstCombine/and.ll
Expand Up @@ -1637,6 +1637,19 @@ define i16 @shl_lshr_pow2_const_case1(i16 %x) {

define i16 @shl_lshr_pow2_const_case2(i16 %x) {
; CHECK-LABEL: @shl_lshr_pow2_const_case2(
; CHECK-NEXT: [[SHL:%.*]] = shl i16 4, [[X:%.*]]
; CHECK-NEXT: [[LSHR:%.*]] = lshr i16 [[SHL]], 6
; CHECK-NEXT: [[R:%.*]] = or i16 [[LSHR]], -9
; CHECK-NEXT: ret i16 [[R]]
;
%shl = shl i16 4, %x
%lshr = lshr i16 %shl, 6
%r = or i16 %lshr, 65527 ; ~8
ret i16 %r
}

define i16 @shl_lshr_pow2_const_case3(i16 %x) {
; CHECK-LABEL: @shl_lshr_pow2_const_case3(
; CHECK-NEXT: [[SHL:%.*]] = shl i16 16, [[X:%.*]]
; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i16 [[SHL]], 3
; CHECK-NEXT: [[R:%.*]] = or i16 [[LSHR]], -9
Expand All @@ -1648,8 +1661,8 @@ define i16 @shl_lshr_pow2_const_case2(i16 %x) {
ret i16 %r
}

define i13 @shl_lshr_pow2_const_case3(i16 %x) {
; CHECK-LABEL: @shl_lshr_pow2_const_case3(
define i13 @shl_lshr_pow2_const_case4(i16 %x) {
; CHECK-LABEL: @shl_lshr_pow2_const_case4(
; CHECK-NEXT: [[SHL:%.*]] = shl i16 16, [[X:%.*]]
; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i16 [[SHL]], 3
; CHECK-NEXT: [[R:%.*]] = trunc i16 [[LSHR]] to i13
Expand Down

0 comments on commit 2e7d4b6

Please sign in to comment.