[llvm] 4d71124 - [InstCombine] Add zext nneg test variant for gep of sext add fold (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 21 07:38:18 PST 2023
Author: Nikita Popov
Date: 2023-12-21T16:38:09+01:00
New Revision: 4d7112435e31dafb5854f69c516373e4548bd0a3
URL: https://github.com/llvm/llvm-project/commit/4d7112435e31dafb5854f69c516373e4548bd0a3
DIFF: https://github.com/llvm/llvm-project/commit/4d7112435e31dafb5854f69c516373e4548bd0a3.diff
LOG: [InstCombine] Add zext nneg test variant for gep of sext add fold (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/array.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/array.ll b/llvm/test/Transforms/InstCombine/array.ll
index 8bab3104fd8cd0..824cf3d663c821 100644
--- a/llvm/test/Transforms/InstCombine/array.ll
+++ b/llvm/test/Transforms/InstCombine/array.ll
@@ -72,3 +72,39 @@ entry:
store i32 %b, ptr %gep
ret void
}
+
+define void @test_zext_nneg(ptr %ptr, i32 %a, i32 %b) {
+; CHECK-LABEL: define void @test_zext_nneg(
+; CHECK-SAME: ptr [[PTR:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[A]], 10
+; CHECK-NEXT: [[IDX:%.*]] = zext nneg i32 [[ADD]] to i64
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, ptr [[PTR]], i64 [[IDX]]
+; CHECK-NEXT: store i32 [[B]], ptr [[GEP]], align 4
+; CHECK-NEXT: ret void
+;
+entry:
+ %add = add nsw i32 %a, 10
+ %idx = zext nneg i32 %add to i64
+ %gep = getelementptr inbounds i32, ptr %ptr, i64 %idx
+ store i32 %b, ptr %gep
+ ret void
+}
+
+define void @test_zext_missing_nneg(ptr %ptr, i32 %a, i32 %b) {
+; CHECK-LABEL: define void @test_zext_missing_nneg(
+; CHECK-SAME: ptr [[PTR:%.*]], i32 [[A:%.*]], i32 [[B:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[A]], 10
+; CHECK-NEXT: [[IDX:%.*]] = zext i32 [[ADD]] to i64
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, ptr [[PTR]], i64 [[IDX]]
+; CHECK-NEXT: store i32 [[B]], ptr [[GEP]], align 4
+; CHECK-NEXT: ret void
+;
+entry:
+ %add = add nsw i32 %a, 10
+ %idx = zext i32 %add to i64
+ %gep = getelementptr inbounds i32, ptr %ptr, i64 %idx
+ store i32 %b, ptr %gep
+ ret void
+}
More information about the llvm-commits
mailing list