[llvm] 4975837 - [InstCombine] Add basic (select C, (gep Ptr, Idx), Ptr) tests from PR50183
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 13 08:58:38 PDT 2021
Author: Simon Pilgrim
Date: 2021-07-13T16:57:40+01:00
New Revision: 4975837f1480621d9428a4be468831d07b2201de
URL: https://github.com/llvm/llvm-project/commit/4975837f1480621d9428a4be468831d07b2201de
DIFF: https://github.com/llvm/llvm-project/commit/4975837f1480621d9428a4be468831d07b2201de.diff
LOG: [InstCombine] Add basic (select C, (gep Ptr, Idx), Ptr) tests from PR50183
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 902b681727f5..77710cee416d 100644
--- a/llvm/test/Transforms/InstCombine/select-gep.ll
+++ b/llvm/test/Transforms/InstCombine/select-gep.ll
@@ -71,6 +71,34 @@ define i32* @test2(i32* %p, i64 %x, i64 %y) {
ret i32* %select
}
+; PR50183
+define i32* @test2a(i32* %p, i64 %x, i64 %y) {
+; CHECK-LABEL: @test2a(
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
+; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], i32* [[GEP]], i32* [[P]]
+; CHECK-NEXT: ret i32* [[SELECT]]
+;
+ %gep = getelementptr inbounds i32, i32* %p, i64 %x
+ %cmp = icmp ugt i64 %x, %y
+ %select = select i1 %cmp, i32* %gep, i32* %p
+ ret i32* %select
+}
+
+; PR50183
+define i32* @test2b(i32* %p, i64 %x, i64 %y) {
+; CHECK-LABEL: @test2b(
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
+; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], i32* [[P]], i32* [[GEP]]
+; CHECK-NEXT: ret i32* [[SELECT]]
+;
+ %gep = getelementptr inbounds i32, i32* %p, i64 %x
+ %cmp = icmp ugt i64 %x, %y
+ %select = select i1 %cmp, i32* %p, i32* %gep
+ ret i32* %select
+}
+
; Three (or more) operand GEPs are currently expected to not be optimised,
; though they could be in principle.
More information about the llvm-commits
mailing list