summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 17:24:03 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 17:24:03 +0000
commitd2efb29d3e5967193ab5eeb9c9d403e6a61cd4ec (patch)
tree39f60f475b6218eda95f7ba7195de7c72769f089
parent8918a3662d7b782e5a4d6b1dd6a6450272dcf0cf (diff)
downloadgcc-d2efb29d3e5967193ab5eeb9c9d403e6a61cd4ec.tar.gz
gcc/
* fwprop.c (forward_propagate_and_simplify): After checking reg/subreg combinations, check whether the modes are the same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179287 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fwprop.c21
2 files changed, 17 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d05ebc63a66..ab85f50774d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-27 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * fwprop.c (forward_propagate_and_simplify): After checking
+ reg/subreg combinations, check whether the modes are the same.
+
2011-09-27 Bernd Schmidt <bernds@codesourcery.com>
Richard Sandiford <rdsandiford@googlemail.com>
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 236dda2dea5..5368d187f4b 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -1232,21 +1232,24 @@ forward_propagate_and_simplify (df_ref use, rtx def_insn, rtx def_set)
/* If def and use are subreg, check if they match. */
reg = DF_REF_REG (use);
- if (GET_CODE (reg) == SUBREG
- && GET_CODE (SET_DEST (def_set)) == SUBREG
- && (SUBREG_BYTE (SET_DEST (def_set)) != SUBREG_BYTE (reg)
- || GET_MODE (SET_DEST (def_set)) != GET_MODE (reg)))
- return false;
-
+ if (GET_CODE (reg) == SUBREG && GET_CODE (SET_DEST (def_set)) == SUBREG)
+ {
+ if (SUBREG_BYTE (SET_DEST (def_set)) != SUBREG_BYTE (reg))
+ return false;
+ }
/* Check if the def had a subreg, but the use has the whole reg. */
- if (REG_P (reg) && GET_CODE (SET_DEST (def_set)) == SUBREG)
+ else if (REG_P (reg) && GET_CODE (SET_DEST (def_set)) == SUBREG)
return false;
-
/* Check if the use has a subreg, but the def had the whole reg. Unlike the
previous case, the optimization is possible and often useful indeed. */
- if (GET_CODE (reg) == SUBREG && REG_P (SET_DEST (def_set)))
+ else if (GET_CODE (reg) == SUBREG && REG_P (SET_DEST (def_set)))
reg = SUBREG_REG (reg);
+ /* Make sure that we can treat REG as having the same mode as the
+ source of DEF_SET. */
+ if (GET_MODE (SET_DEST (def_set)) != GET_MODE (reg))
+ return false;
+
/* Check if the substitution is valid (last, because it's the most
expensive check!). */
src = SET_SRC (def_set);