diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-04-24 04:44:57 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-04-24 04:44:57 +0000 |
commit | c82c20b315d47c124893ed1cb27c39b0050fd227 (patch) | |
tree | 450633f420b6e43e34877a6cde404acfd0d3b642 /lib | |
parent | 95c57ea1825fedc10dc2a311b0d97105f6e61148 (diff) |
Avoid promoting a i16 node if it would eliminate a (store (op (load))) opportunity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102237 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index b8fc7e6612..2060dbf312 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -10015,6 +10015,14 @@ bool X86TargetLowering::isTypeDesirableForOp(unsigned Opc, EVT VT) const { } } +static bool MayFoldLoad(SDValue Op) { + return Op.hasOneUse() && ISD::isNormalLoad(Op.getNode()); +} + +static bool MayFoldIntoStore(SDValue Op) { + return Op.hasOneUse() && ISD::isNormalStore(*Op.getNode()->use_begin()); +} + /// IsDesirableToPromoteOp - This method query the target whether it is /// beneficial for dag combiner to promote the specified node. If true, it /// should return the desired promotion type by reference. @@ -10051,8 +10059,7 @@ bool X86TargetLowering::IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const { case ISD::SRL: { SDValue N0 = Op.getOperand(0); // Look out for (store (shl (load), x)). - if (isa<LoadSDNode>(N0) && N0.hasOneUse() && - Op.hasOneUse() && Op.getNode()->use_begin()->getOpcode() == ISD::STORE) + if (MayFoldLoad(N0) && MayFoldIntoStore(Op)) return false; Promote = true; break; @@ -10067,12 +10074,12 @@ bool X86TargetLowering::IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const { case ISD::SUB: { SDValue N0 = Op.getOperand(0); SDValue N1 = Op.getOperand(1); - if (!Commute && isa<LoadSDNode>(N1)) + if (!Commute && MayFoldLoad(N1)) return false; // Avoid disabling potential load folding opportunities. - if ((isa<LoadSDNode>(N0) && N0.hasOneUse()) && !isa<ConstantSDNode>(N1)) + if (MayFoldLoad(N0) && (!isa<ConstantSDNode>(N1) || MayFoldIntoStore(Op))) return false; - if ((isa<LoadSDNode>(N1) && N1.hasOneUse()) && !isa<ConstantSDNode>(N0)) + if (MayFoldLoad(N1) && (!isa<ConstantSDNode>(N0) || MayFoldIntoStore(Op))) return false; Promote = true; } |