[Bug target/79430] [7/8 Regression] action of statement incorrectly optimised away
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 26 09:57:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79430
--- Comment #78 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Untested fix. The problem is that autoinc/dec of stack_pointer_rtx doesn't use
REG_INC notes (various comments, e.g. in auto_inc_p or in auto-inc-dec.c seem
to suggest that stack_pointer_rtx is just special in this regard) and reg_set_p
used by modified_between_p etc. thus doesn't consider push/pop instructions as
affecting the stack pointer and memory based on that.
--- gcc/rtlanal.c.jj 2017-01-05 11:43:10.000000000 +0100
+++ gcc/rtlanal.c 2017-04-26 11:38:16.510940053 +0200
@@ -1221,6 +1221,24 @@ reg_set_p (const_rtx reg, const_rtx insn
|| find_reg_fusage (insn, CLOBBER, reg)))))
return true;
+ /* There are no REG_INC notes for SP autoinc. */
+ if (reg == stack_pointer_rtx && INSN_P (insn))
+ {
+ subrtx_var_iterator::array_type array;
+ FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (insn), NONCONST)
+ {
+ rtx mem = *iter;
+ if (mem
+ && MEM_P (mem)
+ && GET_RTX_CLASS (GET_CODE (XEXP (mem, 0))) == RTX_AUTOINC)
+ {
+ if (XEXP (XEXP (mem, 0), 0) == stack_pointer_rtx)
+ return true;
+ iter.skip_subrtxes ();
+ }
+ }
+ }
+
return set_of (reg, insn) != NULL_RTX;
}
More information about the Gcc-bugs
mailing list