Skip to content
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

add support for the 'fcmp false' instruction #2251

Merged
merged 5 commits into from
Dec 7, 2023

Conversation

VyacheslavLevytskyy
Copy link
Contributor

@VyacheslavLevytskyy VyacheslavLevytskyy commented Dec 5, 2023

There is no direct equivalent for "fcmp false" in the specification [https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_relational_and_logical_instructions], but we may return ConstantFalse in this case instead of reporting error.

This patch depends on #2216

@VyacheslavLevytskyy
Copy link
Contributor Author

@MrSidims @bwlodarcz Can you please have a look

@bwlodarcz
Copy link
Contributor

Unfortunately the 'fcmp' instruction can go through vector also. I prepared test:

define spir_func <4 x i1> @g(<4 x float> %0) {
entry:
 %1 = fcmp false <4 x float> %0, %0
 ret <4 x i1> %1
}

llvm-as and translator passes but spirv-val

error: line 28: OpReturnValue Value <id> '15[%false_0]'s type does not match OpFunction's return type.
  OpReturnValue %false_0

Without further investigation I interpret this error that ConstantFalse is constant type declaration. In SPIRV BoolType != Constant BoolType. So the return type of the function is not the same as the one returned.

@VyacheslavLevytskyy
Copy link
Contributor Author

VyacheslavLevytskyy commented Dec 5, 2023

@bwlodarcz Thank you. Let's represent a vector of false values as a OpConstantNull ("The null value is type dependent, defined as follows: - Scalar Boolean: false ... Composites: Members are set recursively to the null constant according to the null value of their constituent types.")

@VyacheslavLevytskyy
Copy link
Contributor Author

Please take a look @asudarsa @LU-JOHN

@bwlodarcz
Copy link
Contributor

LGTM.

@MrSidims MrSidims requested review from asudarsa and svenvh December 6, 2023 12:30
Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@asudarsa asudarsa merged commit aeeaf6c into KhronosGroup:main Dec 7, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants