Skip to content

Commit 95828ee

Browse files
committed
[X86] combineFaddCFmul - use KnownBits to detect FNEG patterns.
We currently look for X86ISD::VBROADCAST_LOAD patterns, but this won't work with a future patch which will improve sharing of constant pool loads.
1 parent b3a9e8f commit 95828ee

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50888,20 +50888,11 @@ static SDValue combineFaddCFmul(SDNode *N, SelectionDAG &DAG,
5088850888
return DAG.getTarget().Options.NoSignedZerosFPMath ||
5088950889
Flags.hasNoSignedZeros();
5089050890
};
50891-
auto IsVectorAllNegativeZero = [](const SDNode *N) {
50892-
if (N->getOpcode() != X86ISD::VBROADCAST_LOAD)
50893-
return false;
50894-
assert(N->getSimpleValueType(0).getScalarType() == MVT::f32 &&
50895-
"Unexpected vector type!");
50896-
if (ConstantPoolSDNode *CP =
50897-
dyn_cast<ConstantPoolSDNode>(N->getOperand(1)->getOperand(0))) {
50898-
APInt AI = APInt(32, 0x80008000, true);
50899-
if (const auto *CI = dyn_cast<ConstantInt>(CP->getConstVal()))
50900-
return CI->getValue() == AI;
50901-
if (const auto *CF = dyn_cast<ConstantFP>(CP->getConstVal()))
50902-
return CF->getValue() == APFloat(APFloat::IEEEsingle(), AI);
50903-
}
50904-
return false;
50891+
auto IsVectorAllNegativeZero = [&DAG](SDValue Op) {
50892+
APInt AI = APInt(32, 0x80008000, true);
50893+
KnownBits Bits = DAG.computeKnownBits(Op);
50894+
return Bits.getBitWidth() == 32 && Bits.isConstant() &&
50895+
Bits.getConstant() == AI;
5090550896
};
5090650897

5090750898
if (N->getOpcode() != ISD::FADD || !Subtarget.hasFP16() ||
@@ -50933,7 +50924,7 @@ static SDValue combineFaddCFmul(SDNode *N, SelectionDAG &DAG,
5093350924
if ((Opcode == X86ISD::VFMADDC || Opcode == X86ISD::VFCMADDC) &&
5093450925
((ISD::isBuildVectorAllZeros(Op0->getOperand(2).getNode()) &&
5093550926
HasNoSignedZero(Op0->getFlags())) ||
50936-
IsVectorAllNegativeZero(Op0->getOperand(2).getNode()))) {
50927+
IsVectorAllNegativeZero(Op0->getOperand(2)))) {
5093750928
MulOp0 = Op0.getOperand(0);
5093850929
MulOp1 = Op0.getOperand(1);
5093950930
IsConj = Opcode == X86ISD::VFCMADDC;

0 commit comments

Comments
 (0)