This helps handling a case where the BUILD_VECTOR has i16 element type and i32 constant operands t2: v8i16 = setcc t8, t17, setult:ch t3: v8i16 = BUILD_VECTOR Constant:i32<1>, ... t4: v8i16 = and t2, t3 t5: v8i16 = add t8, t4 This can be turned into t5: v8i16 = sub t8, t2, and allows us to remove t3 and t4 from the DAG.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
15425 ↗ | (On Diff #435362) | Declare Known on the line where it is assigned. KnownBits Known = DAG.computeKnownBits... |
15432 ↗ | (On Diff #435362) | This is no inconsistent with the other call to computeKnownBits. I think for both you can do DAG.computeKnownBits(LHS) or DAG.computeKnownBits(RHS). |
This shoudl have been picked up by foldAddSubMasked1 in the generic DAG combiner but wasn't because the BUILD_VECTOR has i8 element type and i32 constant operands. We should fix that to not require the widths to match.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | ||
---|---|---|
10664–10665 | Are all of the callers of isOneOrOneSplat ok with this change? Is this change correct for the caller you’re interested in if the element type of the build_vector is i1? |
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | ||
---|---|---|
10664–10665 | Let me go through the callers one by one. There are 8 uses of isOneOrOneSplat in llvm, all in DAGCombiner.cpp. so far, I ran through check-llvm and looks good. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | ||
---|---|---|
10664–10665 | The bitwidth check was added https://reviews.llvm.org/D25374 and I have ran check-llvm-codegen for all available targets and things are fine. |
@adriantong1024 Please can you rebase after rGadfcdb0d0d4af1194121211c125c291162b43ccd?
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | ||
---|---|---|
10664–10665 | This comment can probably go - unlike Null/AllOnes this isn't going to work well if the bitcast is to a vector type with different scalar sizes |
I ran ninja check-lld check-libc check-flang check-llvm check-polly check-bolt check-mlir check-all check-clang check-clang-tools check-openmp locally and things are good.
Are all of the callers of isOneOrOneSplat ok with this change?
Is this change correct for the caller you’re interested in if the element type of the build_vector is i1?