Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.423 -> 1.424 SelectionDAG.cpp updated: 1.401 -> 1.402 DAGCombiner.cpp updated: 1.295 -> 1.296 --- Log message: PR400: http://llvm.org/PR400 phase 2. Propagate attributed load/store information through DAGs. --- Diffs of the changes: (+112 -36) DAGCombiner.cpp | 70 +++++++++++++++++++++++++++++++++++++-------------- SelectionDAG.cpp | 66 +++++++++++++++++++++++++++++++++++++++--------- SelectionDAGISel.cpp | 12 +++++--- 3 files changed, 112 insertions(+), 36 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.423 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.424 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.423 Sat Apr 21 13:36:27 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Apr 22 18:15:29 2007 @@ -498,7 +498,7 @@ SDOperand getLoadFrom(const Type *Ty, SDOperand Ptr, const Value *SV, SDOperand Root, - bool isVolatile); + bool isVolatile, unsigned Alignment); SDOperand getIntPtrConstant(uint64_t Val) { return DAG.getConstant(Val, TLI.getPointerTy()); @@ -2313,19 +2313,21 @@ } setValue(&I, getLoadFrom(I.getType(), Ptr, I.getOperand(0), - Root, I.isVolatile())); + Root, I.isVolatile(), I.getAlignment())); } SDOperand SelectionDAGLowering::getLoadFrom(const Type *Ty, SDOperand Ptr, const Value *SV, SDOperand Root, - bool isVolatile) { + bool isVolatile, + unsigned Alignment) { SDOperand L; if (const VectorType *PTy = dyn_cast<VectorType>(Ty)) { MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); L = DAG.getVecLoad(PTy->getNumElements(), PVT, Root, Ptr, DAG.getSrcValue(SV)); } else { - L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, SV, 0, isVolatile); + L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, SV, 0, + isVolatile, Alignment); } if (isVolatile) @@ -2342,7 +2344,7 @@ SDOperand Src = getValue(SrcV); SDOperand Ptr = getValue(I.getOperand(1)); DAG.setRoot(DAG.getStore(getRoot(), Src, Ptr, I.getOperand(1), 0, - I.isVolatile())); + I.isVolatile(), I.getAlignment())); } /// IntrinsicCannotAccessMemory - Return true if the specified intrinsic cannot Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.401 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.402 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.401 Sat Apr 21 15:56:26 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Apr 22 18:15:30 2007 @@ -15,11 +15,13 @@ #include "llvm/Constants.h" #include "llvm/GlobalVariable.h" #include "llvm/Intrinsics.h" +#include "llvm/DerivedTypes.h" #include "llvm/Assembly/Writer.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/MRegisterInfo.h" +#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" @@ -1538,9 +1540,7 @@ SDOperand SelectionDAG::getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr, const Value *SV, int SVOffset, - bool isVolatile) { - // FIXME: Alignment == 1 for now. - unsigned Alignment = 1; + bool isVolatile, unsigned Alignment) { SDVTList VTs = getVTList(VT, MVT::Other); SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType()); SDOperand Ops[] = { Chain, Ptr, Undef }; @@ -1556,6 +1556,18 @@ void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDOperand(E, 0); + if (Alignment == 0) { // Ensure that codegen never sees alignment 0 + const Type *Ty = 0; + if (VT != MVT::Vector && VT != MVT::iPTR) { + Ty = MVT::getTypeForValueType(VT); + } else if (SV) { + const PointerType *PT = dyn_cast<PointerType>(SV->getType()); + assert(PT && "Value for load must be a pointer"); + Ty = PT->getElementType(); + } + assert(Ty && "Could not get type information for load"); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ISD::NON_EXTLOAD, VT, SV, SVOffset, Alignment, isVolatile); @@ -1568,7 +1580,7 @@ SDOperand Chain, SDOperand Ptr, const Value *SV, int SVOffset, MVT::ValueType EVT, - bool isVolatile) { + bool isVolatile, unsigned Alignment) { // If they are asking for an extending load from/to the same thing, return a // normal load. if (VT == EVT) @@ -1583,8 +1595,6 @@ assert(MVT::isInteger(VT) == MVT::isInteger(EVT) && "Cannot convert from FP to Int or Int -> FP!"); - // FIXME: Alignment == 1 for now. - unsigned Alignment = 1; SDVTList VTs = getVTList(VT, MVT::Other); SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType()); SDOperand Ops[] = { Chain, Ptr, Undef }; @@ -1600,6 +1610,18 @@ void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDOperand(E, 0); + if (Alignment == 0) { // Ensure that codegen never sees alignment 0 + const Type *Ty = 0; + if (VT != MVT::Vector && VT != MVT::iPTR) { + Ty = MVT::getTypeForValueType(VT); + } else if (SV) { + const PointerType *PT = dyn_cast<PointerType>(SV->getType()); + assert(PT && "Value for load must be a pointer"); + Ty = PT->getElementType(); + } + assert(Ty && "Could not get type information for load"); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ExtType, EVT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); @@ -1647,11 +1669,9 @@ SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Val, SDOperand Ptr, const Value *SV, int SVOffset, - bool isVolatile) { + bool isVolatile, unsigned Alignment) { MVT::ValueType VT = Val.getValueType(); - // FIXME: Alignment == 1 for now. - unsigned Alignment = 1; SDVTList VTs = getVTList(MVT::Other); SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType()); SDOperand Ops[] = { Chain, Val, Ptr, Undef }; @@ -1667,6 +1687,18 @@ void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDOperand(E, 0); + if (Alignment == 0) { // Ensure that codegen never sees alignment 0 + const Type *Ty = 0; + if (VT != MVT::Vector && VT != MVT::iPTR) { + Ty = MVT::getTypeForValueType(VT); + } else if (SV) { + const PointerType *PT = dyn_cast<PointerType>(SV->getType()); + assert(PT && "Value for store must be a pointer"); + Ty = PT->getElementType(); + } + assert(Ty && "Could not get type information for store"); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, false, VT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); @@ -1677,7 +1709,7 @@ SDOperand SelectionDAG::getTruncStore(SDOperand Chain, SDOperand Val, SDOperand Ptr, const Value *SV, int SVOffset, MVT::ValueType SVT, - bool isVolatile) { + bool isVolatile, unsigned Alignment) { MVT::ValueType VT = Val.getValueType(); bool isTrunc = VT != SVT; @@ -1685,8 +1717,6 @@ assert(MVT::isInteger(VT) == MVT::isInteger(SVT) && "Can't do FP-INT conversion!"); - // FIXME: Alignment == 1 for now. - unsigned Alignment = 1; SDVTList VTs = getVTList(MVT::Other); SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType()); SDOperand Ops[] = { Chain, Val, Ptr, Undef }; @@ -1702,6 +1732,18 @@ void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) return SDOperand(E, 0); + if (Alignment == 0) { // Ensure that codegen never sees alignment 0 + const Type *Ty = 0; + if (VT != MVT::Vector && VT != MVT::iPTR) { + Ty = MVT::getTypeForValueType(VT); + } else if (SV) { + const PointerType *PT = dyn_cast<PointerType>(SV->getType()); + assert(PT && "Value for store must be a pointer"); + Ty = PT->getElementType(); + } + assert(Ty && "Could not get type information for store"); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, isTrunc, SVT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.295 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.296 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.295 Sat Apr 21 13:36:27 2007 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Apr 22 18:15:30 2007 @@ -1263,7 +1263,9 @@ (!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) { SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1)); return SDOperand(N, 0); // Return N so it doesn't get rechecked! @@ -1280,7 +1282,9 @@ (!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) { SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1)); return SDOperand(N, 0); // Return N so it doesn't get rechecked! @@ -1320,7 +1324,8 @@ AddToWorkList(NewPtr.Val); SDOperand Load = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), NewPtr, - LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT); + LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.Val, Load, Load.getValue(1)); return SDOperand(N, 0); // Return N so it doesn't get rechecked! @@ -2120,7 +2125,8 @@ SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - N0.getValueType()); + N0.getValueType(), + LN0->isVolatile()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2136,7 +2142,9 @@ if (!AfterLegalize || TLI.isLoadXLegal(ISD::SEXTLOAD, EVT)) { SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2212,7 +2220,9 @@ SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - N0.getValueType()); + N0.getValueType(), + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2227,7 +2237,9 @@ MVT::ValueType EVT = LN0->getLoadedVT(); SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2303,7 +2315,9 @@ SDOperand ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - N0.getValueType()); + N0.getValueType(), + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2321,7 +2335,9 @@ SDOperand ExtLoad = DAG.getExtLoad(LN0->getExtensionType(), VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -2398,9 +2414,11 @@ AddToWorkList(NewPtr.Val); SDOperand Load = (ExtType == ISD::NON_EXTLOAD) ? DAG.getLoad(VT, LN0->getChain(), NewPtr, - LN0->getSrcValue(), LN0->getSrcValueOffset()) + LN0->getSrcValue(), LN0->getSrcValueOffset(), + LN0->isVolatile(), LN0->getAlignment()) : DAG.getExtLoad(ExtType, VT, LN0->getChain(), NewPtr, - LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT); + LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), LN0->getAlignment()); AddToWorkList(N); if (CombineSRL) { std::vector<SDNode*> NowDead; @@ -2479,7 +2497,9 @@ LoadSDNode *LN0 = cast<LoadSDNode>(N0); SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1)); return SDOperand(N, 0); // Return N so it doesn't get rechecked! @@ -2492,7 +2512,9 @@ LoadSDNode *LN0 = cast<LoadSDNode>(N0); SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), - LN0->getSrcValueOffset(), EVT); + LN0->getSrcValueOffset(), EVT, + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1)); return SDOperand(N, 0); // Return N so it doesn't get rechecked! @@ -2552,7 +2574,8 @@ if (0 && ISD::isNON_EXTLoad(N0.Val) && N0.hasOneUse()) { LoadSDNode *LN0 = cast<LoadSDNode>(N0); SDOperand Load = DAG.getLoad(VT, LN0->getChain(), LN0->getBasePtr(), - LN0->getSrcValue(), LN0->getSrcValueOffset()); + LN0->getSrcValue(), LN0->getSrcValueOffset(), + LN0->isVolatile(), LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load), Load.getValue(1)); @@ -2942,7 +2965,9 @@ SDOperand ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - N0.getValueType()); + N0.getValueType(), + LN0->isVolatile(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.Val, DAG.getNode(ISD::FP_ROUND, N0.getValueType(), ExtLoad), ExtLoad.getValue(1)); @@ -3331,13 +3356,16 @@ // Replace the chain to void dependency. if (LD->getExtensionType() == ISD::NON_EXTLOAD) { ReplLoad = DAG.getLoad(N->getValueType(0), BetterChain, Ptr, - LD->getSrcValue(), LD->getSrcValueOffset()); + LD->getSrcValue(), LD->getSrcValueOffset(), + LD->isVolatile(), LD->getAlignment()); } else { ReplLoad = DAG.getExtLoad(LD->getExtensionType(), LD->getValueType(0), BetterChain, Ptr, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->getLoadedVT()); + LD->getLoadedVT(), + LD->isVolatile(), + LD->getAlignment()); } // Create token factor to keep old chain connected. @@ -4040,13 +4068,17 @@ if (LLD->getExtensionType() == ISD::NON_EXTLOAD) Load = DAG.getLoad(TheSelect->getValueType(0), LLD->getChain(), Addr,LLD->getSrcValue(), - LLD->getSrcValueOffset()); + LLD->getSrcValueOffset(), + LLD->isVolatile(), + LLD->getAlignment()); else { Load = DAG.getExtLoad(LLD->getExtensionType(), TheSelect->getValueType(0), LLD->getChain(), Addr, LLD->getSrcValue(), LLD->getSrcValueOffset(), - LLD->getLoadedVT()); + LLD->getLoadedVT(), + LLD->isVolatile(), + LLD->getAlignment()); } // Users of the select now use the result of the load. CombineTo(TheSelect, Load); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits