This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Bug optimization/12845] [3.4 Regression] Error: Invalid Compare


Hi Dave,

I've been meaning to add an additional comment to the bugzilla PR entry.

The problem is that "reload" replaces pseudos with constants without
simplification.  This means that in addition to the problems that you
are seeing with always true/false conditional branches, GCC might also
generate "(plus (reg ...) (const_int 0))", and even non-canonical
"(plus (const_int ...) (reg ...))" patterns and similar cases that
really shouldn't ever reach the final assembly language output.

I believe the solution will be to call "simplify_replace_rtx(pat,0,0)"
immediately after the call to "subst_reloads" in reload_as_needed in
reload1.c.  This will recursively traverse an insn/expr simplifying
everything.  [Alternatively, we could write a recursive subst/simplify
for reload, along the same lines as CSE's fold_rtx].  Things are also
made easier if the function simplify_replace_rtx can be taught to
additionally handle SET, PARALLEL, USE and CLOBBER rtxen to allow passing
the entire insn pattern.  We'd then call recog, i.e.
validate_replace_rtx, to see if the simplified pattern is still a valid
instruction, and if so use that in preference to the unsimplified form.

Additionally, it might make sense performance-wise to only do this
when subst_reloads contains a constant reload.  And these changes
might need to be co-ordinated with the new register allocator.


I'm posting this gcc-patches, just in case anyone has opinions on
whether reload should be simplifying/canonicalizing its constant
substitutions, potential compile-time issues, and whether converting
conditional branches into unconditional jumps during reload is a
bad thing (w.r.t. the CFG and liveness information).

Am I mistaken about reload's substitution of pseudos with constants?

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]