[llvm] d2cd3f8 - [InstCombine] Add 3-operand gep test with different ptr and same indices
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 11:01:04 PDT 2021
Author: Simon Pilgrim
Date: 2021-07-15T18:50:19+01:00
New Revision: d2cd3f88e78d01eec19c50ff2da1ed659a2cd210
URL: https://github.com/llvm/llvm-project/commit/d2cd3f88e78d01eec19c50ff2da1ed659a2cd210
DIFF: https://github.com/llvm/llvm-project/commit/d2cd3f88e78d01eec19c50ff2da1ed659a2cd210.diff
LOG: [InstCombine] Add 3-operand gep test with different ptr and same indices
Added:
Modified:
llvm/test/Transforms/InstCombine/select-gep.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select-gep.ll b/llvm/test/Transforms/InstCombine/select-gep.ll
index 45bc1da7046e..8f96f49b761a 100644
--- a/llvm/test/Transforms/InstCombine/select-gep.ll
+++ b/llvm/test/Transforms/InstCombine/select-gep.ll
@@ -117,8 +117,23 @@ define i32* @test3a([4 x i32]* %p, i64 %x, i64 %y) {
ret i32* %select
}
-define i32* @test3b([4 x i32]* %p, i32* %q, i64 %x, i64 %y) {
+define i32* @test3b([4 x i32]* %p, [4 x i32]* %q, i64 %x, i64 %y) {
; CHECK-LABEL: @test3b(
+; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[P:%.*]], i64 2, i64 [[X:%.*]]
+; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[Q:%.*]], i64 2, i64 [[X]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
+; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], i32* [[GEP1]], i32* [[GEP2]]
+; CHECK-NEXT: ret i32* [[SELECT]]
+;
+ %gep1 = getelementptr inbounds [4 x i32], [4 x i32]* %p, i64 2, i64 %x
+ %gep2 = getelementptr inbounds [4 x i32], [4 x i32]* %q, i64 2, i64 %x
+ %cmp = icmp ugt i64 %x, %y
+ %select = select i1 %cmp, i32* %gep1, i32* %gep2
+ ret i32* %select
+}
+
+define i32* @test3c([4 x i32]* %p, i32* %q, i64 %x, i64 %y) {
+; CHECK-LABEL: @test3c(
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[P:%.*]], i64 [[X:%.*]], i64 2
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i32, i32* [[Q:%.*]], i64 [[X]]
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
@@ -132,8 +147,8 @@ define i32* @test3b([4 x i32]* %p, i32* %q, i64 %x, i64 %y) {
ret i32* %select
}
-define i32* @test3c(i32* %p, [4 x i32]* %q, i64 %x, i64 %y) {
-; CHECK-LABEL: @test3c(
+define i32* @test3d(i32* %p, [4 x i32]* %q, i64 %x, i64 %y) {
+; CHECK-LABEL: @test3d(
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 [[X:%.*]]
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds [4 x i32], [4 x i32]* [[Q:%.*]], i64 [[X]], i64 2
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
More information about the llvm-commits
mailing list