This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug optimization/12845] [3.4 Regression] Error: Invalid Compare
- From: Roger Sayle <roger at eyesopen dot com>
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: gcc-patches at gcc dot gnu dot org, <rth at redhat dot com>, Michael Matz <matz at suse dot de>
- Date: Mon, 5 Jan 2004 15:27:52 -0700 (MST)
- Subject: 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
--