arm: add commutative alternatives to <US>mull pattern.

Prior to Armv6, the SMULL and UMULL instructions, which have the form

     UMULL Rdlo, Rdhi, Rm, Rs

had an operand restriction such that Rdlo, Rdhi and Rm must all be
different registers.  Rs, however can overlap either of the
destination registers.  Add some register-tie alternatives to allow
the register allocator to find these forms without having to use
additional register moves.

In addition to this, the test is pretty meaningless on Thumb-1 targets
as the S/UMULL instructions do not exist in a 16-bit encoding.  So skip
the test in this case.

gcc/ChangeLog:

	* config/arm/arm.md (<US>mull): Add alternatives that allow Rs
	to be tied to either Rdlo or Rdhi.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/pr42575.c: Skip test if thumb1.
This commit is contained in:
Richard Earnshaw 2025-03-25 11:50:30 +00:00
parent 7679b82684
commit a86891525d
2 changed files with 6 additions and 5 deletions

View file

@ -2432,11 +2432,11 @@
)
(define_insn "<US>mull"
[(set (match_operand:SI 0 "s_register_operand" "=r,&r")
[(set (match_operand:SI 0 "s_register_operand" "=r,&r,&r,&r")
(mult:SI
(match_operand:SI 2 "s_register_operand" "%r,r")
(match_operand:SI 3 "s_register_operand" "r,r")))
(set (match_operand:SI 1 "s_register_operand" "=r,&r")
(match_operand:SI 2 "s_register_operand" "%r,r,r,r")
(match_operand:SI 3 "s_register_operand" "r,r,0,1")))
(set (match_operand:SI 1 "s_register_operand" "=r,&r,&r,&r")
(truncate:SI
(lshiftrt:DI
(mult:DI (SE:DI (match_dup 2)) (SE:DI (match_dup 3)))
@ -2445,7 +2445,7 @@
"<US>mull%?\\t%0, %1, %2, %3"
[(set_attr "type" "umull")
(set_attr "predicable" "yes")
(set_attr "arch" "v6,nov6")]
(set_attr "arch" "v6,nov6,nov6,nov6")]
)
(define_expand "<Us>maddsidi4"

View file

@ -1,4 +1,5 @@
/* { dg-options "-O2" } */
/* { dg-skip-if "Thumb1 lacks UMULL" { arm_thumb1 } } */
/* Make sure RA does good job allocating registers and avoids
unnecessary moves. */
/* { dg-final { scan-assembler-not "mov" } } */