]> git.ipfire.org Git - thirdparty/gcc.git/commit
arc: Use intrinsics for __builtin_mul_overflow ()
authorLuis Silva <luiss@synopsys.com>
Wed, 25 Jun 2025 14:58:35 +0000 (17:58 +0300)
committerClaudiu Zissulescu <claziss@gmail.com>
Wed, 25 Jun 2025 17:14:50 +0000 (20:14 +0300)
commit5fd8f336f17067fa3ae25eb69f50ca45171ceec8
tree49305e784b8a995eff53217811a9e63cd8aec6d6
parent49943c2c0adf6b66b62e66dafde08d1dbdcfc621
arc: Use intrinsics for __builtin_mul_overflow ()

This patch handles both signed and unsigned builtin multiplication
overflow.

Uses the "mpy.f" instruction to set the condition codes based on the
result.  In the event of an overflow, the V flag is set, triggering a
conditional move depending on the V flag status.

For example, set "1" to "r0" in case of overflow:

        mov_s   r0,1
        mpy.f   r0,r0,r1
        j_s.d   [blink]
        mov.nv  r0,0

gcc/ChangeLog:

* config/arc/arc.md (<su_optab>mulvsi4): New define_expand.
(<su_optab>mulsi3_Vcmp): New define_insn.

Signed-off-by: Luis Silva <luiss@synopsys.com>
gcc/config/arc/arc.md