On 10/29/26 3:04 AM, Sendao Yan wrote:
Moving pass_lower_switch after the late jump threading changed the
control flow seen by the uninitialized warning pass, exposing two
false positives (PR107919 and PR44547). Both stem from the same
defect in uninit_analysis::is_use_guarded.
is_use_guarded treats an empty use predicate (the PHI is defined and
used in the same block) as an unguarded use because init_use_preds
returns false when the predicate is empty. That is wrong: whether
such a use is guarded depends solely on the definition predicate, so
fall through and compute it.
An empty (TRUE) use predicate is then matched by m_phi_def_preds being
TRUE, i.e. the value is defined on every path. Two spots made this
mismatch on a TRUE use predicate:
- predicate::simplify_2 folded a tautological disjunction to TRUE by
clearing m_preds but forgot to set m_cval, so a definition
predicate that simplified to TRUE was misread as FALSE ("never
defined"). Set m_cval as well.
- the fallback path only recognized an implied guard when the
relaxed definition predicate was a superset of the use predicate,
which is vacuous for a TRUE use predicate; simplify and normalize
the relaxed predicate and check relaxed.is_true () instead.
gcc/ChangeLog:
* gimple-predicate-analysis.cc (predicate::simplify_2): Set
m_cval when a disjunction simplifies to true.
(uninit_analysis::is_use_guarded): Do not return early for an
empty use predicate; skip the overlap pruning and use an
is_true-based superset test for an unconditional use; simplify
and normalize the relaxed definition predicate in the fallback
and test it with is_true for an unconditional use.
Sashiko noted several medium/low issues. Can you take a look at its
output and either adjust your patch if the issues are real or if they're
not real issues, just note it as a followup comment? I'm not going to
get to this tonight, but we might as well address whatever Sashiko found
proactively.
https://gcc.sashiko.dev/#/patchset/20261029090402.3747255-1-yansendao%40126.com
Thanks,
jeff