[SelectionDAGBuilder] Only check VPCmp for NaNs in fp comparisons (#189749)

`getFCmpCodeWithoutNaN` should only be used for FP comparisons (which is
also the only context in which `isKnownNeverNaN` makes sense).
This commit is contained in:
zGoldthorpe 2026-04-01 11:00:55 -06:00 committed by GitHub
parent 91adaeceb1
commit d7e129dffb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8859,11 +8859,9 @@ void SelectionDAGBuilder::visitVPCmp(const VPCmpIntrinsic &VPIntrin) {
ISD::CondCode Condition;
CmpInst::Predicate CondCode = VPIntrin.getPredicate();
bool IsFP = VPIntrin.getOperand(0)->getType()->isFPOrFPVectorTy();
Condition = IsFP ? getFCmpCondCode(CondCode) : getICmpCondCode(CondCode);
SDValue Op1 = getValue(VPIntrin.getOperand(0));
SDValue Op2 = getValue(VPIntrin.getOperand(1));
Value *Op1 = VPIntrin.getOperand(0);
Value *Op2 = VPIntrin.getOperand(1);
// #2 is the condition code
SDValue MaskOp = getValue(VPIntrin.getOperand(3));
SDValue EVL = getValue(VPIntrin.getOperand(4));
@ -8872,12 +8870,19 @@ void SelectionDAGBuilder::visitVPCmp(const VPCmpIntrinsic &VPIntrin) {
"Unexpected target EVL type");
EVL = DAG.getNode(ISD::ZERO_EXTEND, DL, EVLParamVT, EVL);
if (VPIntrin.getOperand(0)->getType()->isFPOrFPVectorTy()) {
Condition = getFCmpCondCode(CondCode);
SimplifyQuery SQ(DAG.getDataLayout(), &VPIntrin);
if (isKnownNeverNaN(Op2, SQ) && isKnownNeverNaN(Op1, SQ))
Condition = getFCmpCodeWithoutNaN(Condition);
} else {
Condition = getICmpCondCode(CondCode);
}
EVT DestVT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(),
VPIntrin.getType());
if (DAG.isKnownNeverNaN(Op1) && DAG.isKnownNeverNaN(Op2))
Condition = getFCmpCodeWithoutNaN(Condition);
setValue(&VPIntrin,
DAG.getSetCCVP(DL, DestVT, Op1, Op2, Condition, MaskOp, EVL));
setValue(&VPIntrin, DAG.getSetCCVP(DL, DestVT, getValue(Op1), getValue(Op2),
Condition, MaskOp, EVL));
}
void SelectionDAGBuilder::visitVectorPredicationIntrinsic(