https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90036
--- Comment #21 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:f23a339a686ed6cc6a4838459bc220e48ba901cb commit r16-7825-gf23a339a686ed6cc6a4838459bc220e48ba901cb Author: Jeff Law <[email protected]> Date: Sat Feb 28 08:54:23 2026 -0700 [PR tree-optimization/90036] Backpropagate more equivalences in DOM And now the rest of the fix for 90036. Two changes of note. First, when recording temporary equivalences from the edge info cache, if the equivalence has the form: [0/1] = A EQ/NE CST; Go ahead and backprop that equivalence to the uses of A. Concretely from the BZ we have this: > ;; basic block 2, loop depth 0 > ;; pred: ENTRY > _1 = vptr_14(D) == 0; > _2 = ownvptr_15(D) != 0; > _3 = _1 | _2; > if (_3 != 0) > goto <bb 4>; [67.00%] > else > goto <bb 3>; [33.00%] > ;; succ: 4 > ;; 3 [ ... ] > ;; basic block 4, loop depth 0 > ;; pred: 2 > if (vptr_14(D) != 0) > goto <bb 5>; [25.37%] > else > goto <bb 10>; [74.63%] > ;; succ: 5 > ;; 10 > > ;; basic block 5, loop depth 0 > ;; pred: 4 > # definition_10 = PHI <0(4)> > # vstring_9 = PHI <0B(4)> > if (ownvptr_15(D) != 0) > goto <bb 7>; [80.00%] > else > goto <bb 6>; [20.00%] > ;; succ: 7 > ;; 6 > > ;; basic block 6, loop depth 0 > ;; pred: 5 > sprintf (p_13(D), "~%%%s", vstring_9); > goto <bb 10>; [100.00%] > ;; succ: 10 So when DOM discovers the edge equivalence for vptr_14 on the 4->5 edge DOM now back-propagates the value to the uses of vptr_14, particularly uses in bb#1. That allows us to discover a simple equivalence for _1 which is a key nugget to unlocking this BZ. 1 = (_3 != 0) by way of traversing the 2->4 edge. 1 = (vptr_14 != 0) by way of traversing the 4->5 edge _1 = 0 by backproping the state of vptr_14 to use point in bb1 The last step is to back-propagate the _1 = 0 equivalence to the use points of _1 in bb1. In particular to this statement _3 = _1 | _2; If we know that _1 == 0, then _3 and _2 must have the same values (nonzero in this case). _2 = ownvptr_15(D) != 0; Since we know the state of _2, we can compute the state of ownvptr_15. Which was the goal. We're still on the 4->5 edge, but we've managed to compute an equivalence for ownvptr_15 which in turn allows us to know how the branch at the end of bb5 will go. Note this is not jump threading. It's a conditional equivalence with back propagation. The additional lookups in the hash table trigger messages in the dump file. The unconstrained_commons.f test scans the DOM dump file to ensure certain messages never appear. That scan test is now bogus. The test has other things it checks to ensure DOM hasn't done anything wrong. So that one scan test in unconstrained_commons.f has been removed. Bootstrapped and regression tested on x86, armv7, loongarch64, riscv64. Regression tested on the usual crosses as well. PR tree-optimization/90036 gcc/ * tree-ssa-dom.cc (back_propagate_equivalences): Accept new argument for available expression stack. Lookup equivalences in the expression hash table too. If an expression hash a known constant value, record it and recurse. (record_temporary_equivalences): Back propagate for a subset of edge equivalences. gcc/testsuite * gcc.dg/tree-ssa/pr90036.c: New test. * gfortran.dg/unconstrained_commons.f: Drop useless DOM hash table lookup check.
