On 3/18/25 10:22 AM, Luis Silva wrote:
This patch introduces two new instruction patterns:

     `*mulsi3_cmp0`:  This pattern performs a multiplication
     and sets the CC_Z register based on the result, while
     also storing the result of the multiplication in a
     general-purpose register.

     `*mulsi3_cmp0_noout`:  This pattern performs a
     multiplication and sets the CC_Z register based on the
     result without storing the result in a general-purpose
     register.

These patterns are optimized to generate code using the `mpy.f`
instruction, specifically used where the result is compared to zero.

In addition, the previous commutative multiplication implementation
was removed.  It incorrectly took into account the negative flag,
which is wrong.  This new implementation only considers the zero
flag.

A test case has been added to verify the correctness of these
changes.

gcc/ChangeLog:

         * config/arc/arc.cc (arc_select_cc_mode): Handle multiplication
         results compared against zero, selecting CC_Zmode.
         * config/arc/arc.md (*mulsi3_cmp0): New define_insn.
         (*mulsi3_cmp0_noout): New define_insn.

gcc/testsuite/ChangeLog:

         * gcc.target/arc/mult-cmp0.c: New test.
So I'm not well versed in the ARC port, but a couple questions.

First your new patterns use a new type "mpy". Do you want/need to add that to the pipeline descriptions? It would seem advisable to do so.

Do the new patterns need to set "cond" and "predicable" attributes?

Jeff

Reply via email to