https://gcc.gnu.org/g:a1bff044b64eb06bdf3d17dc92244f0cde735e8d
commit r17-4893-ga1bff044b64eb06bdf3d17dc92244f0cde735e8d Author: Aldy Hernandez <[email protected]> Date: Sun Oct 4 13:03:33 2026 +0000 DOM: stop deriving implied conditions in record_conditions Most of what record_conditions is doing is a NOP, as ranger is picking it up. We can nuke the derivations. I tested that there is no difference in the assembly at -O2 for my .ii bootstrap files, as well as the preprocessed Fortran files I keep from a LAPACK build (for floating point stuff). I also confirmed that LAPACK internal tests pass. And of course, the usual regression tests. So I think this is dead code, and can be removed. Tested on ppc64le Linux. gcc/ChangeLog: * tree-ssa-scopedtables.cc (build_and_record_new_cond): Remove. (record_conditions): Do not derive the implied conditions. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ssa-dom-simplify-5.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-simplify-5.c | 79 ++++++++++++++++++ gcc/tree-ssa-scopedtables.cc | 93 ---------------------- 2 files changed, 79 insertions(+), 93 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-simplify-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-simplify-5.c new file mode 100644 index 000000000000..7d00d74613ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-simplify-5.c @@ -0,0 +1,79 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fno-tree-vrp -fdump-tree-dom2" } */ + +/* x < y where x and y are tested for being unordered, so they are not; + x == y where x <= y is tested, so it holds; and i < j where i != j + is tested, so it holds. */ + +void link_error (void); + +void __GIMPLE (ssa,startwith("dom")) +by_lt (float x, float y) +{ + __BB(2): + if (x_1(D) < y_2(D)) + goto __BB3; + else + goto __BB5; + + __BB(3): + if (x_1(D) __UNORDERED y_2(D)) + goto __BB4; + else + goto __BB5; + + __BB(4): + link_error (); + goto __BB5; + + __BB(5): + return; +} + +void __GIMPLE (ssa,startwith("dom")) +by_eq (float x, float y) +{ + __BB(2): + if (x_1(D) == y_2(D)) + goto __BB3; + else + goto __BB5; + + __BB(3): + if (x_1(D) <= y_2(D)) + goto __BB5; + else + goto __BB4; + + __BB(4): + link_error (); + goto __BB5; + + __BB(5): + return; +} + +void __GIMPLE (ssa,startwith("dom")) +by_lt_int (int i, int j) +{ + __BB(2): + if (i_1(D) < j_2(D)) + goto __BB3; + else + goto __BB5; + + __BB(3): + if (i_1(D) != j_2(D)) + goto __BB5; + else + goto __BB4; + + __BB(4): + link_error (); + goto __BB5; + + __BB(5): + return; +} + +/* { dg-final { scan-tree-dump-not "link_error" "dom2" } } */ diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc index 35ce7586d8bc..1dba346763c8 100644 --- a/gcc/tree-ssa-scopedtables.cc +++ b/gcc/tree-ssa-scopedtables.cc @@ -966,30 +966,6 @@ initialize_expr_from_cond (tree cond, struct hashable_expr *expr) gcc_unreachable (); } -/* Build a cond_equivalence record indicating that the comparison - CODE holds between operands OP0 and OP1 and push it to **P. */ - -static void -build_and_record_new_cond (enum tree_code code, - tree op0, tree op1, - vec<cond_equivalence> *p, - bool val = true) -{ - cond_equivalence c; - struct hashable_expr *cond = &c.cond; - - gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison); - - cond->type = boolean_type_node; - cond->kind = EXPR_BINARY; - cond->ops.binary.op = code; - cond->ops.binary.opnd0 = op0; - cond->ops.binary.opnd1 = op1; - - c.value = val ? boolean_true_node : boolean_false_node; - p->safe_push (c); -} - /* Record that COND is true and INVERTED is false into the edge information structure. Also record that any conditions dominated by COND are true as well. @@ -999,80 +975,11 @@ build_and_record_new_cond (enum tree_code code, void record_conditions (vec<cond_equivalence> *p, tree cond, tree inverted) { - tree op0, op1; cond_equivalence c; if (!COMPARISON_CLASS_P (cond)) return; - op0 = TREE_OPERAND (cond, 0); - op1 = TREE_OPERAND (cond, 1); - - switch (TREE_CODE (cond)) - { - case LT_EXPR: - case GT_EXPR: - if (FLOAT_TYPE_P (TREE_TYPE (op0))) - { - build_and_record_new_cond (ORDERED_EXPR, op0, op1, p); - build_and_record_new_cond (LTGT_EXPR, op0, op1, p); - } - - build_and_record_new_cond ((TREE_CODE (cond) == LT_EXPR - ? LE_EXPR : GE_EXPR), - op0, op1, p); - build_and_record_new_cond (NE_EXPR, op0, op1, p); - build_and_record_new_cond (EQ_EXPR, op0, op1, p, false); - break; - - case GE_EXPR: - case LE_EXPR: - if (FLOAT_TYPE_P (TREE_TYPE (op0))) - { - build_and_record_new_cond (ORDERED_EXPR, op0, op1, p); - } - break; - - case EQ_EXPR: - if (FLOAT_TYPE_P (TREE_TYPE (op0))) - { - build_and_record_new_cond (ORDERED_EXPR, op0, op1, p); - } - build_and_record_new_cond (LE_EXPR, op0, op1, p); - build_and_record_new_cond (GE_EXPR, op0, op1, p); - break; - - case UNORDERED_EXPR: - build_and_record_new_cond (NE_EXPR, op0, op1, p); - build_and_record_new_cond (UNLE_EXPR, op0, op1, p); - build_and_record_new_cond (UNGE_EXPR, op0, op1, p); - build_and_record_new_cond (UNEQ_EXPR, op0, op1, p); - build_and_record_new_cond (UNLT_EXPR, op0, op1, p); - build_and_record_new_cond (UNGT_EXPR, op0, op1, p); - break; - - case UNLT_EXPR: - case UNGT_EXPR: - build_and_record_new_cond ((TREE_CODE (cond) == UNLT_EXPR - ? UNLE_EXPR : UNGE_EXPR), - op0, op1, p); - build_and_record_new_cond (NE_EXPR, op0, op1, p); - break; - - case UNEQ_EXPR: - build_and_record_new_cond (UNLE_EXPR, op0, op1, p); - build_and_record_new_cond (UNGE_EXPR, op0, op1, p); - break; - - case LTGT_EXPR: - build_and_record_new_cond (NE_EXPR, op0, op1, p); - build_and_record_new_cond (ORDERED_EXPR, op0, op1, p); - break; - - default: - break; - } - /* Now store the original true and false conditions into the first two slots. */ initialize_expr_from_cond (cond, &c.cond);
