[Bug rtl-optimization/99114] [WORD_REGISTER_OPERATIONS] wrong code for (u16_var & 3) == (u32)1

pipcet at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 16 00:50:08 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99114

--- Comment #2 from pipcet at gmail dot com ---
(In reply to Eric Botcazou from comment #1)
> Please provide a reproducer as documented in https://gcc.gnu.org/bugs

I'll try, but please consider investigating this without one. It happens after
a very lengthy compilation process (compiling a buggy gcc with a buggy
cross-compiler, then compiling JIT code with that, generating a buggy .so, then
running _that_, to see incorrect behavior rather than a clear crash), in C++
code, with an out-of-tree backend.

On the other hand, it's been investigated, and it's a clear bug with a one-line
fix.

> > The assumption here is that op0 will be an (and:HI) after the first
> > statement (and we assume (subreg:SI (and:HI ... (const_int 3))) is
> > defined because of WORD_REGISTER_OPERATIONS) but it's actually
> > simplified to be just the (reg:HI 593), and (subreg:SI (reg:HI 593))
> > is not defined.
> 
> Paradoxical registers are defined under specific circumstances though.

Thanks, I understand that. This isn't one of them.

> > I'm unsure whether this can cause wrong code for in-tree backends or
> > backends which don't define WORD_REGISTER_OPERATIONS.
> 
> Well, obviously not for the latter, see the comment just above the code.

As I said, I'm unsure. The buggy line of code is executed on other targets, and
the condition under which that happens is not !paradoxical_subreg_p. I think
it's equivalent, but I don't think that's obvious...


More information about the Gcc-bugs mailing list