OK, I see what you mean. The reason you can get both (ior (ashift ...)
(lshiftrt ...)) and (ior (lshiftrt ...) (ashift ...)) is that simplify-rtx.c
has no rule to canonicalize such expressions and that LSHIFTRT and
ASHIFT have the same precedence.
Hmm, in simplify_binary_operation_1(), it says:
/* Convert (ior (ashift A CX) (lshiftrt A CY)) where CX+CY equals the
mode size to (rotate A CX). */
ok, so that means that in that specific shift example I could go away
with a rotate operation (even though it has to be of mode DI -> SI).
Right after that is code to make sure ASHIFT is the first operand for the
simplification attempts that follow. You could try adding code to do this in
general, but I don't know where such code should be added.
I will look more into this. It might be that there is no simple way to
activate canonicalization for the general case (i.e. any insn that
defined in the machine description), and maybe it has to be done to
every specific type of operation.
Btw, I found this in rtlanal.c:
int
commutative_operand_precedence (rtx op)
> :
:
It seems like commutative_operand_precedence() is only used twice to
swap operand1 and operand2 - so the fact that it returns low values (or
high, since the comment in the code seems wrong) for general operands
shouldn't affect the ability to canonicalize them.
Sami