-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISCV] Vector binary ops of splats aren't scalarized on fixed vectors #65068
Labels
Comments
lukel97
added
backend:RISC-V
llvm:codegen
missed-optimization
llvm:SelectionDAG
SelectionDAGISel as well
labels
Aug 29, 2023
@llvm/issue-subscribers-backend-risc-v |
candidate patch : https://reviews.llvm.org/D159190 |
Looking forward to a more generalized solution. |
lukel97
added a commit
to lukel97/llvm-project
that referenced
this issue
Sep 8, 2023
This adds tests for fixed and scalable vectors where we have a binary op on two splats that could be scalarized. Normally this would be scalarized in the middle-end by VectorCombine, but as noted in https://reviews.llvm.org/D159190, this pattern can crop up during CodeGen afterwards. Note that a combine already exists for this, but currently it only works on scalable vectors where the element type == XLEN. See llvm#65068 and llvm#65072
lukel97
added a commit
to lukel97/llvm-project
that referenced
this issue
Sep 13, 2023
When scalarizing bin ops of splats, we treat the extract as free for a splat_vector because its operand is already scalar, i.e. (extract idx, (splat_vector x)) -> x. The same also applies for a build_vector that's a splat: (extract idx, (build_vector x x x x)) -> x. This patch takes this into account, which enables scalarization for fixed length vectors, since the current canonical form for a splatted fixed length vector is still build_vector. This improves what we were seeing on RISC-V in llvm#65068, but unfortunately causes some patterns to be missed on other targets. One big one is that on AArch64 and X86 scalarizing (xor (splat x), (splat -1)) to (splat (xor x, -1)) prevents vnot from being matched, which for example prevents bif from being matched. Posting this patch as a WIP to show my findings.
lukel97
added a commit
that referenced
this issue
Sep 20, 2023
…65747) This adds tests for fixed and scalable vectors where we have a binary op on two splats that could be scalarized. Normally this would be scalarized in the middle-end by VectorCombine, but as noted in https://reviews.llvm.org/D159190, this pattern can crop up during CodeGen afterwards. Note that a combine already exists for this, but on RISC-V currently it only works on scalable vectors where the element type == XLEN. See #65068 and #65072
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The functions below multiply a vector with a splatted scalar, computed from an add:
When compiled with
llc -o - -mattr=+v
, the splatted add is scalarized for the scalable version:But the fixed version doesn't:
The text was updated successfully, but these errors were encountered: