[AArch64 costs 17/18] Cost for SYMBOL_REF, HIGH and LO_SUM 81/41181/1
authorjgreenhalgh <jgreenhalgh@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 May 2014 09:25:48 +0000 (09:25 +0000)
committerNikolai Bozhenov <n.bozhenov@samsung.com>
Thu, 11 Jun 2015 11:07:03 +0000 (14:07 +0300)
git cherry-pick d369e66

gcc/

* config/aarch64/aarch64.c (aarch64_rtx_costs): Cost SYMBOL_REF,
HIGH, LO_SUM.

Change-Id: I94ed46b7c88e3c0bed08ea46f1a08bc15f49618d
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210509 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/aarch64/aarch64.c

index cbba9a9..9c8fa5a 100644 (file)
@@ -1,4 +1,9 @@
 2014-05-16  James Greenhalgh  <james.greenhalgh@arm.com>
+
+       * config/aarch64/aarch64.c (aarch64_rtx_costs): Cost SYMBOL_REF,
+       HIGH, LO_SUM.
+
+2014-05-16  James Greenhalgh  <james.greenhalgh@arm.com>
            Philipp Tomsich  <philipp.tomsich@theobroma-systems.com>
 
        * config/aarch64/aarch64.c (aarch64_rtx_costs): Cost TRUNCATE.
index 5ebf162..f22bb6a 100644 (file)
@@ -5440,15 +5440,44 @@ cost_plus:
          return false;  /* All arguments need to be in registers.  */
        }
 
-    case HIGH:
-      if (!CONSTANT_P (XEXP (x, 0)))
-       *cost += rtx_cost (XEXP (x, 0), HIGH, 0, speed);
+    case SYMBOL_REF:
+
+      if (aarch64_cmodel == AARCH64_CMODEL_LARGE)
+       {
+         /* LDR.  */
+         if (speed)
+           *cost += extra_cost->ldst.load;
+       }
+      else if (aarch64_cmodel == AARCH64_CMODEL_SMALL
+              || aarch64_cmodel == AARCH64_CMODEL_SMALL_PIC)
+       {
+         /* ADRP, followed by ADD.  */
+         *cost += COSTS_N_INSNS (1);
+         if (speed)
+           *cost += 2 * extra_cost->alu.arith;
+       }
+      else if (aarch64_cmodel == AARCH64_CMODEL_TINY
+              || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
+       {
+         /* ADR.  */
+         if (speed)
+           *cost += extra_cost->alu.arith;
+       }
+
+      if (flag_pic)
+       {
+         /* One extra load instruction, after accessing the GOT.  */
+         *cost += COSTS_N_INSNS (1);
+         if (speed)
+           *cost += extra_cost->ldst.load;
+       }
       return true;
 
+    case HIGH:
     case LO_SUM:
-      if (!CONSTANT_P (XEXP (x, 1)))
-       *cost += rtx_cost (XEXP (x, 1), LO_SUM, 1, speed);
-      *cost += rtx_cost (XEXP (x, 0), LO_SUM, 0, speed);
+      /* ADRP/ADD (immediate).  */
+      if (speed)
+       *cost += extra_cost->alu.arith;
       return true;
 
     case ZERO_EXTRACT: