diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-07-24 23:43:55 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-07-24 23:43:55 +0000 |
commit | 6f2c24560b6b87b3eee8b6f4e1ce3a7a12b46589 (patch) | |
tree | ea355d498f15ab1bd17b5eeda86b06733e3fd1cb /gcc/simplify-rtx.c | |
parent | 2029706725556f2b0676b40a73a36f2bcce61877 (diff) | |
download | gcc-6f2c24560b6b87b3eee8b6f4e1ce3a7a12b46589.tar.gz |
* simplify-rtx.c (avoid_constant_pool_reference): Coerce
the retrieved constant into the expected mode.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44321 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index ed7b0ea6e55..1961f194eba 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -136,18 +136,36 @@ simplify_gen_binary (code, mode, op0, op1) return gen_rtx_fmt_ee (code, mode, op0, op1); } -/* 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; } /* Make a unary operation by first seeing if it folds and otherwise making |