Zdenek,
I'm looking at a missed optimizations in combine and it is similar to the one
you've fixed in PR18942 (http://thread.gmane.org/gmane.comp.gcc.patches/81504).
I'm trying to make GCC optimize
(leu:SI
(plus:SI (reg:SI) (const_int -1))
(const_int 1))
into
(leu:SI
(reg:SI)
(const_int 2))
.
Your patch for PR18942 handles only EQ/NE comparisons, and I wonder if there is
a reason not to handle LEU/GEU, LTU/GTU comparisons as well. I'm a bit fuzzy
whether signed comparisons can be optimized here as well, but I can't see the
problem with unsigned comparisons.
Any reason why this optimization would be unsafe?
Regarding the testcase, the general pattern
(set (tmp1) (plus:SI (reg:SI) (const_int A))
(set (tmp2) (leu:SI (tmp1) (const_int B))
is generated from switch statement
switch (reg) {
case A:
case B:
...
}
Combine tries merge the two instructions into one, but fails. This causes an
extra 'add' instruction per switch statement in the final assembly. The target
I'm working with is MIPS, but, I imagine, other architectures are affected as
well.
Thank you,
--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics