diff options
author | Nikita Popov <npopov@redhat.com> | 2023-12-21 16:31:56 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-12-21 16:38:09 +0100 |
commit | 4d7112435e31dafb5854f69c516373e4548bd0a3 (patch) | |
tree | 004186eede8c626dc02f1c35fe5b25e802ebc311 | |
parent | 8fdfd34cd2ad67cd3fe2ded59b476790240a52bb (diff) | |
download | llvm-4d7112435e31dafb5854f69c516373e4548bd0a3.zip llvm-4d7112435e31dafb5854f69c516373e4548bd0a3.tar.gz llvm-4d7112435e31dafb5854f69c516373e4548bd0a3.tar.bz2 |
[InstCombine] Add zext nneg test variant for gep of sext add fold (NFC)
-rw-r--r-- | llvm/test/Transforms/InstCombine/array.ll | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/array.ll b/llvm/test/Transforms/InstCombine/array.ll index 8bab310..824cf3d 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 +} |