In MipsDAGToDAGISel::SelectAddr, fold add node into address operand, if its
authorAkira Hatanaka <ahatanaka@mips.com>
Fri, 24 Aug 2012 20:21:49 +0000 (20:21 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Fri, 24 Aug 2012 20:21:49 +0000 (20:21 +0000)
second operand is MipsISD::GPRel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162584 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsISelDAGToDAG.cpp
test/CodeGen/Mips/small-section-reserve-gp.ll

index 5a97c17ec851316d162f5ed3ca5fa3d197ea4d56..4205223923e30412f278dadc1cfd9666f89e0efd 100644 (file)
@@ -337,8 +337,9 @@ SelectAddr(SDNode *Parent, SDValue Addr, SDValue &Base, SDValue &Offset) {
     // Generate:
     //  lui $2, %hi($CPI1_0)
     //  lwc1 $f0, %lo($CPI1_0)($2)
-    if (Addr.getOperand(1).getOpcode() == MipsISD::Lo) {
-      SDValue LoVal = Addr.getOperand(1), Opnd0 = LoVal.getOperand(0);
+    if (Addr.getOperand(1).getOpcode() == MipsISD::Lo ||
+        Addr.getOperand(1).getOpcode() == MipsISD::GPRel) {
+      SDValue Opnd0 = Addr.getOperand(1).getOperand(0);
       if (isa<ConstantPoolSDNode>(Opnd0) || isa<GlobalAddressSDNode>(Opnd0) ||
           isa<JumpTableSDNode>(Opnd0)) {
         Base = Addr.getOperand(0);
index fc251cb612773981431dbca4ecca6305307dfbbf..03503fb2ae18e4e5a0b895c5c7f04937b889e05d 100644 (file)
@@ -5,7 +5,7 @@
 
 define i32 @geti() nounwind readonly {
 entry:
-; CHECK: addiu ${{[0-9]+}}, $gp, %gp_rel(i)
+; CHECK: lw ${{[0-9]+}}, %gp_rel(i)($gp)
   %0 = load i32* @i, align 4
   ret i32 %0
 }