]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: add commutative alternatives to <US>mull pattern.
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 25 Mar 2025 11:50:30 +0000 (11:50 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Tue, 25 Mar 2025 12:06:22 +0000 (12:06 +0000)
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.

gcc/config/arm/arm.md
gcc/testsuite/gcc.target/arm/pr42575.c

index 442d86b932926e85d438f28e8666face4bd2cf92..597ef6725bb7c2ef6f32104a1418b69cc7938187 100644 (file)
 )
 
 (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)))
   "<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"
index 1998e323df17379aad9f25452da57fea9f22787e..3906c77ed569dc4e340ef1b17d3993cdb05b3a34 100644 (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" } } */