]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MIN/MAX should be treated similar as comparisons for trapping
authorAndrew Pinski <apinski@marvell.com>
Sat, 1 Apr 2023 22:50:27 +0000 (22:50 +0000)
committerAndrew Pinski <apinski@marvell.com>
Thu, 27 Apr 2023 15:00:25 +0000 (08:00 -0700)
While looking into moving optimizations from minmax_replacement
in phiopt to match.pd, I Noticed that min/max were considered
trapping even if -ffinite-math-only was being used. This changes
those expressions to be similar as comparisons so that they are
not considered trapping if -ffinite-math-only is on.

OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu.

gcc/ChangeLog:

* rtlanal.cc (may_trap_p_1): Treat SMIN/SMAX similar as
COMPARISON.
* tree-eh.cc (operation_could_trap_helper_p): Treate
MIN_EXPR/MAX_EXPR similar as other comparisons.

gcc/rtlanal.cc
gcc/tree-eh.cc

index c96a88cebf1c16ccb8f6e2be6ca8ebdb61990bd4..b7948ecfad117431da55742aca6a1a6e5ffe81c6 100644 (file)
@@ -3204,6 +3204,9 @@ may_trap_p_1 (const_rtx x, unsigned flags)
     case LT:
     case LTGT:
     case COMPARE:
+    /* Treat min/max similar as comparisons.  */
+    case SMIN:
+    case SMAX:
       /* Some floating point comparisons may trap.  */
       if (!flag_trapping_math)
        break;
index 425323ff7d677a1eeb50795d165d8b0580fe59ec..934209d205fa13bb6434245af6bd8eb064430826 100644 (file)
@@ -2490,6 +2490,9 @@ operation_could_trap_helper_p (enum tree_code op,
     case GT_EXPR:
     case GE_EXPR:
     case LTGT_EXPR:
+    /* MIN/MAX similar as LT/LE/GT/GE. */
+    case MIN_EXPR:
+    case MAX_EXPR:
       /* Some floating point comparisons may trap.  */
       return honor_nans;