mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Revert r237046. See the testcase on the thread where r237046 was committed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237317 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b96942f6ec
commit
172e8df4af
@ -665,7 +665,7 @@ public:
|
|||||||
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT);
|
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT);
|
||||||
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N);
|
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N);
|
||||||
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
||||||
const SDNodeFlags *Flags = nullptr);
|
bool nuw = false, bool nsw = false, bool exact = false);
|
||||||
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
||||||
SDValue N3);
|
SDValue N3);
|
||||||
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2,
|
||||||
@ -982,7 +982,8 @@ public:
|
|||||||
|
|
||||||
/// Get the specified node if it's already available, or else return NULL.
|
/// Get the specified node if it's already available, or else return NULL.
|
||||||
SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, ArrayRef<SDValue> Ops,
|
SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, ArrayRef<SDValue> Ops,
|
||||||
const SDNodeFlags *Flags = nullptr);
|
bool nuw = false, bool nsw = false,
|
||||||
|
bool exact = false);
|
||||||
|
|
||||||
/// Creates a SDDbgValue node.
|
/// Creates a SDDbgValue node.
|
||||||
SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R,
|
SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R,
|
||||||
@ -1240,8 +1241,8 @@ private:
|
|||||||
void allnodes_clear();
|
void allnodes_clear();
|
||||||
|
|
||||||
BinarySDNode *GetBinarySDNode(unsigned Opcode, SDLoc DL, SDVTList VTs,
|
BinarySDNode *GetBinarySDNode(unsigned Opcode, SDLoc DL, SDVTList VTs,
|
||||||
SDValue N1, SDValue N2,
|
SDValue N1, SDValue N2, bool nuw, bool nsw,
|
||||||
const SDNodeFlags *Flags = nullptr);
|
bool exact);
|
||||||
|
|
||||||
/// Look up the node specified by ID in CSEMap. If it exists, return it. If
|
/// Look up the node specified by ID in CSEMap. If it exists, return it. If
|
||||||
/// not, return the insertion token that will make insertion faster. This
|
/// not, return the insertion token that will make insertion faster. This
|
||||||
|
@ -1017,11 +1017,6 @@ static bool isBinOpWithFlags(unsigned Opcode) {
|
|||||||
case ISD::ADD:
|
case ISD::ADD:
|
||||||
case ISD::SUB:
|
case ISD::SUB:
|
||||||
case ISD::SHL:
|
case ISD::SHL:
|
||||||
case ISD::FADD:
|
|
||||||
case ISD::FDIV:
|
|
||||||
case ISD::FMUL:
|
|
||||||
case ISD::FREM:
|
|
||||||
case ISD::FSUB:
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -1034,8 +1029,8 @@ class BinaryWithFlagsSDNode : public BinarySDNode {
|
|||||||
public:
|
public:
|
||||||
SDNodeFlags Flags;
|
SDNodeFlags Flags;
|
||||||
BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
|
BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
|
||||||
SDValue X, SDValue Y, const SDNodeFlags &NodeFlags)
|
SDValue X, SDValue Y)
|
||||||
: BinarySDNode(Opc, Order, dl, VTs, X, Y), Flags(NodeFlags) {}
|
: BinarySDNode(Opc, Order, dl, VTs, X, Y), Flags() {}
|
||||||
static bool classof(const SDNode *N) {
|
static bool classof(const SDNode *N) {
|
||||||
return isBinOpWithFlags(N->getOpcode());
|
return isBinOpWithFlags(N->getOpcode());
|
||||||
}
|
}
|
||||||
|
@ -1452,9 +1452,12 @@ SDValue DAGCombiner::combine(SDNode *N) {
|
|||||||
if (isa<ConstantSDNode>(N0) || !isa<ConstantSDNode>(N1)) {
|
if (isa<ConstantSDNode>(N0) || !isa<ConstantSDNode>(N1)) {
|
||||||
SDValue Ops[] = {N1, N0};
|
SDValue Ops[] = {N1, N0};
|
||||||
SDNode *CSENode;
|
SDNode *CSENode;
|
||||||
if (const auto *BinNode = dyn_cast<BinaryWithFlagsSDNode>(N)) {
|
if (const BinaryWithFlagsSDNode *BinNode =
|
||||||
|
dyn_cast<BinaryWithFlagsSDNode>(N)) {
|
||||||
CSENode = DAG.getNodeIfExists(N->getOpcode(), N->getVTList(), Ops,
|
CSENode = DAG.getNodeIfExists(N->getOpcode(), N->getVTList(), Ops,
|
||||||
&BinNode->Flags);
|
BinNode->Flags.hasNoUnsignedWrap(),
|
||||||
|
BinNode->Flags.hasNoSignedWrap(),
|
||||||
|
BinNode->Flags.hasExact());
|
||||||
} else {
|
} else {
|
||||||
CSENode = DAG.getNodeIfExists(N->getOpcode(), N->getVTList(), Ops);
|
CSENode = DAG.getNodeIfExists(N->getOpcode(), N->getVTList(), Ops);
|
||||||
}
|
}
|
||||||
|
@ -399,22 +399,19 @@ static void AddNodeIDOperands(FoldingSetNodeID &ID,
|
|||||||
ID.AddInteger(Op.getResNo());
|
ID.AddInteger(Op.getResNo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Add logical or fast math flag values to FoldingSetNodeID value.
|
|
||||||
static void AddNodeIDFlags(FoldingSetNodeID &ID, unsigned Opcode,
|
|
||||||
const SDNodeFlags *Flags) {
|
|
||||||
if (!Flags || !isBinOpWithFlags(Opcode))
|
|
||||||
return;
|
|
||||||
|
|
||||||
unsigned RawFlags = Flags->getRawFlags();
|
static void AddBinaryNodeIDCustom(FoldingSetNodeID &ID, bool nuw, bool nsw,
|
||||||
// If no flags are set, do not alter the ID. This saves time and allows
|
bool exact) {
|
||||||
// a gradual increase in API usage of the optional optimization flags.
|
ID.AddBoolean(nuw);
|
||||||
if (RawFlags != 0)
|
ID.AddBoolean(nsw);
|
||||||
ID.AddInteger(RawFlags);
|
ID.AddBoolean(exact);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddNodeIDFlags(FoldingSetNodeID &ID, const SDNode *N) {
|
/// AddBinaryNodeIDCustom - Add BinarySDNodes special infos
|
||||||
if (auto *Node = dyn_cast<BinaryWithFlagsSDNode>(N))
|
static void AddBinaryNodeIDCustom(FoldingSetNodeID &ID, unsigned Opcode,
|
||||||
AddNodeIDFlags(ID, Node->getOpcode(), &Node->Flags);
|
bool nuw, bool nsw, bool exact) {
|
||||||
|
if (isBinOpWithFlags(Opcode))
|
||||||
|
AddBinaryNodeIDCustom(ID, nuw, nsw, exact);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddNodeIDNode(FoldingSetNodeID &ID, unsigned short OpC,
|
static void AddNodeIDNode(FoldingSetNodeID &ID, unsigned short OpC,
|
||||||
@ -509,6 +506,20 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
|
|||||||
ID.AddInteger(ST->getPointerInfo().getAddrSpace());
|
ID.AddInteger(ST->getPointerInfo().getAddrSpace());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ISD::SDIV:
|
||||||
|
case ISD::UDIV:
|
||||||
|
case ISD::SRA:
|
||||||
|
case ISD::SRL:
|
||||||
|
case ISD::MUL:
|
||||||
|
case ISD::ADD:
|
||||||
|
case ISD::SUB:
|
||||||
|
case ISD::SHL: {
|
||||||
|
const BinaryWithFlagsSDNode *BinNode = cast<BinaryWithFlagsSDNode>(N);
|
||||||
|
AddBinaryNodeIDCustom(
|
||||||
|
ID, N->getOpcode(), BinNode->Flags.hasNoUnsignedWrap(),
|
||||||
|
BinNode->Flags.hasNoSignedWrap(), BinNode->Flags.hasExact());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ISD::ATOMIC_CMP_SWAP:
|
case ISD::ATOMIC_CMP_SWAP:
|
||||||
case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
|
case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
|
||||||
case ISD::ATOMIC_SWAP:
|
case ISD::ATOMIC_SWAP:
|
||||||
@ -552,8 +563,6 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
|
|||||||
}
|
}
|
||||||
} // end switch (N->getOpcode())
|
} // end switch (N->getOpcode())
|
||||||
|
|
||||||
AddNodeIDFlags(ID, N);
|
|
||||||
|
|
||||||
// Target specific memory nodes could also have address spaces to check.
|
// Target specific memory nodes could also have address spaces to check.
|
||||||
if (N->isTargetMemoryOpcode())
|
if (N->isTargetMemoryOpcode())
|
||||||
ID.AddInteger(cast<MemSDNode>(N)->getPointerInfo().getAddrSpace());
|
ID.AddInteger(cast<MemSDNode>(N)->getPointerInfo().getAddrSpace());
|
||||||
@ -950,16 +959,14 @@ void SelectionDAG::allnodes_clear() {
|
|||||||
|
|
||||||
BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL,
|
BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL,
|
||||||
SDVTList VTs, SDValue N1,
|
SDVTList VTs, SDValue N1,
|
||||||
SDValue N2,
|
SDValue N2, bool nuw, bool nsw,
|
||||||
const SDNodeFlags *Flags) {
|
bool exact) {
|
||||||
if (isBinOpWithFlags(Opcode)) {
|
if (isBinOpWithFlags(Opcode)) {
|
||||||
// If no flags were passed in, use a default flags object.
|
|
||||||
SDNodeFlags F;
|
|
||||||
if (Flags == nullptr)
|
|
||||||
Flags = &F;
|
|
||||||
|
|
||||||
BinaryWithFlagsSDNode *FN = new (NodeAllocator) BinaryWithFlagsSDNode(
|
BinaryWithFlagsSDNode *FN = new (NodeAllocator) BinaryWithFlagsSDNode(
|
||||||
Opcode, DL.getIROrder(), DL.getDebugLoc(), VTs, N1, N2, *Flags);
|
Opcode, DL.getIROrder(), DL.getDebugLoc(), VTs, N1, N2);
|
||||||
|
FN->Flags.setNoUnsignedWrap(nuw);
|
||||||
|
FN->Flags.setNoSignedWrap(nsw);
|
||||||
|
FN->Flags.setExact(exact);
|
||||||
|
|
||||||
return FN;
|
return FN;
|
||||||
}
|
}
|
||||||
@ -3229,7 +3236,7 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, SDLoc DL, EVT VT,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1,
|
SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1,
|
||||||
SDValue N2, const SDNodeFlags *Flags) {
|
SDValue N2, bool nuw, bool nsw, bool exact) {
|
||||||
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.getNode());
|
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.getNode());
|
||||||
ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.getNode());
|
ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.getNode());
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
@ -3693,20 +3700,22 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1,
|
|||||||
// Memoize this node if possible.
|
// Memoize this node if possible.
|
||||||
BinarySDNode *N;
|
BinarySDNode *N;
|
||||||
SDVTList VTs = getVTList(VT);
|
SDVTList VTs = getVTList(VT);
|
||||||
|
const bool BinOpHasFlags = isBinOpWithFlags(Opcode);
|
||||||
if (VT != MVT::Glue) {
|
if (VT != MVT::Glue) {
|
||||||
SDValue Ops[] = {N1, N2};
|
SDValue Ops[] = {N1, N2};
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
AddNodeIDNode(ID, Opcode, VTs, Ops);
|
AddNodeIDNode(ID, Opcode, VTs, Ops);
|
||||||
AddNodeIDFlags(ID, Opcode, Flags);
|
if (BinOpHasFlags)
|
||||||
|
AddBinaryNodeIDCustom(ID, Opcode, nuw, nsw, exact);
|
||||||
void *IP = nullptr;
|
void *IP = nullptr;
|
||||||
if (SDNode *E = FindNodeOrInsertPos(ID, DL.getDebugLoc(), IP))
|
if (SDNode *E = FindNodeOrInsertPos(ID, DL.getDebugLoc(), IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
|
|
||||||
N = GetBinarySDNode(Opcode, DL, VTs, N1, N2, Flags);
|
N = GetBinarySDNode(Opcode, DL, VTs, N1, N2, nuw, nsw, exact);
|
||||||
|
|
||||||
CSEMap.InsertNode(N, IP);
|
CSEMap.InsertNode(N, IP);
|
||||||
} else {
|
} else {
|
||||||
N = GetBinarySDNode(Opcode, DL, VTs, N1, N2, Flags);
|
N = GetBinarySDNode(Opcode, DL, VTs, N1, N2, nuw, nsw, exact);
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertNode(N);
|
InsertNode(N);
|
||||||
@ -6010,12 +6019,13 @@ SelectionDAG::getTargetInsertSubreg(int SRIdx, SDLoc DL, EVT VT,
|
|||||||
/// getNodeIfExists - Get the specified node if it's already available, or
|
/// getNodeIfExists - Get the specified node if it's already available, or
|
||||||
/// else return NULL.
|
/// else return NULL.
|
||||||
SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
|
SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
|
||||||
ArrayRef<SDValue> Ops,
|
ArrayRef<SDValue> Ops, bool nuw, bool nsw,
|
||||||
const SDNodeFlags *Flags) {
|
bool exact) {
|
||||||
if (VTList.VTs[VTList.NumVTs - 1] != MVT::Glue) {
|
if (VTList.VTs[VTList.NumVTs - 1] != MVT::Glue) {
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
AddNodeIDNode(ID, Opcode, VTList, Ops);
|
AddNodeIDNode(ID, Opcode, VTList, Ops);
|
||||||
AddNodeIDFlags(ID, Opcode, Flags);
|
if (isBinOpWithFlags(Opcode))
|
||||||
|
AddBinaryNodeIDCustom(ID, nuw, nsw, exact);
|
||||||
void *IP = nullptr;
|
void *IP = nullptr;
|
||||||
if (SDNode *E = FindNodeOrInsertPos(ID, DebugLoc(), IP))
|
if (SDNode *E = FindNodeOrInsertPos(ID, DebugLoc(), IP))
|
||||||
return E;
|
return E;
|
||||||
|
@ -2139,8 +2139,6 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned OpCode) {
|
|||||||
bool nuw = false;
|
bool nuw = false;
|
||||||
bool nsw = false;
|
bool nsw = false;
|
||||||
bool exact = false;
|
bool exact = false;
|
||||||
FastMathFlags FMF;
|
|
||||||
|
|
||||||
if (const OverflowingBinaryOperator *OFBinOp =
|
if (const OverflowingBinaryOperator *OFBinOp =
|
||||||
dyn_cast<const OverflowingBinaryOperator>(&I)) {
|
dyn_cast<const OverflowingBinaryOperator>(&I)) {
|
||||||
nuw = OFBinOp->hasNoUnsignedWrap();
|
nuw = OFBinOp->hasNoUnsignedWrap();
|
||||||
@ -2149,20 +2147,9 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned OpCode) {
|
|||||||
if (const PossiblyExactOperator *ExactOp =
|
if (const PossiblyExactOperator *ExactOp =
|
||||||
dyn_cast<const PossiblyExactOperator>(&I))
|
dyn_cast<const PossiblyExactOperator>(&I))
|
||||||
exact = ExactOp->isExact();
|
exact = ExactOp->isExact();
|
||||||
if (const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(&I))
|
|
||||||
FMF = FPOp->getFastMathFlags();
|
|
||||||
|
|
||||||
SDNodeFlags Flags;
|
|
||||||
Flags.setExact(exact);
|
|
||||||
Flags.setNoSignedWrap(nsw);
|
|
||||||
Flags.setNoUnsignedWrap(nuw);
|
|
||||||
Flags.setAllowReciprocal(FMF.allowReciprocal());
|
|
||||||
Flags.setNoInfs(FMF.noInfs());
|
|
||||||
Flags.setNoNaNs(FMF.noNaNs());
|
|
||||||
Flags.setNoSignedZeros(FMF.noSignedZeros());
|
|
||||||
Flags.setUnsafeAlgebra(FMF.unsafeAlgebra());
|
|
||||||
SDValue BinNodeValue = DAG.getNode(OpCode, getCurSDLoc(), Op1.getValueType(),
|
SDValue BinNodeValue = DAG.getNode(OpCode, getCurSDLoc(), Op1.getValueType(),
|
||||||
Op1, Op2, &Flags);
|
Op1, Op2, nuw, nsw, exact);
|
||||||
setValue(&I, BinNodeValue);
|
setValue(&I, BinNodeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2210,12 +2197,9 @@ void SelectionDAGBuilder::visitShift(const User &I, unsigned Opcode) {
|
|||||||
dyn_cast<const PossiblyExactOperator>(&I))
|
dyn_cast<const PossiblyExactOperator>(&I))
|
||||||
exact = ExactOp->isExact();
|
exact = ExactOp->isExact();
|
||||||
}
|
}
|
||||||
SDNodeFlags Flags;
|
|
||||||
Flags.setExact(exact);
|
|
||||||
Flags.setNoSignedWrap(nsw);
|
|
||||||
Flags.setNoUnsignedWrap(nuw);
|
|
||||||
SDValue Res = DAG.getNode(Opcode, getCurSDLoc(), Op1.getValueType(), Op1, Op2,
|
SDValue Res = DAG.getNode(Opcode, getCurSDLoc(), Op1.getValueType(), Op1, Op2,
|
||||||
&Flags);
|
nuw, nsw, exact);
|
||||||
setValue(&I, Res);
|
setValue(&I, Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2660,9 +2660,8 @@ SDValue TargetLowering::BuildExactSDIV(SDValue Op1, SDValue Op2, SDLoc dl,
|
|||||||
// TODO: For UDIV use SRL instead of SRA.
|
// TODO: For UDIV use SRL instead of SRA.
|
||||||
SDValue Amt =
|
SDValue Amt =
|
||||||
DAG.getConstant(ShAmt, dl, getShiftAmountTy(Op1.getValueType()));
|
DAG.getConstant(ShAmt, dl, getShiftAmountTy(Op1.getValueType()));
|
||||||
SDNodeFlags Flags;
|
Op1 = DAG.getNode(ISD::SRA, dl, Op1.getValueType(), Op1, Amt, false, false,
|
||||||
Flags.setExact(true);
|
true);
|
||||||
Op1 = DAG.getNode(ISD::SRA, dl, Op1.getValueType(), Op1, Amt, &Flags);
|
|
||||||
d = d.ashr(ShAmt);
|
d = d.ashr(ShAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user