On 09/10/2026 16:22, Richard Sandiford wrote:
Andrew Stubbs <[email protected]> writes:
On 09/10/2026 12:15, Richard Sandiford wrote:
Sorry, a couple of other things:

+
+         rtx new_addr
+           = (REG_P (addr)
+              ? simplify_gen_subreg (addr_elt_mode, addr, addrmode,
+                                     addr_byte)
+              : simplify_subreg (addr_elt_mode, addr, addrmode, addr_byte));

I think we should use simplify_gen_subreg unconditionally unless there's
a specific reason not to.  This is a simplification regardless of what
the address is.

I tried this and got an ICE. AFAICT, simplify_gen_subreg does the wrong
thing (in this situation) when the address has an offset:

    (mem/i:V8QI (plus:V8DI (reg:V8DI 720)
                           (vec_duplicate:V8DI (const_int 0))))

It tries to wrap the plus in a subreg, which is not valid. So, I'm going
to leave this bit as-is, unless you have a better suggestion?

Why's it not valid though?
gcn_addr_space_legitimate_address_p rejects it because there's no instruction that can do that in a load/store instruction.

Is that not how that's supposed to work?

There's also a chance to fix it in gcn_addr_space_legitimize_address, so I'm trying to figure out if that's something it should be doing.

The testcase is trying to convert

     (mem/i:V8QI (plus:V8DI (reg:V8DI 720)
                            (vec_duplicate:V8DI (const_int 0))))

into

     (mem:QI (subreg:DI (plus:V8DI (reg:V8DI 720)
                                   (vec_duplicate:V8DI (const_int 0)))
                        0))

Which is because CSE is trying to split this

     (set (mem/i:V8QI (plus:V8DI (reg:V8DI 720)
                                 (vec_duplicate:V8DI (const_int 0))))
          (const_vector:V8QI [(const_int 0 [0]) repeated x8]))

into 8 separate operations. The comment says "These are templates and don't actually get emitted but are used to tell CSE how to get to a particular constant."


Anyway, if I change gcn_addr_space_legitimate_address_p to allow the subreg pattern the CSE pass works and eventually decides to do nothing.

I'm trying to work out if there are other consequences to allowing that. Maybe I should allow it only when "strict == false"?

Thoughts?

Andrew

Reply via email to