[PATCH] D132381: [InstCombine] Add tests for D130075
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 22 12:04:06 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b24e64014ef: [InstCombine] Add tests for D130075 (authored by foad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132381/new/
https://reviews.llvm.org/D132381
Files:
llvm/test/Transforms/InstCombine/add2.ll
Index: llvm/test/Transforms/InstCombine/add2.ll
===================================================================
--- llvm/test/Transforms/InstCombine/add2.ll
+++ llvm/test/Transforms/InstCombine/add2.ll
@@ -472,3 +472,31 @@
%add = add i32 %sel0, %sel1
ret i32 %add
}
+
+; The ADD can't cause overflow out of the low 4 bits so the OR can be removed.
+
+define i32 @add_undemanded_low_bits(i32 %x) {
+; CHECK-LABEL: @add_undemanded_low_bits(
+; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 15
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[OR]], 1616
+; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[ADD]], 4
+; CHECK-NEXT: ret i32 [[SHR]]
+;
+ %or = or i32 %x, 15
+ %add = add i32 %or, 1616
+ %shr = lshr i32 %add, 4
+ ret i32 %shr
+}
+
+define i32 @sub_undemanded_low_bits(i32 %x) {
+; CHECK-LABEL: @sub_undemanded_low_bits(
+; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 15
+; CHECK-NEXT: [[SUB:%.*]] = add i32 [[OR]], -1616
+; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[SUB]], 4
+; CHECK-NEXT: ret i32 [[SHR]]
+;
+ %or = or i32 %x, 15
+ %sub = sub i32 %or, 1616
+ %shr = lshr i32 %sub, 4
+ ret i32 %shr
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132381.454587.patch
Type: text/x-patch
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220822/ce1452e0/attachment.bin>
More information about the llvm-commits
mailing list