aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-04-01 22:50:27 +0000
committerAndrew Pinski <apinski@marvell.com>2023-04-27 08:00:25 -0700
commit5fecfed8788eb114508e36e465147f2bb856fa33 (patch)
tree49a4aa2dba82270f060fc6231c51dce8d84b5ac8 /gcc
parentba9975a259656d099b67ad2b9c69bf970be2b210 (diff)
downloadgcc-5fecfed8788eb114508e36e465147f2bb856fa33.zip
gcc-5fecfed8788eb114508e36e465147f2bb856fa33.tar.gz
gcc-5fecfed8788eb114508e36e465147f2bb856fa33.tar.bz2
MIN/MAX should be treated similar as comparisons for trapping
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rtlanal.cc3
-rw-r--r--gcc/tree-eh.cc3
2 files changed, 6 insertions, 0 deletions
diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc
index c96a88c..b7948ec 100644
--- a/gcc/rtlanal.cc
+++ b/gcc/rtlanal.cc
@@ -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;
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 425323f..934209d 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -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;