[llvm] [DAG] ISD::matchUnaryPredicate / matchUnaryFpPredicate / matchBinaryPredicate - add DemandedElts variant (PR #183013)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 2 01:08:47 PDT 2026
================
@@ -361,8 +361,14 @@ bool ISD::matchUnaryPredicateImpl(SDValue Op,
ISD::SPLAT_VECTOR != Op.getOpcode())
return false;
+ if (ISD::SPLAT_VECTOR == Op.getOpcode() && DemandedElts == 0)
+ return true;
+
EVT SVT = Op.getValueType().getScalarType();
for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
+ if (!DemandedElts[i])
----------------
VachanVY wrote:
<details>
`Op = [2, 2, 2, 2]` `DemandedElts = [0, 0, 1, 0]`
For splat vectors `e = Op.getNumOperands()` is `1`, we never really get to check the demanded lane if we don't have `ISD::SPLAT_VECTOR != Op.getOpcode()`
So when a normal vector and not demanded lane then skip the check
```cpp
if (ISD::SPLAT_VECTOR == Op.getOpcode() && !DemandedElts)
return true;
```
We are sure that if it is Splat vector atleast one lane is sure to be demanded due to early return before itself as above.
</details>
https://github.com/llvm/llvm-project/pull/183013
More information about the llvm-commits
mailing list