J.J. Garcia wrote:
Hi all,
I'm trying to debug a code optimization in gcc for an specific arch, to
be more explicit it's for gcc 2.95.3 for Metaware ARC target
architecture, i know the old release of compiler and i know there will
not be lot of support about it, anyway im keep on trying...,
The "bug" is still there in the most recent version of GCC, but AFAIK (I
speak RTL, but I don't speak ARC assembly) the optimization is ok.
The change is from:
(set (reg:CC 61 cc)
(compare:CC (reg/v:SI 69 [ n ])
(const_int 9 [0x9])))
(set (reg/v:SI 67 [ test_value ])
(if_then_else:SI (ltu (reg:CC 61 cc) (const_int 0 [0x0]))
(const_int 69 [0x45])
(reg:SI 71)))
to
(set (reg:CC 61 cc)
(compare:CC (reg/v:SI 69 [ n ])
(const_int 8 [0x9])))
(set (reg/v:SI 67 [ test_value ])
(if_then_else:SI (leu (reg:CC 61 cc) (const_int 0 [0x0]))
(const_int 69 [0x45])
(reg:SI 71)))
Testing < 9 is the same as testing <= 8.
The assembly seems also ok, since ".ls" is the translation of the "leu"
RTL code. By comparison, "ltu" would become "c".
While unexpected, this change is done by GCC as part of "canonicalizing"
expressions so that, for example, it could detect that "<= 8" and "< 9"
are really testing the same condition.
All this said, remember that the correct place to report a bug is the
GCC bugzilla at http://gcc.gnu.org/bugzilla
Paolo