llvm/llvm-project

[DAG] isKnownToBeAPowerOfTwo - add DemandedElts + OrZero handling to ISD::ZERO_EXTEND cases

Geschlossen

#181.648 geöffnet am 16.02.2026

 (7 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
good first issuellvm:SelectionDAG

Repository-Metriken

Stars
 (26.378 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

The zext nodes can safely filter elements using DemandedElts and can correctly identify zero cases when OrZero is true (zext(0) is still 0):

https://github.com/RKSimon/llvm-project/blob/20aff2085c358d3e112b245494161ddb9ffe0410/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L4755-L4757

The actual change to the inner isKnownToBeAPowerOfTwo call is trivial (add DemandedElts + OrZero passthrough args), but this will require test coverage as well - these might be possible by extending existing DAG tests, else maybe add unit tests like we did in https://github.com/llvm/llvm-project/pull/181485

Contributor Guide