[llvm] 9d23029 - [InstCombine] add tests for demanded/known bits of shifted constant; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 07:52:15 PST 2021
Author: Sanjay Patel
Date: 2021-02-04T10:31:22-05:00
New Revision: 9d230295d925238573f6e2dd23f0c5de76f6657b
URL: https://github.com/llvm/llvm-project/commit/9d230295d925238573f6e2dd23f0c5de76f6657b
DIFF: https://github.com/llvm/llvm-project/commit/9d230295d925238573f6e2dd23f0c5de76f6657b.diff
LOG: [InstCombine] add tests for demanded/known bits of shifted constant; NFC
These are variations of a missed analysis noted in:
https://llvm.org/PR48984
Added:
Modified:
llvm/test/Transforms/InstCombine/shift.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll
index 61cbec61bba4..d181be35ebad 100644
--- a/llvm/test/Transforms/InstCombine/shift.ll
+++ b/llvm/test/Transforms/InstCombine/shift.ll
@@ -1795,3 +1795,25 @@ define void @ashr_out_of_range_1(i177* %A) {
store i177 %B28, i177* %G62, align 4
ret void
}
+
+define i8 @lshr_mask_demand(i8 %x) {
+; CHECK-LABEL: @lshr_mask_demand(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 63, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = and i8 [[S]], -32
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %s = lshr i8 63, %x ; 0b00111111
+ %r = and i8 %s, 224 ; 0b11100000
+ ret i8 %r
+}
+
+define i8 @shl_mask_demand(i8 %x) {
+; CHECK-LABEL: @shl_mask_demand(
+; CHECK-NEXT: [[S:%.*]] = shl i8 12, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = and i8 [[S]], 7
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %s = shl i8 12, %x ; 0b00001100
+ %r = and i8 %s, 7 ; 0b00000111
+ ret i8 %r
+}
More information about the llvm-commits
mailing list