-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIRV] Addition of @llvm.lround.* and @llvm.llround.* intrinsic #129240
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
Open
aadeshps-mcw
wants to merge
1
commit into
llvm:main
Choose a base branch
from
aadeshps-mcw:aadesh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK: [[opencl:%[0-9]+]] = OpExtInstImport "OpenCL.std" | ||
; CHECK-DAG: [[f32:%[0-9]+]] = OpTypeFloat 32 | ||
; CHECK-DAG: [[i32:%[0-9]+]] = OpTypeInt 32 0 | ||
; CHECK-DAG: [[f64:%[0-9]+]] = OpTypeFloat 64 | ||
; CHECK-DAG: [[i64:%[0-9]+]] = OpTypeInt 64 0 | ||
; CHECK-DAG: [[vecf32:%[0-9]+]] = OpTypeVector [[f32]] | ||
; CHECK-DAG: [[veci32:%[0-9]+]] = OpTypeVector [[i32]] | ||
; CHECK-DAG: [[vecf64:%[0-9]+]] = OpTypeVector [[f64]] | ||
; CHECK-DAG: [[veci64:%[0-9]+]] = OpTypeVector [[i64]] | ||
|
||
; CHECK: [[rounded_i32_f32:%[0-9]+]] = OpExtInst [[f32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i32]] [[rounded_i32_f32]] | ||
; CHECK: [[rounded_i32_f64:%[0-9]+]] = OpExtInst [[f64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i32]] [[rounded_i32_f64]] | ||
; CHECK: [[rounded_i64_f32:%[0-9]+]] = OpExtInst [[f32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i64]] [[rounded_i64_f32]] | ||
; CHECK: [[rounded_i64_f64:%[0-9]+]] = OpExtInst [[f64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i64]] [[rounded_i64_f64]] | ||
; CHECK: [[rounded_v4i32_f32:%[0-9]+]] = OpExtInst [[vecf32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci32]] [[rounded_v4i32_f32]] | ||
; CHECK: [[rounded_v4i32_f64:%[0-9]+]] = OpExtInst [[vecf64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci32]] [[rounded_v4i32_f64]] | ||
; CHECK: [[rounded_v4i64_f32:%[0-9]+]] = OpExtInst [[vecf32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci64]] [[rounded_v4i64_f32]] | ||
; CHECK: [[rounded_v4i64_f64:%[0-9]+]] = OpExtInst [[vecf64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci64]] [[rounded_v4i64_f64]] | ||
|
||
define spir_func i32 @test_llround_i32_f32(float %arg0) { | ||
entry: | ||
%0 = call i32 @llvm.llround.i32.f32(float %arg0) | ||
ret i32 %0 | ||
} | ||
|
||
define spir_func i32 @test_llround_i32_f64(double %arg0) { | ||
entry: | ||
%0 = call i32 @llvm.llround.i32.f64(double %arg0) | ||
ret i32 %0 | ||
} | ||
|
||
define spir_func i64 @test_llround_i64_f32(float %arg0) { | ||
entry: | ||
%0 = call i64 @llvm.llround.i64.f32(float %arg0) | ||
ret i64 %0 | ||
} | ||
|
||
define spir_func i64 @test_llround_i64_f64(double %arg0) { | ||
entry: | ||
%0 = call i64 @llvm.llround.i64.f64(double %arg0) | ||
ret i64 %0 | ||
} | ||
|
||
define spir_func <4 x i32> @test_llround_v4i32_f32(<4 x float> %arg0) { | ||
entry: | ||
%0 = call <4 x i32> @llvm.llround.v4i32.f32(<4 x float> %arg0) | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define spir_func <4 x i32> @test_llround_v4i32_f64(<4 x double> %arg0) { | ||
entry: | ||
%0 = call <4 x i32> @llvm.llround.v4i32.f64(<4 x double> %arg0) | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define spir_func <4 x i64> @test_llround_v4i64_f32(<4 x float> %arg0) { | ||
entry: | ||
%0 = call <4 x i64> @llvm.llround.v4i64.f32(<4 x float> %arg0) | ||
ret <4 x i64> %0 | ||
} | ||
|
||
define spir_func <4 x i64> @test_llround_v4i64_f64(<4 x double> %arg0) { | ||
entry: | ||
%0 = call <4 x i64> @llvm.llround.v4i64.f64(<4 x double> %arg0) | ||
ret <4 x i64> %0 | ||
} | ||
|
||
declare i32 @llvm.llround.i32.f32(float) | ||
declare i32 @llvm.llround.i32.f64(double) | ||
declare i64 @llvm.llround.i64.f32(float) | ||
declare i64 @llvm.llround.i64.f64(double) | ||
|
||
declare <4 x i32> @llvm.llround.v4i32.f32(<4 x float>) | ||
declare <4 x i32> @llvm.llround.v4i32.f64(<4 x double>) | ||
declare <4 x i64> @llvm.llround.v4i64.f32(<4 x float>) | ||
declare <4 x i64> @llvm.llround.v4i64.f64(<4 x double>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK: [[opencl:%[0-9]+]] = OpExtInstImport "OpenCL.std" | ||
; CHECK-DAG: [[f32:%[0-9]+]] = OpTypeFloat 32 | ||
; CHECK-DAG: [[i32:%[0-9]+]] = OpTypeInt 32 0 | ||
; CHECK-DAG: [[f64:%[0-9]+]] = OpTypeFloat 64 | ||
; CHECK-DAG: [[i64:%[0-9]+]] = OpTypeInt 64 0 | ||
; CHECK-DAG: [[vecf32:%[0-9]+]] = OpTypeVector [[f32]] | ||
; CHECK-DAG: [[veci32:%[0-9]+]] = OpTypeVector [[i32]] | ||
; CHECK-DAG: [[vecf64:%[0-9]+]] = OpTypeVector [[f64]] | ||
; CHECK-DAG: [[veci64:%[0-9]+]] = OpTypeVector [[i64]] | ||
|
||
; CHECK: [[rounded_i32_f32:%[0-9]+]] = OpExtInst [[f32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i32]] [[rounded_i32_f32]] | ||
; CHECK: [[rounded_i32_f64:%[0-9]+]] = OpExtInst [[f64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i32]] [[rounded_i32_f64]] | ||
; CHECK: [[rounded_i64_f32:%[0-9]+]] = OpExtInst [[f32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i64]] [[rounded_i64_f32]] | ||
; CHECK: [[rounded_i64_f64:%[0-9]+]] = OpExtInst [[f64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[i64]] [[rounded_i64_f64]] | ||
; CHECK: [[rounded_v4i32_f32:%[0-9]+]] = OpExtInst [[vecf32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci32]] [[rounded_v4i32_f32]] | ||
; CHECK: [[rounded_v4i32_f64:%[0-9]+]] = OpExtInst [[vecf64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci32]] [[rounded_v4i32_f64]] | ||
; CHECK: [[rounded_v4i64_f32:%[0-9]+]] = OpExtInst [[vecf32]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci64]] [[rounded_v4i64_f32]] | ||
; CHECK: [[rounded_v4i64_f64:%[0-9]+]] = OpExtInst [[vecf64]] [[opencl]] round %[[#]] | ||
; CHECK-NEXT: %[[#]] = OpConvertFToS [[veci64]] [[rounded_v4i64_f64]] | ||
|
||
define spir_func i32 @test_lround_i32_f32(float %arg0) { | ||
entry: | ||
%0 = call i32 @llvm.lround.i32.f32(float %arg0) | ||
ret i32 %0 | ||
} | ||
|
||
define spir_func i32 @test_lround_i32_f64(double %arg0) { | ||
entry: | ||
%0 = call i32 @llvm.lround.i32.f64(double %arg0) | ||
ret i32 %0 | ||
} | ||
|
||
define spir_func i64 @test_lround_i64_f32(float %arg0) { | ||
entry: | ||
%0 = call i64 @llvm.lround.i64.f32(float %arg0) | ||
ret i64 %0 | ||
} | ||
|
||
define spir_func i64 @test_lround_i64_f64(double %arg0) { | ||
entry: | ||
%0 = call i64 @llvm.lround.i64.f64(double %arg0) | ||
ret i64 %0 | ||
} | ||
|
||
define spir_func <4 x i32> @test_lround_v4i32_f32(<4 x float> %arg0) { | ||
entry: | ||
%0 = call <4 x i32> @llvm.lround.v4i32.f32(<4 x float> %arg0) | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define spir_func <4 x i32> @test_lround_v4i32_f64(<4 x double> %arg0) { | ||
entry: | ||
%0 = call <4 x i32> @llvm.lround.v4i32.f64(<4 x double> %arg0) | ||
ret <4 x i32> %0 | ||
} | ||
|
||
define spir_func <4 x i64> @test_lround_v4i64_f32(<4 x float> %arg0) { | ||
entry: | ||
%0 = call <4 x i64> @llvm.lround.v4i64.f32(<4 x float> %arg0) | ||
ret <4 x i64> %0 | ||
} | ||
|
||
define spir_func <4 x i64> @test_lround_v4i64_f64(<4 x double> %arg0) { | ||
entry: | ||
%0 = call <4 x i64> @llvm.lround.v4i64.f64(<4 x double> %arg0) | ||
ret <4 x i64> %0 | ||
} | ||
|
||
declare i32 @llvm.lround.i32.f32(float) | ||
declare i32 @llvm.lround.i32.f64(double) | ||
declare i64 @llvm.lround.i64.f32(float) | ||
declare i64 @llvm.lround.i64.f64(double) | ||
|
||
declare <4 x i32> @llvm.lround.v4i32.f32(<4 x float>) | ||
declare <4 x i32> @llvm.lround.v4i32.f64(<4 x double>) | ||
declare <4 x i64> @llvm.lround.v4i64.f32(<4 x float>) | ||
declare <4 x i64> @llvm.lround.v4i64.f64(<4 x double>) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@maarquitos14 please advise, which triple should be used for vulkan and opencl
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.
Ideally, we should go with
spirv64-unknown-unknown-opencl
for opencl andspirv64-unknown-vulkan
for vulkan.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.
Why vulkan is the OS component of the target triple, but OpenCL is the environment? I think they must be the same component.
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 asked Google folks about that a while ago, this was their response:
Regarding OpenCL, it was introduced as an environment for something completely unrelated to SPIRV.
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.
As I mentioned here, OpenCL should also be OS component.
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.
How should I proceed with testing this intrinsic further?
Uh oh!
There was an error while loading. Please reload this page.
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.
We are aware, @MrSidims asked the original author in #78655 (comment), but we had no answer yet. I can try and address that in a future PR, but for now, this is the current status of things.
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'm okay with cleaning things up in the future.
I interpreted
Ideally
in your previous comment as the current state of things doesn't require any improvements.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.
Ah, I see. I said
ideally
because for openclspirv64-unknown-unknown
should work, but I'd prefer to start havingopencl
explicitly in the triples, so that somebody reading the tests doesn't have to guess if it's intended for OpenCL or Vulkan. Sorry for the confusion.