v3 of the series; thanks for running v2 through your tester.  Only 2/2
changed, 1/2 is identical to v2.

Changes since v2, from the Sashiko review of v2 [1]:

- Fix the ICE that was reported as the only High finding.  Before this
  series predicate::simplify() was only ever called on predicates built
  from comparisons (use_preds and m_phi_def_preds are simplified and then
  normalized).  normalize() breaks that invariant: a bit test written as
  "if (x & 4)" is recorded as a pred_info with cond_code == BIT_AND_EXPR,
  and 2/2 calls simplify() on a copy of the already-normalized definition
  predicate.  pred_neg_p() then calls invert_tree_comparison() with that
  code, and simplify_1b() hands it to maybe_fold_and_comparisons(); both
  reach gcc_unreachable().  pred_equal_p() has had the
  TREE_CODE_CLASS (..) == tcc_comparison guard since 94c12ffac23;
  pred_neg_p() lost it in the same commit.  v3 gives pred_neg_p() the same
  guard and skips non-comparison pairs in simplify_1b().  I could not
  build a testcase that trips it, so this part is a defensive fix, but the
  path is newly reachable after 2/2 and the failure mode would be an
  ice-on-valid-code.  If the analysis behind the report has a testcase or a
  build/test command that reaches it, please send it along and I will add it
  to the testsuite.

- drop_conjuncts_implied_by() can remove every conjunct of a chain; an
  empty conjunct is TRUE, so turn that into an empty predicate with
  m_cval set, the way simplify_2() does, instead of leaving an empty chain
  behind.

- Drop the "use_preds.is_true () ? m_phi_def_preds.is_true () : ..." test
  added in v2: is_true() implies an empty m_preds and we only get there
  with m_preds non-empty, so the TRUE side was dead code.

- The b_chain leak in simplify_2() was already fixed on trunk by the
  PR128365 change (78148ac7f7e), which is in the base of this version.

- predicate::simplify() drops a chain both when simplify_1b() proves it
  false and when it proves it true; only the latter is wrong.  That is
  pre-existing code that this series does not add, so I left it alone to
  keep the patch focused -- I can send a separate patch if wanted.

Bootstrapped on x86_64-pc-linux-gnu.  Tested: the uninit testcases
(gcc.dg/uninit*, gcc.dg/tree-ssa/uninit*, gcc.dg/uninit-pr44547.c) and the
new gcc.dg/tree-ssa/pr128102.c all pass.

[1] 
https://gcc.sashiko.dev/#/patchset/20261102074810.2976046-1-yansendao%40126.com


Sendao Yan (2):
  tree-optimization/128102 - lower switches after the late jump
    threading
  tree-optimization/128102 - fix -Wuninitialized FPs from lowering
    switches late

 gcc/gimple-predicate-analysis.cc         | 78 +++++++++++++++++++-----
 gcc/passes.def                           |  4 +-
 gcc/testsuite/gcc.dg/tree-ssa/pr128102.c | 69 +++++++++++++++++++++
 3 files changed, 134 insertions(+), 17 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr128102.c

-- 
2.34.1

Reply via email to