On Thu, Mar 7, 2024 at 10:37 PM Segher Boessenkool <seg...@kernel.crashing.org> wrote: > > On Thu, Mar 07, 2024 at 10:04:32PM +0100, Uros Bizjak wrote: > > [snip] > > > The part we want to fix deals with the *user* of the CC register. It > > is not true that this is always COMPARISON_P, so EQ, NE, GE, LT, ... > > in the form of > > > > (LT:CCGC (reg:CCGC 17 flags) (const_int 0)) > > > > but can be something else, such as the above noted > > > > (unspec:DI [ > > (reg:CC 17 flags) > > ] UNSPEC_PUSHFL) > > But that is invalid RTL? The only valid use of a CC is written as > cc-compared-to-0. It means "the result of something compared to 0, > stored in that cc reg". > > (And you can copy a CC reg around, but that is not a use ;-) )
How can we describe a pushfl then? It was changed to its current form in [1], but I suspect that the code will try to update it even when pushfl is implemented as a direct move from a register (as was defined previously). BTW: Unspecs are used in a couple of other places for other targets [2]. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112494#c5 [2] https://gcc.gnu.org/pipermail/gcc-patches/2023-December/639743.html > > > The source code that deals with the *user* of the CC register assumes > > the former form, so it blindly tries to update the mode of the CC > > register inside LT comparison RTX > > Would you like it better if there was an assert for this? There are > very many RTL requirements that aren't chacked for currently :-/ In this case - yes. Assert signals that something is unsupported (or invalid), way better than silently corrupting some memory, reporting the corruption only with checking enabled. > > > (some other nearby source code even > > checks for (const_int 0) RTX). Obviously, this is not the case with > > the former form, where the update tries to: > > > > SUBST (XEXP (*cc_use_loc, 0), ...) > > > > on unspec, which has no XEXP (..., 0). > > > > And *this* is what triggers RTX checking assert. > > The unspec should have the CC compared with 0 as argument. But this does not do what pushfl does... It pushes the register to the stack. Uros.