-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
use case: a builtin that does the equivalent of x86.avx2.phsub.w on a SIMD vector #16387
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
Comments
Thanks for the report. As you suspected I'm going to close it as a duplicate of #2291. However, let's see if we can get your use case solved. What does this instruction do? Surely this is not merely vector subtraction? |
The use case isn't this intrinsic specifically, I actually picked a random one from Intel's Intrinsics Guide just to showcase the more general issue, apologies if this wasn't clear from the original issue description. The general reproducer seems to be: any intrinsic requiring an additional CPU feature. It won't get selected correctly, regardless of the global CPU feature set. Two things follow from this that may or may not be relevant/interesting:
As for my specific use case: If a choice is to be made between some general WONTFIX LLVM backend issue and adding builtins willy-nilly on a case by case basis, then I would much rather concede my specific use case for now in favor of some more general, systematic effort to bring such functionality to Zig in the future. |
Whatever the issue was here, I can't reproduce it anymore on Remaining issues:
That being said, I'm going to open additional issues for these. It's not worth it to fix these just to make another "bug" work slightly better. |
Zig Version
0.11.0-dev.3978+711b4e93e
Steps to Reproduce and Observed Behavior
zig build-lib a.zig -O ReleaseSmall -mcpu=haswell
. ReleaseSmall is again arbitrary and only used to get nicer output. The CPU only matters insofar that the specific target feature is included, AVX2 in this case.LLVM Emit Object... LLVM ERROR: Cannot select: intrinsic %llvm.x86.avx2.phsub.w
. No binary is produced.Adding
--verbose-llvm-(ir|bc)=a.(ll|bc)
to the build command still fails with the same LLVM error, but produces a valid IR file that can be compiled withllc
no problem. In the IR file the correct target feature is set as well, so it seems the problem is somewhere on the Zig side. Maybe Zig is failing to pass the (correct) target features somewhere?Expected Behavior
Should compile using the LLVM backend with an appropriate target CPU.
I am aware this is #2291 and one day won't work on purpose. But there is no resolution to that issue yet, so this should work in the meantime IMO - if not, feel free to close this issue (and to be fair, inline assembly gets you some of the way there, but it leaves a lot to be desired in terms of codegen in my experience).
The text was updated successfully, but these errors were encountered: