https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95810
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:6ff6c02695c9b6ae6e840422080f6d10449577b8 commit r9-8901-g6ff6c02695c9b6ae6e840422080f6d10449577b8 Author: Jakub Jelinek <ja...@redhat.com> Date: Wed Jun 24 10:40:02 2020 +0200 fold-const: Fix A <= 0 ? A : -A folding [PR95810] We folded A <= 0 ? A : -A into -ABS (A), which is for signed integral types incorrect - can invoke on INT_MIN UB twice, once on ABS and once on its negation. The following patch fixes it by instead folding it to (type)-ABSU (A). 2020-06-24 Jakub Jelinek <ja...@redhat.com> PR middle-end/95810 * fold-const.c (fold_cond_expr_with_comparison): Optimize A <= 0 ? A : -A into (type)-absu(A) rather than -abs(A). * gcc.dg/ubsan/pr95810.c: New test. (cherry picked from commit 01e10b0ee77e82cb331414c569e02dc7a2c4999e)