[InstCombine][foldPHIArgGEPIntoPHI] Early return for const vector index for gep inst (#138661)
This commit is contained in:
@@ -574,8 +574,8 @@ Instruction *InstCombinerImpl::foldPHIArgGEPIntoPHI(PHINode &PN) {
|
||||
// substantially cheaper to compute for the constants, so making it a
|
||||
// variable index could pessimize the path. This also handles the case
|
||||
// for struct indices, which must always be constant.
|
||||
if (isa<ConstantInt>(FirstInst->getOperand(Op)) ||
|
||||
isa<ConstantInt>(GEP->getOperand(Op)))
|
||||
if (isa<Constant>(FirstInst->getOperand(Op)) ||
|
||||
isa<Constant>(GEP->getOperand(Op)))
|
||||
return nullptr;
|
||||
|
||||
if (FirstInst->getOperand(Op)->getType() !=
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
||||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
||||
|
||||
%foo = type { i16, i16, i16 }
|
||||
|
||||
define <16 x ptr> @test(i1 %tobool) {
|
||||
; CHECK-LABEL: define <16 x ptr> @test(
|
||||
; CHECK-SAME: i1 [[TOBOOL:%.*]]) {
|
||||
; CHECK-NEXT: [[ENTRY:.*:]]
|
||||
; CHECK-NEXT: [[LANE_0:%.*]] = alloca [[FOO:%.*]], align 16
|
||||
; CHECK-NEXT: [[LANE_15:%.*]] = insertelement <16 x ptr> poison, ptr [[LANE_0]], i64 0
|
||||
; CHECK-NEXT: br i1 [[TOBOOL]], label %[[F1:.*]], label %[[F0:.*]]
|
||||
; CHECK: [[F0]]:
|
||||
; CHECK-NEXT: [[MM_VECTORGEP:%.*]] = getelementptr inbounds [[FOO]], <16 x ptr> [[LANE_15]], <16 x i64> zeroinitializer, <16 x i32> splat (i32 1)
|
||||
; CHECK-NEXT: br label %[[MERGE:.*]]
|
||||
; CHECK: [[F1]]:
|
||||
; CHECK-NEXT: [[MM_VECTORGEP2:%.*]] = getelementptr inbounds [[FOO]], <16 x ptr> [[LANE_15]], <16 x i64> zeroinitializer, <16 x i32> splat (i32 2)
|
||||
; CHECK-NEXT: br label %[[MERGE]]
|
||||
; CHECK: [[MERGE]]:
|
||||
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <16 x ptr> [ [[MM_VECTORGEP]], %[[F0]] ], [ [[MM_VECTORGEP2]], %[[F1]] ]
|
||||
; CHECK-NEXT: ret <16 x ptr> [[VEC_PHI]]
|
||||
;
|
||||
entry:
|
||||
%lane.0 = alloca %foo, align 16
|
||||
%lane.15 = insertelement <16 x ptr> poison, ptr %lane.0, i64 0
|
||||
%mm_vectorGEP = getelementptr inbounds %foo, <16 x ptr> %lane.15, <16 x i64> zeroinitializer, <16 x i32> splat (i32 1)
|
||||
%mm_vectorGEP2 = getelementptr inbounds %foo, <16 x ptr> %lane.15, <16 x i64> zeroinitializer, <16 x i32> splat (i32 2)
|
||||
br i1 %tobool, label %f1, label %f0
|
||||
|
||||
f0:
|
||||
br label %merge
|
||||
|
||||
f1:
|
||||
br label %merge
|
||||
|
||||
merge:
|
||||
%vec.phi = phi <16 x ptr> [ %mm_vectorGEP, %f0], [ %mm_vectorGEP2, %f1 ]
|
||||
ret <16 x ptr> %vec.phi
|
||||
}
|
||||
Reference in New Issue
Block a user