From d2cd3f88e78d01eec19c50ff2da1ed659a2cd210 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 15 Jul 2021 18:48:56 +0100 Subject: [PATCH] [InstCombine] Add 3-operand gep test with different ptr and same indices --- llvm/test/Transforms/InstCombine/select-gep.ll | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/select-gep.ll b/llvm/test/Transforms/InstCombine/select-gep.ll index 45bc1da..8f96f49 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:%.*]] -- 2.7.4