-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement the sign
HLSL Function
#70078
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
Closed
9 tasks
Labels
Comments
sign
intrinsicsign
HLSL Function
This was referenced Aug 5, 2024
52 tasks
farzonl
pushed a commit
that referenced
this issue
Sep 5, 2024
farzonl
pushed a commit
that referenced
this issue
Sep 10, 2024
partially fixes #70078 ### Changes - Implemented `sign` clang builtin - Linked `sign` clang builtin with `hlsl_intrinsics.h` - Added sema checks for `sign` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp` - Add codegen for `sign` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp` - Add codegen tests to `clang/test/CodeGenHLSL/builtins/sign.hlsl` - Add sema tests to `clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl` ### Related PRs - #101987 - #101988 ### Discussion - Should there be a `usign` intrinsic that handles the unsigned cases?
farzonl
pushed a commit
that referenced
this issue
Oct 10, 2024
- Add handling for unsigned integers to hlsl_elementwise_sign - Use `select` instead of adding dx and spirv intrinsics for unsigned integers as [discussed previously ](#101988 (comment)) fixes #70078 ### Related PRs - #101987 - #101988 - #101989 cc @farzonl @pow2clk @bob80905 @bogner @llvm-beanz
DanielCChen
pushed a commit
to DanielCChen/llvm-project
that referenced
this issue
Oct 16, 2024
- Add handling for unsigned integers to hlsl_elementwise_sign - Use `select` instead of adding dx and spirv intrinsics for unsigned integers as [discussed previously ](llvm#101988 (comment)) fixes llvm#70078 ### Related PRs - llvm#101987 - llvm#101988 - llvm#101989 cc @farzonl @pow2clk @bob80905 @bogner @llvm-beanz
51 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sign
clang builtin,sign
clang builtin withhlsl_intrinsics.h
sign
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
sign
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/sign.hlsl
clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl
int_spv_sign
intrinsic inIntrinsicsSPIRV.td
sign
lowering and map it toint_spv_sign
inSPIRVInstructionSelector::selectIntrinsic
.llvm/test/CodeGen/SPIRV/hlsl-intrinsics/sign.ll
DirectX
There were no DXIL opcodes found for
sign
.SPIR-V
FSign:
Description:
FSign
Result is 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.
The operand x must be a scalar or vector whose component type is
floating-point.
Result Type and the type of x must be the same type. Results are
computed per component.
6
<id>
x
Test Case(s)
Example 1
Example 2
Example 3
HLSL:
Returns the sign of x.
Parameters
Return Value
Returns -1 if x is less than zero; 0 if x equals zero; and 1 if x is greater than zero.
Type Description
Minimum Shader Model
This function is supported in the following shader models.
See also
Intrinsic Functions (DirectX HLSL)
The text was updated successfully, but these errors were encountered: