]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
simplify-rtx.c (avoid_constant_pool_reference): Coerce the retrieved constant into...
authorRichard Henderson <rth@redhat.com>
Tue, 24 Jul 2001 23:43:55 +0000 (16:43 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 24 Jul 2001 23:43:55 +0000 (16:43 -0700)
        * simplify-rtx.c (avoid_constant_pool_reference): Coerce
        the retrieved constant into the expected mode.

From-SVN: r44321

gcc/ChangeLog
gcc/simplify-rtx.c

index 010e14cddefdd23f5c0339af4d47fe8318ea6f8c..819ee9b8a78c54664ca911e2ea4899e94854054d 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-24  Richard Henderson  <rth@redhat.com>
+
+       * simplify-rtx.c (avoid_constant_pool_reference): Coerce
+       the retrieved constant into the expected mode.
+
 Wed Jul 25 01:41:27 CEST 2001  Jan Hubicka  <jh@suse.cz>
 
        * flow.c (try_simplify_condjump): Avoid duplicated edges.
index ed7b0ea6e55054f6bf7f327d36b085336849dd87..1961f194ebac00c206a93135b56452014d703aa6 100644 (file)
@@ -136,18 +136,36 @@ simplify_gen_binary (code, mode, op0, op1)
     return gen_rtx_fmt_ee (code, mode, op0, op1);
 }
 \f
-/* In case X is MEM referencing constant pool, return the real value.
+/* If X is a MEM referencing the constant pool, return the real value.
    Otherwise return X.  */
 static rtx
 avoid_constant_pool_reference (x)
      rtx x;
 {
+  rtx c, addr;
+  enum machine_mode cmode;
+
   if (GET_CODE (x) != MEM)
     return x;
-  if (GET_CODE (XEXP (x, 0)) != SYMBOL_REF
-      || !CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
+  addr = XEXP (x, 0);
+
+  if (GET_CODE (addr) != SYMBOL_REF
+      || ! CONSTANT_POOL_ADDRESS_P (addr))
     return x;
-  return get_pool_constant (XEXP (x, 0));
+
+  c = get_pool_constant (addr);
+  cmode = get_pool_mode (addr);
+
+  /* If we're accessing the constant in a different mode than it was
+     originally stored, attempt to fix that up via subreg simplifications.
+     If that fails we have no choice but to return the original memory.  */
+  if (cmode != GET_MODE (x))
+    {
+      c = simplify_subreg (GET_MODE (x), c, cmode, 0);
+      return c ? c : x;
+    }
+
+  return c;
 }
 \f
 /* Make a unary operation by first seeing if it folds and otherwise making