This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch RFC IA64] Fixing predication & autoinc interaction
Alexander Monakov wrote:
> (To recap: the problem in the testcase is that combine pass combines
> (set (reg r1) (mem (postinc...)))
> (set (reg r2) (if_then_else (cond c) (reg r2) (reg r1)))
>
> into
>
> (set (reg r2) (if_then_else (cond c) (reg r2) (mem (postinc...))))
>
> which is matched by recog on ia64 before reload, leading to a
> miscompilation, since postinc side effect does not now occur
> unconditionally)
[...]
> Moreover, Michael Meissner in
> http://gcc.gnu.org/ml/gcc/2000-01/msg00394.html
> says that if_then_else with side effects should imply that said side
> effects occur regardless of condition. Thus, ARM back-end plays by that
> rule and does not expose ``wrong'' patterns to the optimizers. However,
> Ian Lance Taylor told me on IRC that this rule should not be relied on.
It may be a bit underspecified, but since if_then_else is not handled
specially anywhere in the compiler, or documented to have special
semantics, I think the default assumption has to be that it behaves like
any other RTL code. So, I'm with Mike here.
> So, my approach seems to go against the existing practice, but if GCC
> really does not promise anything about if_then_else with side effects (I
> do not see anything related in the GCC Internals), it makes sense to
> make combine safer instead of pessimizing .md files.
I don't see how .md files would have to be pessimized. They should
disallow side effects in if_then_else iff they are unable to deal with them.
> + /* Do not bring expressions with side-effects into conditionals. */
> + if (GET_CODE (PATTERN (i3)) == SET
> + && GET_CODE (SET_SRC (PATTERN (i3))) == IF_THEN_ELSE
> + && ((i1 && side_effects_p (PATTERN (i1)))
> + || side_effects_p (PATTERN (i2))))
> + {
> + undo_all ();
> + return 0;
> + }
That's unlikely to be general enough to catch all possible instruction
patterns.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif