[Bug target/122998] RISC-V optimization: builtin_sub_overflow(unsigned) can make sub-optimal code
law at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Dec 7 16:25:52 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122998
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2025-12-07
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Jeffrey A. Law <law at gcc dot gnu.org> ---
I suspect fixing this likely requires work in gimple.
;; basic block 2, loop depth 0
;; pred: ENTRY
_6 = .SUB_OVERFLOW (x_4(D), y_5(D));
_2 = IMAGPART_EXPR <_6>;
if (_2 != 0)
goto <bb 4>; [21.72%]
else
goto <bb 3>; [78.28%]
;; succ: 4
;; 3
;; basic block 3, loop depth 0
;; pred: 2
_1 = REALPART_EXPR <_6>;
;; succ: 4
;; basic block 4, loop depth 0
;; pred: 2
;; 3
# _3 = PHI <291(2), _1(3)>
return _3;
In that form there's really nothing to do. The subtraction is speculative and
it's going to be fairly hard to sink the subtraction later in the RTL pipeline.
More information about the Gcc-bugs
mailing list