From: Segher Boessenkool Date: Fri, 19 Apr 2019 16:58:01 +0000 (+0200) Subject: tree-call-cdce: If !HONOR_NANS do not make code with NaNs (PR88055) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c5c4d431e0d526738fbf54a92d36fefff8f647e4;p=gcc.git tree-call-cdce: If !HONOR_NANS do not make code with NaNs (PR88055) If we don't HONOR_NANS we should not try to use any unordered comparison results. Best case those will just be optimized away; realistically, they ICE. For example, the rs6000 backend has some code that specifically checks we never do this. PR tree-optimization/88055 * tree-call-cdce.c (comparison_code_if_no_nans): New function. (gen_one_condition): Use it if !HONOR_NANS. From-SVN: r270460 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5327dcda6f3..493aaeb84b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-19 Segher Boessenkool + + PR tree-optimization/88055 + * tree-call-cdce.c (comparison_code_if_no_nans): New function. + (gen_one_condition): Use it if !HONOR_NANS. + 2019-04-19 Jakub Jelinek PR middle-end/90139 diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c index 2b1e9340bce..2e482b37ea2 100644 --- a/gcc/tree-call-cdce.c +++ b/gcc/tree-call-cdce.c @@ -362,6 +362,40 @@ can_guard_call_p (gimple *call) || find_fallthru_edge (gimple_bb (call)->succs)); } +/* For a comparison code return the comparison code we should use if we don't + HONOR_NANS. */ + +static enum tree_code +comparison_code_if_no_nans (tree_code code) +{ + switch (code) + { + case UNLT_EXPR: + return LT_EXPR; + case UNGT_EXPR: + return GT_EXPR; + case UNLE_EXPR: + return LE_EXPR; + case UNGE_EXPR: + return GE_EXPR; + case UNEQ_EXPR: + return EQ_EXPR; + case LTGT_EXPR: + return NE_EXPR; + + case LT_EXPR: + case GT_EXPR: + case LE_EXPR: + case GE_EXPR: + case EQ_EXPR: + case NE_EXPR: + return code; + + default: + gcc_unreachable (); + } +} + /* A helper function to generate gimple statements for one bound comparison, so that the built-in function is called whenever TCODE is *false*. TEMP_NAME1/TEMP_NAME2 are names @@ -378,6 +412,9 @@ gen_one_condition (tree arg, int lbub, vec conds, unsigned *nconds) { + if (!HONOR_NANS (arg)) + tcode = comparison_code_if_no_nans (tcode); + tree lbub_real_cst, lbub_cst, float_type; tree temp, tempn, tempc, tempcn; gassign *stmt1;