diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-14 20:06:23 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-14 20:06:23 +0000 |
commit | 3d2931b52bc6e77b35fac2cabaf7e5e91db63f9a (patch) | |
tree | 1c5ac4147db728d1db8cce06fbd59ea041cbd2c0 /gcc/cse.c | |
parent | 03623d96836cf980f972e4ef8b9cb98aec14d4fd (diff) | |
download | gcc-3d2931b52bc6e77b35fac2cabaf7e5e91db63f9a.tar.gz |
gcc/ChangeLog:
PR middle-end/18628
* cse.c (fold_rtx_mem): Don't fold a load from a jumptable into a
register.
gcc/testsuite/ChangeLog:
* gcc.dg/pr18628.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96445 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cse.c')
-rw-r--r-- | gcc/cse.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/cse.c b/gcc/cse.c index d7f3027e2bb..fd5e21ac2ee 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3515,8 +3515,30 @@ fold_rtx_mem (rtx x, rtx insn) if (offset >= 0 && (offset / GET_MODE_SIZE (GET_MODE (table)) < XVECLEN (table, 0))) - return XVECEXP (table, 0, - offset / GET_MODE_SIZE (GET_MODE (table))); + { + rtx label = XVECEXP + (table, 0, offset / GET_MODE_SIZE (GET_MODE (table))); + rtx set; + + /* If we have an insn that loads the label from the + jumptable into a reg, we don't want to set the reg + to the label, because this may cause a reference to + the label to remain after the label is removed in + some very obscure cases (PR middle-end/18628). */ + if (!insn) + return label; + + set = single_set (insn); + + if (! set || SET_SRC (set) != x) + return x; + + /* If it's a jump, it's safe to reference the label. */ + if (SET_DEST (set) == pc_rtx) + return label; + + return x; + } } if (table_insn && JUMP_P (table_insn) && GET_CODE (PATTERN (table_insn)) == ADDR_DIFF_VEC) |