Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6714,6 +6714,9 @@ static SDValue foldAndOrOfSETCC(SDNode *LogicOp, SelectionDAG &DAG) {
DAG, isFMAXNUMFMINNUM_IEEE, isFMAXNUMFMINNUM);

if (NewOpcode != ISD::DELETED_NODE) {
// Propagate fast-math flags from setcc.
SelectionDAG::FlagInserter FlagInserter(DAG, LHS->getFlags() &
RHS->getFlags());
SDValue MinMaxValue =
DAG.getNode(NewOpcode, DL, OpVT, Operand1, Operand2);
return DAG.getSetCC(DL, VT, MinMaxValue, CommonValue, CC);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3757,7 +3757,7 @@ void SelectionDAGBuilder::visitFCmp(const FCmpInst &I) {

ISD::CondCode Condition = getFCmpCondCode(predicate);
auto *FPMO = cast<FPMathOperator>(&I);
if (FPMO->hasNoNaNs() || TM.Options.NoNaNsFPMath)
if (FPMO->hasNoNaNs())
Condition = getFCmpCodeWithoutNaN(Condition);

SDNodeFlags Flags;
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14306,14 +14306,15 @@ SDValue SITargetLowering::performRcpCombine(SDNode *N,
}

bool SITargetLowering::isCanonicalized(SelectionDAG &DAG, SDValue Op,
SDNodeFlags UserFlags,
unsigned MaxDepth) const {
unsigned Opcode = Op.getOpcode();
if (Opcode == ISD::FCANONICALIZE)
return true;

if (auto *CFP = dyn_cast<ConstantFPSDNode>(Op)) {
const auto &F = CFP->getValueAPF();
if (F.isNaN() && F.isSignaling())
if ((UserFlags.hasNoNaNs() || F.isNaN()) && F.isSignaling())
return false;
if (!F.isDenormal())
return true;
Expand Down Expand Up @@ -14505,7 +14506,7 @@ bool SITargetLowering::isCanonicalized(SelectionDAG &DAG, SDValue Op,

// FIXME: denormalsEnabledForType is broken for dynamic
return denormalsEnabledForType(DAG, Op.getValueType()) &&
DAG.isKnownNeverSNaN(Op);
(UserFlags.hasNoNaNs() || DAG.isKnownNeverSNaN(Op));
}

bool SITargetLowering::isCanonicalized(Register Reg, const MachineFunction &MF,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class SITargetLowering final : public AMDGPUTargetLowering {
Register N1) const override;

bool isCanonicalized(SelectionDAG &DAG, SDValue Op,
unsigned MaxDepth = 5) const;
SDNodeFlags UserFlags = {}, unsigned MaxDepth = 5) const;
bool isCanonicalized(Register Reg, const MachineFunction &MF,
unsigned MaxDepth = 5) const;
bool denormalsEnabledForType(const SelectionDAG &DAG, EVT VT) const;
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1001,11 +1001,13 @@ def MFMALdScaleXForm : SDNodeXForm<timm, [{
return CurDAG->getTargetConstant(New, SDLoc(N), MVT::i32);
}]>;

def is_canonicalized : PatLeaf<(fAny srcvalue:$src), [{
const SITargetLowering &Lowering =
def fcanonicalize_canonicalized
: PatFrag<(ops node:$op), (fcanonicalize node:$op), [{
const SITargetLowering &Lowering =
*static_cast<const SITargetLowering *>(getTargetLowering());
return Lowering.isCanonicalized(*CurDAG, Op);
return Lowering.isCanonicalized(*CurDAG, Op->getOperand(0), N->getFlags());
}]> {
// FIXME: This predicate for GlobalISel is dead code.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless the change, this predicate doesn't take part in instruction selection.

let GISelPredicateCode = [{
const SITargetLowering *TLI = static_cast<const SITargetLowering *>(
MF.getSubtarget().getTargetLowering());
Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/Target/AMDGPU/SIInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -3459,10 +3459,7 @@ def : GCNPat<
// If fcanonicalize's operand is implicitly canonicalized, we only need a copy.
let AddedComplexity = 8 in {
foreach vt = [f16, v2f16, f32, v2f32, f64] in {
def : GCNPat<
(fcanonicalize (vt is_canonicalized:$src)),
(COPY vt:$src)
>;
def : GCNPat<(fcanonicalize_canonicalized vt:$src), (COPY vt:$src)>;
}
}

Expand Down
Loading