llvm/llvm-project

[DAG] ISD::matchUnaryPredicate / matchUnaryFpPredicate / matchBinaryPredicate - add DemandedElts variant

已关闭

#181,658 创建于 2026年2月16日

 (6 条评论) (1 个反应) (1 位负责人)C++ (10,782 个派生)batch import
good first issuellvm:SelectionDAG

仓库指标

星标
 (26,378 个星标)
PR 合并指标
 (平均合并 1天 2小时) (30 天内合并 1,000 个 PR)

描述

The ISD::match*Predicate methods help us to perform all_of tests on scalar/splat/build_vector constants with a callback test.

It'd be very useful if we could provide variants of these that take a DemandedElts argument (similar to #181485 and other DAG value tracking methods), to allow us to restrict the build_vector tests to specific elements.

For instance, this would allow us to remove the vector constant checks from isKnownToBeAPowerOfTwo entirely and just use the initial matchUnaryPredicate call at the start of the method:

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

scalar/splat cases can just ignore the DemandedElts argument, but we should assert the build_vector are the same size as the DemandedElts APInt

贡献者指南