[llvm-branch-commits] [llvm] [DAG][AArch64] Handle truncated buildvectors to allow and(subvector(anyext)) fold. (PR #133915)
Simon Pilgrim via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 2 01:55:07 PDT 2025
================
@@ -7166,7 +7166,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
// if (and x, c) is known to be zero, return 0
unsigned BitWidth = VT.getScalarSizeInBits();
- ConstantSDNode *N1C = isConstOrConstSplat(N1);
+ ConstantSDNode *N1C =
+ isConstOrConstSplat(N1, /*AllowUndef*/ false, /*AllowTrunc*/ true);
----------------
RKSimon wrote:
we could replace this with something like:
```cpp
std::optional<APInt> N1C;
if (ConstantSDNode *C1 = isConstOrConstSplat(N1, /*AllowUndef*/ false, /*AllowTrunc*/ true))
N1C = C1->getAPIntValue().zextOrTrunc(BitWidth);
```
WDYT?
https://github.com/llvm/llvm-project/pull/133915
More information about the llvm-branch-commits
mailing list