// 0 and 1.0 / (0.5 * pi) do not have inline immmediates, so there is an
// additional cost to negate them.
-bool AMDGPUTargetLowering::isConstantCostlierToNegate(SDValue N) const {
- if (const ConstantFPSDNode *C = isConstOrConstSplatFP(N)) {
- if (C->isZero() && !C->isNegative())
- return true;
+TargetLowering::NegatibleCost
+AMDGPUTargetLowering::getConstantNegateCost(const ConstantFPSDNode *C) const {
+ if (C->isZero())
+ return C->isNegative() ? NegatibleCost::Cheaper : NegatibleCost::Expensive;
- if (Subtarget->hasInv2PiInlineImm() && isInv2Pi(C->getValueAPF()))
- return true;
- }
+ if (Subtarget->hasInv2PiInlineImm() && isInv2Pi(C->getValueAPF()))
+ return C->isNegative() ? NegatibleCost::Cheaper : NegatibleCost::Expensive;
+ return NegatibleCost::Neutral;
+}
+
+bool AMDGPUTargetLowering::isConstantCostlierToNegate(SDValue N) const {
+ if (const ConstantFPSDNode *C = isConstOrConstSplatFP(N))
+ return getConstantNegateCost(C) == NegatibleCost::Expensive;
return false;
}
SDValue RHS, DAGCombinerInfo &DCI) const;
SDValue performSelectCombine(SDNode *N, DAGCombinerInfo &DCI) const;
+ TargetLowering::NegatibleCost
+ getConstantNegateCost(const ConstantFPSDNode *C) const;
+
bool isConstantCostlierToNegate(SDValue N) const;
SDValue performFNegCombine(SDNode *N, DAGCombinerInfo &DCI) const;
SDValue performFAbsCombine(SDNode *N, DAGCombinerInfo &DCI) const;