diff mbox

[PR,target/65103,3/3] Change rtx cost for i386 address constants

Message ID 20150513082054.GC47912@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich May 13, 2015, 8:20 a.m. UTC
On 12 May 17:33, Uros Bizjak wrote:
> Hello!
> 
> >> 2015-03-10  Ilya Enkovich  <ilya.enkovich@intel.com>
> >>
> >>         PR target/65103
> >>         * config/i386/i386.c (ix86_rtx_costs): We want to propagate
> >>         link time constants into adress expressions and therefore set
> >>         their cost to 0.
> >>
> >> gcc/testsuite/
> >>
> >> 2015-03-10  Ilya Enkovich  <ilya.enkovich@intel.com>
> >>
> >>         PR target/65103
> >>         * gcc.target/i386/pr65103-3.c: New.
> >>
> >>
> >> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> >> index b3971b8..341a157 100644
> >> --- a/gcc/config/i386/i386.c
> >> +++ b/gcc/config/i386/i386.c
> >> @@ -42039,7 +42039,8 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total,
> >>                && !(TARGET_64BIT
> >>                     && (GET_CODE (x) == LABEL_REF
> >>                         || (GET_CODE (x) == SYMBOL_REF
> >> -                           && SYMBOL_REF_LOCAL_P (x)))))
> >> +                           && SYMBOL_REF_LOCAL_P (x))))
> >> +              && (TARGET_64BIT || GET_CODE (x) != CONST))
> 
> Please also add a one-line comment for the new condition.
> 
> OK with this change.
> 
> Uros.

Thanks! Here is committed version.

Ilya
--
gcc/

2015-05-13  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR target/65103
	* config/i386/i386.c (ix86_rtx_costs): We want to propagate
	link time constants into adress expressions and therefore set
	their cost to 0.

gcc/testsuite/

2015-05-13  Ilya Enkovich  <ilya.enkovich@intel.com>

	PR target/65103
	* gcc.target/i386/pr65103-3.c: New.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fd52d89..d739f89 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -42005,7 +42005,9 @@  ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total,
 	       && !(TARGET_64BIT
 		    && (GET_CODE (x) == LABEL_REF
 			|| (GET_CODE (x) == SYMBOL_REF
-			    && SYMBOL_REF_LOCAL_P (x)))))
+			    && SYMBOL_REF_LOCAL_P (x))))
+	       /* Use 0 cost for CONST to improve its propagation.  */
+	       && (TARGET_64BIT || GET_CODE (x) != CONST))
 	*total = 1;
       else
 	*total = 0;
diff --git a/gcc/testsuite/gcc.target/i386/pr65103-3.c b/gcc/testsuite/gcc.target/i386/pr65103-3.c
new file mode 100644
index 0000000..eddf20b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65103-3.c
@@ -0,0 +1,19 @@ 
+/* { dg-do compile { target ia32 } } */
+/* { dg-require-effective-target pie } */
+/* { dg-options "-O2 -fPIE" } */
+/* { dg-final { scan-assembler-not "GOTOFF," } } */
+
+static int *data[100];
+
+void test (long a, long b)
+{
+  do
+    {
+      if( a < b )
+        {
+	  data[a] = data[b];
+	  a++;
+        }
+    }
+  while (a <= b);
+}