]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimple: Remove special handling of COND_EXPR for COMPARISON_CLASS_P [PR116949, PR114785]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 29 Oct 2024 21:43:42 +0000 (14:43 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 31 Oct 2024 01:07:24 +0000 (18:07 -0700)
After r13-707-g68e0063397ba82, COND_EXPR for gimple assign no longer could contain a comparison.
The vectorizer was builting gimple assigns with comparison until r15-4695-gd17e672ce82e69
(which added an assert to make sure it no longer builds it).

So let's remove the special handling COND_EXPR in a few places and add an assert to
gimple_build_assign_1 to make sure we don't build a gimple assign any more with a comparison.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR middle-end/114785
PR middle-end/116949
* gimple-match-exports.cc (maybe_push_res_to_seq): Remove special
handling of COMPARISON_CLASS_P in COND_EXPR/VEC_COND_EXPR.
(gimple_extract): Likewise.
* gimple-walk.cc (walk_stmt_load_store_addr_ops): Likewise.
* gimple.cc (gimple_build_assign_1): Add assert for COND_EXPR
so its 1st operand is not a comparison.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/gimple-match-exports.cc
gcc/gimple-walk.cc
gcc/gimple.cc

index 77d225825cfac68b633f4d93bc3c6eb24532df6a..bc8038c19f05de54d783bdc51c84ea07c3e8a839 100644 (file)
@@ -489,12 +489,6 @@ maybe_push_res_to_seq (gimple_match_op *res_op, gimple_seq *seq, tree res)
        && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
       return NULL_TREE;
 
-  if (num_ops > 0 && COMPARISON_CLASS_P (ops[0]))
-    for (unsigned int i = 0; i < 2; ++i)
-      if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME
-         && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i)))
-       return NULL_TREE;
-
   if (res_op->code.is_tree_code ())
     {
       auto code = tree_code (res_op->code);
@@ -786,11 +780,7 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
            }
          case GIMPLE_TERNARY_RHS:
            {
-             tree rhs1 = gimple_assign_rhs1 (stmt);
-             if (code == COND_EXPR && COMPARISON_CLASS_P (rhs1))
-               rhs1 = valueize_condition (rhs1);
-             else
-               rhs1 = valueize_op (rhs1);
+             tree rhs1 = valueize_op (gimple_assign_rhs1 (stmt));
              tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
              tree rhs3 = valueize_op (gimple_assign_rhs3 (stmt));
              res_op->set_op (code, type, rhs1, rhs2, rhs3);
index 9f768ca20fdad09137b35d760619dba2b27ceaa0..00520319aa901a26100c9ba38e850a48aee41cd0 100644 (file)
@@ -835,17 +835,6 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data,
            ;
          else if (TREE_CODE (op) == ADDR_EXPR)
            ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data);
-         /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
-            tree with two operands.  */
-         else if (i == 1 && COMPARISON_CLASS_P (op))
-           {
-             if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR)
-               ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0),
-                                                      0), op, data);
-             if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR)
-               ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1),
-                                                      0), op, data);
-           }
        }
     }
   else if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
index eeb1badff5fc6b52748676ac721ba1d290b8a592..f7b313be40e344d270a8da06f4804504c0428812 100644 (file)
@@ -475,6 +475,9 @@ gimple_build_assign_1 (tree lhs, enum tree_code subcode, tree op1,
         gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
                                    PASS_MEM_STAT));
   gimple_assign_set_lhs (p, lhs);
+  /* For COND_EXPR, op1 should not be a comparison. */
+  if (op1 && subcode == COND_EXPR)
+    gcc_assert (!COMPARISON_CLASS_P  (op1));
   gimple_assign_set_rhs1 (p, op1);
   if (op2)
     {