@@ -55721,9 +55721,9 @@ static SDValue combineVectorCompare(SDNode *N, SelectionDAG &DAG,
55721
55721
55722
55722
// Helper to determine if we can convert an integer comparison to a float
55723
55723
// comparison byt casting the operands.
55724
- static std::optional<unsigned> CastIntSETCCtoFP(MVT VT, ISD::CondCode CC,
55725
- const KnownBits &LHS ,
55726
- const KnownBits &RHS ) {
55724
+ static std::optional<unsigned>
55725
+ CastIntSETCCtoFP(MVT VT, ISD::CondCode CC, unsigned NumSignificantBitsLHS ,
55726
+ unsigned NumSignificantBitsRHS ) {
55727
55727
MVT SVT = VT.getScalarType();
55728
55728
assert(SVT == MVT::f32 && "Only tested for float so far");
55729
55729
const fltSemantics &Sem = SelectionDAG::EVTToAPFloatSemantics(SVT);
@@ -55732,20 +55732,10 @@ static std::optional<unsigned> CastIntSETCCtoFP(MVT VT, ISD::CondCode CC,
55732
55732
55733
55733
// TODO: Handle bitcastable integers.
55734
55734
55735
- // For cvt + signed compare we need:
55736
- // abs(lhs) < MaxConvertableCvt and abs(rhs) < MaxConvertableCvt
55737
- auto OpInAbsRange = [](const KnownBits &Known, const APInt &Bound) {
55738
- if (Known.isUnknown() ||
55739
- !KnownBits::slt(Known, KnownBits::makeConstant(Bound)) ||
55740
- !KnownBits::sgt(Known, KnownBits::makeConstant(-Bound)))
55741
- return false;
55742
- return true;
55743
- };
55744
- APInt MaxConvertableCvt = APInt::getOneBitSet(
55745
- SVT.getScalarSizeInBits(), APFloat::semanticsPrecision(Sem));
55746
-
55747
- if (OpInAbsRange(RHS, MaxConvertableCvt) &&
55748
- OpInAbsRange(LHS, MaxConvertableCvt))
55735
+ // For cvt + signed compare we need lhs and rhs to be exactly representable as
55736
+ // a fp value.
55737
+ unsigned FPPrec = APFloat::semanticsPrecision(Sem);
55738
+ if (FPPrec >= NumSignificantBitsLHS && FPPrec >= NumSignificantBitsRHS)
55749
55739
return ISD::SINT_TO_FP;
55750
55740
55751
55741
return std::nullopt;
@@ -56153,17 +56143,15 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
56153
56143
56154
56144
// Without AVX2, see if we can cast the values to v8f32 and use fcmp.
56155
56145
// TODO: Handle v4f64 as well?
56156
- KnownBits KnownLHS(EltSizeInBits), KnownRHS(EltSizeInBits);
56157
- KnownLHS.One.setAllBits();
56158
- KnownRHS.One.setAllBits();
56159
- KnownLHS.Zero.setAllBits();
56160
- KnownRHS.Zero.setAllBits();
56146
+ unsigned MaxSigBitsLHS = 0, MaxSigBitsRHS = 0;
56161
56147
for (unsigned I = 0; I != NumOps; ++I) {
56162
- KnownBits LHS = DAG.computeKnownBits(Ops[I].getOperand(0));
56163
- KnownBits RHS = DAG.computeKnownBits(Ops[I].getOperand(1));
56164
- KnownLHS = KnownLHS.intersectWith(LHS);
56165
- KnownRHS = KnownRHS.intersectWith(RHS);
56166
- if (KnownLHS.isUnknown() && KnownRHS.isUnknown())
56148
+ MaxSigBitsLHS =
56149
+ std::max(MaxSigBitsLHS,
56150
+ DAG.ComputeMaxSignificantBits(Ops[I].getOperand(0)));
56151
+ MaxSigBitsRHS =
56152
+ std::max(MaxSigBitsRHS,
56153
+ DAG.ComputeMaxSignificantBits(Ops[I].getOperand(1)));
56154
+ if (MaxSigBitsLHS == EltSizeInBits && MaxSigBitsRHS == EltSizeInBits)
56167
56155
break;
56168
56156
}
56169
56157
@@ -56176,7 +56164,7 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
56176
56164
MVT FpVT = VT.changeVectorElementType(FpSVT);
56177
56165
56178
56166
if (std::optional<unsigned> CastOpc =
56179
- CastIntSETCCtoFP(FpVT, ICC, KnownLHS, KnownRHS )) {
56167
+ CastIntSETCCtoFP(FpVT, ICC, MaxSigBitsLHS, MaxSigBitsRHS )) {
56180
56168
SDValue LHS = ConcatSubOperand(VT, Ops, 0);
56181
56169
SDValue RHS = ConcatSubOperand(VT, Ops, 1);
56182
56170
LHS = DAG.getNode(*CastOpc, DL, FpVT, LHS);
0 commit comments