http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59461
Bug ID: 59461
Summary: missed zero-extension elimination in the combiner
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ebotcazou at gcc dot gnu.org
This is a spin-off of PR rtl-optimization/58295. The zero-extension is not
(and has never been) eliminated on the SPARC at -O2:
ee_isdigit2:
sethi %hi(zeb_test_array), %g1
or %g1, %lo(zeb_test_array), %g1
ldub [%g1+%o0], %g1
mov 0, %o0
add %g1, -48, %g1
and %g1, 0xff, %g1
cmp %g1, 9
jmp %o7+8
movleu %icc, 1, %o0
.size ee_isdigit2, .-ee_isdigit2
The instruction "and %g1, 0xff, %g1" is redundant like on the ARM and the
combiner should eliminate it. The difference between the ARM and the SPARC is
that the former explicitly zero-extends the load from memory while the latter
does it only implicitly via LOAD_EXTEND_OP. This shouldn't matter in the end,
but does here because of some weakness of the nonzero_bits machinery.