[llvm-commits] [llvm] r102237 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Evan Cheng
evan.cheng at apple.com
Fri Apr 23 21:44:57 PDT 2010
Author: evancheng
Date: Fri Apr 23 23:44:57 2010
New Revision: 102237
URL: http://llvm.org/viewvc/llvm-project?rev=102237&view=rev
Log:
Avoid promoting a i16 node if it would eliminate a (store (op (load))) opportunity.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=102237&r1=102236&r2=102237&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 23 23:44:57 2010
@@ -10015,6 +10015,14 @@
}
}
+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 @@
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 @@
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;
}
More information about the llvm-commits
mailing list