-
Notifications
You must be signed in to change notification settings - Fork 221
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
Replace llvm.fmuladd.v1f* with llvm.fmuladd.f* since OpenCL doesn't support length-1 vector. #2868
base: main
Are you sure you want to change the base?
Conversation
…upport length-1 vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't resist to merge the patch, yet my preference to fix this earlier in the compilation stack (before the translator) by replacing all <1 x ...> vectors in the module with scalars. My opinion that we better not to do such replacements in the translator. The reason is that we don't know the environment for which LLVM IR was compiled and I can imagine an unlikely yet possible situation, when LLVM IR compiled for RISC-V architecture comes as an input to the translator and AFAIK <1 x ...> vectors in LLVM IR can be used to represent scalable vectors RISC-V extension. So replacing them with scalars in the translator would be incorrect. Counterargument would be: for this RISC-V folks should add a new extension in SPIR-V, so until it's enabled we could replace vectors with scalars, but IMO it's still better not to do so and continue to emit an error.
UPD: ... LLVM IR are used ... -> ... LLVM IR can be used ...
@@ -0,0 +1,109 @@ | |||
; RUN: llvm-as < %s -o %t.bc | |||
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_vector_compute -o %t.spv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension is not standard and we shouldn't rely on it. Meanwhile you have to use it as there are <1 x ...> vectors in the module.
Thanks for quick reply, @MrSidims, the IR is valid, the number of elements for vector type is a constant integer value larger than 0 in llvm ir https://llvm.org/docs/LangRef.html#vector-type. Component Count of spirv OpTypeVector must be at least 2 https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpTypeVector. There are gaps for IR and spirv. @bashbaug , what do you think? Thanks very much. |
@haonanya1 that's correct. But here comes the question whether we consider https://github.com/KhronosGroup/SPIRV-LLVM-Translator as a proper backend with instructions/intrinsics lowering and types legalization or just as a translator, which just translates one IR form into another form of IR. Currently we are positioning it somewhere in between, doing lowering and not doing legalization. Yet again, it might be OK to add mapping for <1 x ...> vectors to scalars, but I'm a bit afraid to break existing or future flows as <1 x ...> can be also a scalable vector. May be it's fine to break it, at least we would know if we have such customers from incoming llvm-spirv github issue(s) :-) I'd like to hear opinion from @svenvh . I'll propose the PR to OpenCL TSG meeting. |
Aren't scalable vectors represented using I don't have strong objections against doing a vec1 -> scalar replacement in the translator. However I would suggest to implement that as a separate pass, and not only for the |
Oh, indeed, not sure why I though it's just <1 x ...>. So no objections from me to do such transformation. |
No description provided.