[llvm] d7e129d - [SelectionDAGBuilder] Only check VPCmp for NaNs in fp comparisons (#189749)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 10:01:01 PDT 2026
Author: zGoldthorpe
Date: 2026-04-01T17:00:55Z
New Revision: d7e129dffbe1d8cdafd6731a4ff130da68deb40b
URL: https://github.com/llvm/llvm-project/commit/d7e129dffbe1d8cdafd6731a4ff130da68deb40b
DIFF: https://github.com/llvm/llvm-project/commit/d7e129dffbe1d8cdafd6731a4ff130da68deb40b.diff
LOG: [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).
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 69ba9721401e1..cd4470d5f20fe 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -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(
More information about the llvm-commits
mailing list