Do not emit loads multiple times, potentially in the wrong places.
authorChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2005 04:18:32 +0000 (04:18 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2005 04:18:32 +0000 (04:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19661 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelPattern.cpp

index 7b465cd84ca90f10a35316dd87b96cc753a1a847..4db13aa9ec2655a3ee995cbe04e4bfaa254d08a7 100644 (file)
@@ -573,7 +573,7 @@ bool ISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM) {
           // Okay, we know that we have a scale by now.  However, if the scaled
           // value is an add of something and a constant, we can fold the
           // constant into the disp field here.
-          if (ShVal.Val->getOpcode() == ISD::ADD && !ExprMap.count(ShVal) &&
+          if (ShVal.Val->getOpcode() == ISD::ADD && ShVal.hasOneUse() &&
               isa<ConstantSDNode>(ShVal.Val->getOperand(1))) {
             AM.IndexReg = ShVal.Val->getOperand(0);
             ConstantSDNode *AddVal =
@@ -604,7 +604,7 @@ bool ISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM) {
           // Okay, we know that we have a scale by now.  However, if the scaled
           // value is an add of something and a constant, we can fold the
           // constant into the disp field here.
-          if (MulVal.Val->getOpcode() == ISD::ADD && !ExprMap.count(MulVal) &&
+          if (MulVal.Val->getOpcode() == ISD::ADD && MulVal.hasOneUse() &&
               isa<ConstantSDNode>(MulVal.Val->getOperand(1))) {
             Reg = MulVal.Val->getOperand(0);
             ConstantSDNode *AddVal =