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
[aarch64] Double vbsl intrinsics with literal masks are converted to and/orr #62642
Comments
@llvm/issue-subscribers-backend-aarch64 |
Using the optimisation level Which means this is an issue with the instruction lowering which doesn't want to combine (I've got to find where the DAG pattern is defined in the tbl gen sorry only found the cpp stuff for now) :
Anyway, when using |
That would explain the last mask being inverted. |
AArch64 instruction lowering can recognize I think the potential fix will go into InstCombine to prevent it from messing with the sequence. |
In certain scenarios, passing the result of
bsl
/bit
/bif
to anotherbsl
/bit
/bif
when using literal masks will result in expansion toand
andorr
. It seems to be adjusting the masks (as seen in the ARMv7-A equivalent) but it ends up being too aggressive.Example code:
Expected code: something like
Or based on the masked transformation it optimized it to:
Actual (clang 16.0.2 -O3)
This only seems to affect AArch64 mode. ARMv7-a still emits bsl despite the mask transformation, but that seems to be because unlike aarch64 which is expanded to bitwise operations in LLVM, ARMv7 uses
llvm.arm.neon.vbsl.v16i8
. With the expanded LLVM IR ARMv7-a emits the same thing albeit slightly reordered.The text was updated successfully, but these errors were encountered: