[llvm] 09b1cfc - [InstCombine] Add additional test case for (add (zext (add nuw X, C2), C1). NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 07:33:56 PDT 2024
Author: Craig Topper
Date: 2024-07-12T07:33:39-07:00
New Revision: 09b1cfceb62332ebf8e5d319ee048492a709995d
URL: https://github.com/llvm/llvm-project/commit/09b1cfceb62332ebf8e5d319ee048492a709995d
DIFF: https://github.com/llvm/llvm-project/commit/09b1cfceb62332ebf8e5d319ee048492a709995d.diff
LOG: [InstCombine] Add additional test case for (add (zext (add nuw X, C2), C1). NFC
Add test where the zext has an additional use, but the entire
expression can be replaced with (zext X). Folding even though there
is an additional use would not increase the number of instructions.
Added:
Modified:
llvm/test/Transforms/InstCombine/add.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll
index 8b3ecaf25cd9d..2f914a2e58867 100644
--- a/llvm/test/Transforms/InstCombine/add.ll
+++ b/llvm/test/Transforms/InstCombine/add.ll
@@ -951,6 +951,21 @@ define i64 @test41(i32 %a) {
ret i64 %sub
}
+define i64 @test41_multiuse_constants_cancel(i32 %a) {
+; CHECK-LABEL: @test41_multiuse_constants_cancel(
+; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[A:%.*]], 1
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[ADD]] to i64
+; CHECK-NEXT: [[REASS_ADD:%.*]] = shl nuw nsw i64 [[ZEXT]], 1
+; CHECK-NEXT: [[EXTRAUSE:%.*]] = add nsw i64 [[REASS_ADD]], -1
+; CHECK-NEXT: ret i64 [[EXTRAUSE]]
+;
+ %add = add nuw i32 %a, 1
+ %zext = zext i32 %add to i64
+ %sub = add i64 %zext, -1
+ %extrause = add i64 %zext, %sub
+ ret i64 %extrause
+}
+
; (add (zext (add nuw X, C2)), C) --> (zext (add nuw X, C2 + C))
define <2 x i64> @test41vec(<2 x i32> %a) {
More information about the llvm-commits
mailing list