On 11/2/26 12:48 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, if it is TRUE (defined on every path),
treat it as guarding any use, otherwise fall back to superset_of
for a conditional use.
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 treat a TRUE relaxed predicate as guarding any use.
Thanks. Sashiko claimed one new concern, particularly this could lead
to an ICE. It's the only high finding in this report
https://gcc.sashiko.dev/#/patchset/20261102074810.2976046-1-yansendao%40126.com