This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC][4.4] PR rtl-optimization/3507 appalling optimization with sub/cmp
Second, and more important, the optimization belongs in fold_rtx,
The detail is that I need to know DEST, which isn't passed to fold_rtx.
I agree that implementing it in fold_rtx is a problem, but as pointed
out by Steven in the PR trail, that's because our representation of
branches sucks.
The problem is not that you need to know DEST -- it is that if you did
so in fold_rtx, you would need to wait for the second to modify the first.
(insn 1 (set (reg C) (minus (reg A) (reg B))))
(insn 2 (set (reg D) (compare (reg A) (reg B))))
(insn 3 (set ... (ltu (reg D) (const_int 0))))
... that is, in insn 3 you would use find_comparison_args to find A and
B, and fold the ltu to (set ... (ltu (reg C) (const_int 0)). Except
that it is not a valid insn except on cbranch targets (and I don't mean
using a cbranch expander, but using a cbranch insn).
So, I don't like your approach, but mine is probably infeasible --
sorry. Maybe combine would be the right place to fix it, by adding a
different way to do a 3 insn->2 insn combine (in find_split_point), but
I'm not asking you to try.
Paolo