https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124643
Richard Sandiford <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rsandifo at gcc dot
gnu.org
Status|NEW |ASSIGNED
--- Comment #11 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #10)
> (In reply to Richard Sandiford from comment #7)
> > Why does sh_hard_regno_mode_ok specifically reject
> > anything other than SImode for the T register, then go to such lengths to
> > allow QImode references via extension? If the T register is just a single
> > bit, wouldn't QImode and HImode be valid too?
>
> I guess T register ended up SImode because that was the easiest way to do
> this thing when the SH port was initially created. The more correct way
> would be BImode these days. But converting it seems like a rabbit hole
> and/or can of worms.
I suppose the problem with BImode is that it isn't really a natural memory
mode. It also isn't a mode that pseudo registers would naturally have, if you
want to have moves between the T register and pseudos (and it seems like you
do).
Accessing the T register as SImode seems reasonable for a 32-bit target. I
just don't understand why accessing it as HImode and QImode is specifically not
allowed, even though the register is a single bit.
If the port did allow T to be accessed in narrower modes, t_reg_operand could
still accept:
(zero_extend:SI (reg:QI T))
and so (hopefully) allow the same combine opportunities as currently.
> > Rejecting QImode for the T register is what makes validate_subreg reject the
> > subreg.
>
> All those complicated t_reg_operand things were actually expected to be
> there only before RA.
I don't think anything would get rid of the:
(zero_extend:SI (subreg:QI (reg:SI 147 t) 3)
during or after RA. The pattern:
(define_insn "movt"
[(set (match_operand:SI 0 "arith_reg_dest" "=r")
(match_operand:SI 1 "t_reg_operand"))]
"TARGET_SH1"
"movt %0"
[(set_attr "type" "arith")])
doesn't have a constraint for operand 1, so the operand will just be left
as-is.
For example, if I use -fdisable-rtl-late_combine{1,2} to bypass the ICE, I
still see:
(insn 10 12 13 (set (reg:SI 7 r7 [orig:170 _16+-3 ] [170])
(zero_extend:SI (subreg:QI (reg:SI 147 t) 3))) … {movt}
(nil))
in the final dump.
> It was to "help combine" find more opportunities
> around the T register. At that point there was no such thing as
> late-combine, so perhaps that's where the problems come from.
I don't think it's really a late-combine thing. The ICE is coming from a
common routine that is shared with other passes. And the ICE is due to an
existing “invalid” subreg, rather than new RTL created by the pass.
I think the issue is more that, unlike gimple, RTL doesn't have a verification
step that runs after each pass. So if one pass does something unexpected,
it'll often show up as an ICE in some arbitrary later pass.
Anyway, thanks for the info. If accepting the zero-extend-of-subreg is “just”
for combine, rather than something that is needed for correctness, then I think
I'll go ahead with a version of yesterday's patch.