[llvm] fc9dbc9 - [InstCombine] Add extra test for icmp of gep fold (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 2 07:56:16 PST 2024
Author: Nikita Popov
Date: 2024-01-02T16:56:07+01:00
New Revision: fc9dbc999bc711a99b94b42453240b38a6509b0d
URL: https://github.com/llvm/llvm-project/commit/fc9dbc999bc711a99b94b42453240b38a6509b0d
DIFF: https://github.com/llvm/llvm-project/commit/fc9dbc999bc711a99b94b42453240b38a6509b0d.diff
LOG: [InstCombine] Add extra test for icmp of gep fold (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-gep.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-gep.ll b/llvm/test/Transforms/InstCombine/icmp-gep.ll
index 99c784d15eb30a..fb297e04ceb065 100644
--- a/llvm/test/Transforms/InstCombine/icmp-gep.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-gep.ll
@@ -5,6 +5,7 @@ target datalayout = "e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:
declare ptr @getptr()
declare void @use(ptr)
+declare void @use.i1(i1)
define i1 @eq_base(ptr %x, i64 %y) {
; CHECK-LABEL: @eq_base(
@@ -443,6 +444,29 @@ define i1 @test60_extra_use_const_operands_no_inbounds(ptr %foo, i64 %i, i64 %j)
ret i1 %cmp
}
+define void @test60_extra_use_fold(ptr %foo, i64 %start.idx, i64 %end.offset) {
+; CHECK-LABEL: @test60_extra_use_fold(
+; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[FOO:%.*]], i64 [[START_IDX:%.*]]
+; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[FOO]], i64 [[END_OFFSET:%.*]]
+; CHECK-NEXT: call void @use(ptr [[GEP1]])
+; CHECK-NEXT: call void @use(ptr [[GEP2]])
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[GEP1]], [[GEP2]]
+; CHECK-NEXT: call void @use.i1(i1 [[CMP1]])
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ult ptr [[GEP1]], [[GEP2]]
+; CHECK-NEXT: call void @use.i1(i1 [[CMP2]])
+; CHECK-NEXT: ret void
+;
+ %gep1 = getelementptr inbounds i32, ptr %foo, i64 %start.idx
+ %gep2 = getelementptr inbounds i8, ptr %foo, i64 %end.offset
+ call void @use(ptr %gep1)
+ call void @use(ptr %gep2)
+ %cmp1 = icmp eq ptr %gep1, %gep2
+ call void @use.i1(i1 %cmp1)
+ %cmp2 = icmp ult ptr %gep1, %gep2
+ call void @use.i1(i1 %cmp2)
+ ret void
+}
+
define i1 @test_scalable_same(ptr %x) {
; CHECK-LABEL: @test_scalable_same(
; CHECK-NEXT: ret i1 false
More information about the llvm-commits
mailing list