mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[InstCombine] Remove scalable vector restriction in InstCombineCompares
Differential Revision: https://reviews.llvm.org/D93269
This commit is contained in:
parent
8cea8298aa
commit
6eda9a4795
@ -899,8 +899,8 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
|
||||
// For vectors, we apply the same reasoning on a per-lane basis.
|
||||
auto *Base = GEPLHS->getPointerOperand();
|
||||
if (GEPLHS->getType()->isVectorTy() && Base->getType()->isPointerTy()) {
|
||||
int NumElts = cast<FixedVectorType>(GEPLHS->getType())->getNumElements();
|
||||
Base = Builder.CreateVectorSplat(NumElts, Base);
|
||||
auto EC = cast<VectorType>(GEPLHS->getType())->getElementCount();
|
||||
Base = Builder.CreateVectorSplat(EC, Base);
|
||||
}
|
||||
return new ICmpInst(Cond, Base,
|
||||
ConstantExpr::getPointerBitCastOrAddrSpaceCast(
|
||||
@ -1885,8 +1885,7 @@ Instruction *InstCombinerImpl::foldICmpAndConstant(ICmpInst &Cmp,
|
||||
if (ExactLogBase2 != -1 && DL.isLegalInteger(ExactLogBase2 + 1)) {
|
||||
Type *NTy = IntegerType::get(Cmp.getContext(), ExactLogBase2 + 1);
|
||||
if (auto *AndVTy = dyn_cast<VectorType>(And->getType()))
|
||||
NTy = FixedVectorType::get(
|
||||
NTy, cast<FixedVectorType>(AndVTy)->getNumElements());
|
||||
NTy = VectorType::get(NTy, AndVTy->getElementCount());
|
||||
Value *Trunc = Builder.CreateTrunc(X, NTy);
|
||||
auto NewPred = Cmp.getPredicate() == CmpInst::ICMP_EQ ? CmpInst::ICMP_SGE
|
||||
: CmpInst::ICMP_SLT;
|
||||
@ -2192,8 +2191,7 @@ Instruction *InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp,
|
||||
DL.isLegalInteger(TypeBits - Amt)) {
|
||||
Type *TruncTy = IntegerType::get(Cmp.getContext(), TypeBits - Amt);
|
||||
if (auto *ShVTy = dyn_cast<VectorType>(ShType))
|
||||
TruncTy = FixedVectorType::get(
|
||||
TruncTy, cast<FixedVectorType>(ShVTy)->getNumElements());
|
||||
TruncTy = VectorType::get(TruncTy, ShVTy->getElementCount());
|
||||
Constant *NewC =
|
||||
ConstantInt::get(TruncTy, C.ashr(*ShiftAmt).trunc(TypeBits - Amt));
|
||||
return new ICmpInst(Pred, Builder.CreateTrunc(X, TruncTy), NewC);
|
||||
@ -2827,8 +2825,7 @@ static Instruction *foldICmpBitCast(ICmpInst &Cmp,
|
||||
|
||||
Type *NewType = Builder.getIntNTy(XType->getScalarSizeInBits());
|
||||
if (auto *XVTy = dyn_cast<VectorType>(XType))
|
||||
NewType = FixedVectorType::get(
|
||||
NewType, cast<FixedVectorType>(XVTy)->getNumElements());
|
||||
NewType = VectorType::get(NewType, XVTy->getElementCount());
|
||||
Value *NewBitcast = Builder.CreateBitCast(X, NewType);
|
||||
if (TrueIfSigned)
|
||||
return new ICmpInst(ICmpInst::ICMP_SLT, NewBitcast,
|
||||
@ -3411,8 +3408,8 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I,
|
||||
// those elements by copying an existing, defined, and safe scalar constant.
|
||||
Type *OpTy = M->getType();
|
||||
auto *VecC = dyn_cast<Constant>(M);
|
||||
if (OpTy->isVectorTy() && VecC && VecC->containsUndefElement()) {
|
||||
auto *OpVTy = cast<FixedVectorType>(OpTy);
|
||||
auto *OpVTy = dyn_cast<FixedVectorType>(OpTy);
|
||||
if (OpVTy && VecC && VecC->containsUndefElement()) {
|
||||
Constant *SafeReplacementConstant = nullptr;
|
||||
for (unsigned i = 0, e = OpVTy->getNumElements(); i != e; ++i) {
|
||||
if (!isa<UndefValue>(VecC->getAggregateElement(i))) {
|
||||
|
@ -9,3 +9,27 @@ define <vscale x 2 x i1> @sge(<vscale x 2 x i8> %x) {
|
||||
%cmp = icmp sge <vscale x 2 x i8> %x, zeroinitializer
|
||||
ret <vscale x 2 x i1> %cmp
|
||||
}
|
||||
|
||||
define <vscale x 2 x i1> @gep_scalevector1(i32* %X) nounwind {
|
||||
; CHECK-LABEL: @gep_scalevector1(
|
||||
; CHECK-NEXT: [[S:%.*]] = insertelement <vscale x 2 x i32*> undef, i32* [[X:%.*]], i32 0
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp eq <vscale x 2 x i32*> [[S]], zeroinitializer
|
||||
; CHECK-NEXT: [[C1:%.*]] = shufflevector <vscale x 2 x i1> [[C]], <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
|
||||
; CHECK-NEXT: ret <vscale x 2 x i1> [[C1]]
|
||||
;
|
||||
%A = getelementptr inbounds i32, i32* %X, <vscale x 2 x i64> zeroinitializer
|
||||
%C = icmp eq <vscale x 2 x i32*> %A, zeroinitializer
|
||||
ret <vscale x 2 x i1> %C
|
||||
}
|
||||
|
||||
define <vscale x 2 x i1> @signbit_bitcast_fpext_scalevec(<vscale x 2 x half> %x) {
|
||||
; CHECK-LABEL: @signbit_bitcast_fpext_scalevec(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = bitcast <vscale x 2 x half> [[X:%.*]] to <vscale x 2 x i16>
|
||||
; CHECK-NEXT: [[R:%.*]] = icmp slt <vscale x 2 x i16> [[TMP1]], zeroinitializer
|
||||
; CHECK-NEXT: ret <vscale x 2 x i1> [[R]]
|
||||
;
|
||||
%f = fpext <vscale x 2 x half> %x to <vscale x 2 x float>
|
||||
%b = bitcast <vscale x 2 x float> %f to <vscale x 2 x i32>
|
||||
%r = icmp slt <vscale x 2 x i32> %b, zeroinitializer
|
||||
ret <vscale x 2 x i1> %r
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user