"H.J. Lu" <hjl.to...@gmail.com> writes:
> On Mon, Aug 4, 2025 at 3:28 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>>
>> On Mon, Aug 4, 2025 at 2:04 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>> >
>> > On Mon, Aug 4, 2025 at 8:50 AM Richard Sandiford
>> > <richard.sandif...@arm.com> wrote:
>> > > Sorry, I hadn't realised that there were still unfixed regressions
>> > > from that patch.  I suppose if we wanted to avoid two patterns here,
>> > > we'd need to extend the pre-existing word_mode folds to support
>> > > subword modes too (for !WORD_REGISTER_OPERATIONS).  The attached
>> > > untested patch does that, but I expect it would have similar
>> > > knock-on effects.  I'll give it a spin overnight on x86 anyway
>> > > just to see what happens.
>> >
>> > Yes, it fixes:
>> >
>> > FAIL: gcc.target/i386/pr82524.c scan-assembler-not mov[sz]bl
>> > FAIL: gcc.target/i386/pr82524.c scan-assembler [ \t]notb
>> >
>> > together with the enclosed patch.
>>
>> 64-bit libgo failed to compile
>>
>> during RTL pass: late_combine
>> /export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/mpallocbits.go:
>> In function ‘runtime.pageBits.clear’:
>> /export/gnu/import/git/gitlab/x86-gcc/libgo/go/runtime/mpallocbits.go:67:1:
>> internal compiler error: in simplify_subreg, at simplify-rtx.cc:8085
>>    67 | func (b *pageBits) clear(i uint) {
>>       | ^
>> 0x2276abf internal_error(char const*, ...)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/diagnostic-global-context.cc:534
>> 0x669387 fancy_abort(char const*, int, char const*)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/diagnostics/context.cc:1640
>> 0x4d0a70 simplify_context::simplify_subreg(machine_mode, rtx_def*,
>> machine_mode, poly_int<1u, unsigned long>)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/simplify-rtx.cc:8085
>> 0xdbc955 simplify_context::simplify_subreg(machine_mode, rtx_def*,
>> machine_mode, poly_int<1u, unsigned long>)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/simplify-rtx.cc:8349
>> 0xd38441 insn_propagation::apply_to_rvalue_1(rtx_def**)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.cc:1224
>> 0xd37e8b insn_propagation::apply_to_rvalue_1(rtx_def**)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.cc:1166
>> 0xd38942 insn_propagation::apply_to_pattern_1(rtx_def**)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.cc:1400
>> 0xd389ef insn_propagation::apply_to_pattern(rtx_def**)
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.cc:1444
>> 0x20c441d substitute_nondebug_use
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:198
>> 0x20c441d substitute_nondebug_uses
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:271
>> 0x20c5b5d run
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:440
>> 0x20c5b5d combine_into_uses
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:690
>> 0x20c669c execute
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:718
>> 0x20c669c execute
>> /export/gnu/import/git/gitlab/x86-gcc/gcc/late-combine.cc:771
>> Please submit a full bug report, with preprocessed source (by using
>> -freport-bug).
>> Please include the complete backtrace with any bug report.
>> See <https://gcc.gnu.org/bugs/> for instructions.
>>
>> (gdb) call debug (op)
>> (and:SI (reg:DI 113 [ i ])
>>     (const_int 63 [0x3f]))
>> (gdb)

That's not a valid rtx though, so...

> The enclosed patch works.

...I think this is masking a bug elsewhere.

Specifically:

> +  /* Attempt to simplify WORD_MODE and sub-WORD_MODE SUBREGs of bitwise
> +     expressions.  */
> +  scalar_int_mode int_outermode;
> +  if (is_a<scalar_int_mode> (outermode, &int_outermode)
> +      && (WORD_REGISTER_OPERATIONS
> +       ? int_outermode == word_mode
> +       : GET_MODE_PRECISION (int_outermode) <= BITS_PER_WORD)
> +      && SCALAR_INT_MODE_P (innermode)
> +      && (GET_CODE (op) == IOR
> +       || GET_CODE (op) == XOR
> +       || GET_CODE (op) == AND
> +       || GET_CODE (op) == NOT))
>      {
> -      rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
> -      if (op0)
> -     return simplify_gen_unary (GET_CODE (op), outermode, op0, outermode);
> +      rtx op0 = XEXP (op, 0);
> +      if (GET_MODE (op0) != innermode)

This condition must be true if op0 isn't a constant, for the op codes
tested above.

I'll try to reproduce.

Richard

> +     {
> +       if (validate_subreg (innermode, GET_MODE (op0), op0, 0))
> +         op0 = gen_rtx_SUBREG (innermode, op0, 0);
> +     }

Reply via email to