]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/gimple-match-head.c
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / gimple-match-head.c
index 2996bade301e09e433d9c415348a5b3fba882482..7112c1168357ba3bf9d99e87d3b78f3367304145 100644 (file)
@@ -1,5 +1,5 @@
 /* Preamble and helpers for the autogenerated gimple-match.c file.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2021 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -43,6 +43,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "optabs-tree.h"
 #include "tree-eh.h"
 #include "dbgcnt.h"
+#include "tm.h"
+#include "gimple-range.h"
 
 /* Forward declarations of the private auto-generated matchers.
    They expect valueized operands in canonical order and do not
@@ -144,9 +146,21 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op,
       /* Likewise if the operation would not trap.  */
       bool honor_trapv = (INTEGRAL_TYPE_P (res_op->type)
                          && TYPE_OVERFLOW_TRAPS (res_op->type));
-      if (!operation_could_trap_p ((tree_code) res_op->code,
-                                  FLOAT_TYPE_P (res_op->type),
-                                  honor_trapv, res_op->op_or_null (1)))
+      tree_code op_code = (tree_code) res_op->code;
+      bool op_could_trap;
+
+      /* COND_EXPR will trap if, and only if, the condition
+        traps and hence we have to check this.  For all other operations, we
+        don't need to consider the operands.  */
+      if (op_code == COND_EXPR)
+       op_could_trap = generic_expr_could_trap_p (res_op->ops[0]);
+      else
+       op_could_trap = operation_could_trap_p ((tree_code) res_op->code,
+                                               FLOAT_TYPE_P (res_op->type),
+                                               honor_trapv,
+                                               res_op->op_or_null (1));
+
+      if (!op_could_trap)
        {
          res_op->cond.cond = NULL_TREE;
          return false;
@@ -949,10 +963,9 @@ gimple_simplify (gimple *stmt, gimple_match_op *res_op, gimple_seq *seq,
            {
              bool valueized = false;
              tree rhs1 = gimple_assign_rhs1 (stmt);
-             /* If this is a [VEC_]COND_EXPR first try to simplify an
+             /* If this is a COND_EXPR first try to simplify an
                 embedded GENERIC condition.  */
-             if (code == COND_EXPR
-                 || code == VEC_COND_EXPR)
+             if (code == COND_EXPR)
                {
                  if (COMPARISON_CLASS_P (rhs1))
                    {
@@ -1146,6 +1159,16 @@ canonicalize_math_after_vectorization_p ()
   return !cfun || (cfun->curr_properties & PROP_gimple_lvec) != 0;
 }
 
+/* Return true if we can still perform transformations that may introduce
+   vector operations that are not supported by the target. Vector lowering
+   normally handles those, but after that pass, it becomes unsafe.  */
+
+static inline bool
+optimize_vectors_before_lowering_p ()
+{
+  return !cfun || (cfun->curr_properties & PROP_gimple_lvec) == 0;
+}
+
 /* Return true if pow(cst, x) should be optimized into exp(log(cst) * x).
    As a workaround for SPEC CPU2017 628.pop2_s, don't do it if arg0
    is an exact integer, arg1 = phi_res +/- cst1 and phi_res = PHI <cst2, ...>