[llvm] 49f950a - [InstCombine] add more tests for a planned shift fold; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 11:16:04 PDT 2022
Author: Sanjay Patel
Date: 2022-04-21T14:08:50-04:00
New Revision: 49f950ae26453cada4d222eddd55535a003c1c49
URL: https://github.com/llvm/llvm-project/commit/49f950ae26453cada4d222eddd55535a003c1c49
DIFF: https://github.com/llvm/llvm-project/commit/49f950ae26453cada4d222eddd55535a003c1c49.diff
LOG: [InstCombine] add more tests for a planned shift fold; NFC
These are reductions for a missed constraint (the offset
constant must be less than the bitwidth) that caused the
first version of the patch ( 5819f4a42286 ) to be reverted.
Added:
Modified:
llvm/test/Transforms/InstCombine/shift-add.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/shift-add.ll b/llvm/test/Transforms/InstCombine/shift-add.ll
index 141551978377e..d1618d92e1e07 100644
--- a/llvm/test/Transforms/InstCombine/shift-add.ll
+++ b/llvm/test/Transforms/InstCombine/shift-add.ll
@@ -217,3 +217,25 @@ define i32 @shl_nsw_add_positive_invalid_constant(i32 %x) {
%r = shl nsw i32 4, %a
ret i32 %r
}
+
+define i32 @shl_nsw_add_negative_invalid_constant2(i32 %x) {
+; CHECK-LABEL: @shl_nsw_add_negative_invalid_constant2(
+; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], -33
+; CHECK-NEXT: [[R:%.*]] = shl nsw i32 2, [[A]]
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %a = add i32 %x, -33
+ %r = shl nsw i32 2, %a
+ ret i32 %r
+}
+
+define i4 @shl_nsw_add_negative_invalid_constant3(i4 %x) {
+; CHECK-LABEL: @shl_nsw_add_negative_invalid_constant3(
+; CHECK-NEXT: [[A:%.*]] = xor i4 [[X:%.*]], -8
+; CHECK-NEXT: [[R:%.*]] = shl nsw i4 2, [[A]]
+; CHECK-NEXT: ret i4 [[R]]
+;
+ %a = add i4 %x, 8
+ %r = shl nsw i4 2, %a
+ ret i4 %r
+}
More information about the llvm-commits
mailing list