Fold the add (ptr, offset) into ptr[offset] only if the offset is small enough. movwi...
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Tue, 23 Jun 2009 07:10:19 +0000 (07:10 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Tue, 23 Jun 2009 07:10:19 +0000 (07:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73953 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PIC16/PIC16ISelLowering.cpp

index f113a483d692461d42e2da78217995783f2a1372..122af70546d97813f9c2ccf0a8d47828a069b874 100644 (file)
@@ -702,10 +702,12 @@ void PIC16TargetLowering::LegalizeAddress(SDValue Ptr, SelectionDAG &DAG,
   if (Ptr.getOpcode() == ISD::ADD) {
     SDValue OperLeft = Ptr.getOperand(0);
     SDValue OperRight = Ptr.getOperand(1);
-    if (OperLeft.getOpcode() == ISD::Constant) {
+    if ((OperLeft.getOpcode() == ISD::Constant) &&
+        (dyn_cast<ConstantSDNode>(OperLeft)->getZExtValue() < 32 )) {
       Offset = dyn_cast<ConstantSDNode>(OperLeft)->getZExtValue();
       Ptr = OperRight;
-    } else if (OperRight.getOpcode() == ISD::Constant) {
+    } else if ((OperRight.getOpcode() == ISD::Constant)  &&
+               (dyn_cast<ConstantSDNode>(OperRight)->getZExtValue() < 32 )){
       Offset = dyn_cast<ConstantSDNode>(OperRight)->getZExtValue();
       Ptr = OperLeft;
     }