-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lowering of `llvm.bitreverse` and `llvm.trunc` intrinsics to DXIL ops. Fixes #86582 Fixes #86581
- Loading branch information
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,31 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for reversebits are generated for all integer types. | ||
|
||
; Function Attrs: nounwind | ||
define noundef i16 @test_bitreverse_short(i16 noundef %a) { | ||
entry: | ||
; CHECK:call i16 @dx.op.unary.i16(i32 30, i16 %{{.*}}) | ||
%elt.bitreverse = call i16 @llvm.bitreverse.i16(i16 %a) | ||
ret i16 %elt.bitreverse | ||
} | ||
|
||
; Function Attrs: nounwind | ||
define noundef i32 @test_bitreverse_int(i32 noundef %a) { | ||
entry: | ||
; CHECK:call i32 @dx.op.unary.i32(i32 30, i32 %{{.*}}) | ||
%elt.bitreverse = call i32 @llvm.bitreverse.i32(i32 %a) | ||
ret i32 %elt.bitreverse | ||
} | ||
|
||
; Function Attrs: nounwind | ||
define noundef i64 @test_bitreverse_long(i64 noundef %a) { | ||
entry: | ||
; CHECK:call i64 @dx.op.unary.i64(i32 30, i64 %{{.*}}) | ||
%elt.bitreverse = call i64 @llvm.bitreverse.i64(i64 %a) | ||
ret i64 %elt.bitreverse | ||
} | ||
|
||
declare i16 @llvm.bitreverse.i16(i16) | ||
declare i32 @llvm.bitreverse.i32(i32) | ||
declare i64 @llvm.bitreverse.i64(i64) |
This file contains 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,20 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for trunc are generated for float and half. | ||
|
||
define noundef float @trunc_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 29, float %{{.*}}) | ||
%elt.trunc = call float @llvm.trunc.f32(float %a) | ||
ret float %elt.trunc | ||
} | ||
|
||
define noundef half @trunc_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 29, half %{{.*}}) | ||
%elt.trunc = call half @llvm.trunc.f16(half %a) | ||
ret half %elt.trunc | ||
} | ||
|
||
declare half @llvm.trunc.f16(half) | ||
declare float @llvm.trunc.f32(float) |
This file contains 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,10 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation trunc does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload Type | ||
|
||
define noundef double @trunc_double(double noundef %a) { | ||
entry: | ||
%elt.trunc = call double @llvm.trunc.f64(double %a) | ||
ret double %elt.trunc | ||
} |