-
Notifications
You must be signed in to change notification settings - Fork 224
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
Support llvm.frexp intrinsic translation #2252
Conversation
This change also fixes reverse translation of non-constant values of `OpCompositeConstruct`.
Please take a look @MrSidims @asudarsa @LU-JOHN @bwlodarcz @VyacheslavLevytskyy |
There is a value to put it in a separate PR. Reason is that the bug fix alone is a good candidate to be backported to earlier release branches |
I'll try to come up with a PRs split. |
Please take a look @LU-JOHN @bwlodarcz @VyacheslavLevytskyy Thanks |
During review I checked what will happen when:
which is correct llvm IR.
but looking on OpenCL extension spec:
Is this correct? I mean can we pass |
No, we mustn't expect that. And I do believe, that it is LLVM bug - it makes a little sense for frexp to store integral exponent of a float to i1 (unless you want to support mini-floats, but it's not part of LLVM and it's unlikely to be inherited from just float). I suggest that we add here an assertion (or an error, but IMHO assertion here is better) to check if input integer is not i1. For the rest integer types we should add conversion to i32 by UConvert to obey the spec https://registry.khronos.org/SPIR-V/specs/1.0/OpenCL.ExtendedInstructionSet.100.mobile.html "exp must be a pointer(global, local, private, generic) to i32 or vector(2,3,4,8,16) of i32 values". |
Why just not use everywhere |
lib/SPIRV/SPIRVWriter.cpp
Outdated
SPIRVTypePointer *ITy = static_cast<SPIRVTypePointer *>(transPointerType( | ||
II->getType()->getStructElementType(1), SPIRAS_Private)); | ||
|
||
assert(ITy->getElementType()->getBitWidth() == 32); |
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.
Is this check in conformance with comments? Do we want to assert out if type is i16?
Also two other comments:
- Can we pls add a test for this?
- Can we add a error message here?
Thanks
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.
Do we want to assert out if type is i16?
Yes, because the intrinsic is used only with i32 by OpenCL Ext Inst set specification. And actually LLVM language reference also allows only i32 here.
- Can we pls add a test for this?
OK, I can add a separate negative test for that.
- Can we add a error message here?
I agree with Dmitry that the assertion is better in this case. Do you mind if I leave it as is?
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.
Looks good. few comments to address.
Thanks
|
||
; CHECK-SPIRV: ExtInstImport [[#ExtInstSetId:]] "OpenCL.std" | ||
|
||
; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 |
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.
Do we want to make this CHECK-SPIRV-DAG in case the order changes in the future?
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.
Not sure about that - I don't think that types would be shuffled.
I guess we should proceed as is and add DAG checks only if the ordering problem appears.
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.
LGTM
Restarting CI, merging afterwards |
Map
@llvm.frexp
intrinsic to OpenCL Extended Instructionfrexp
builtin.The difference in signatures and return values is covered by extracting/combining values from and into composite type.