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

[HLSL] Add experimental_constrained_tan intrinsic #91421

Closed
farzonl opened this issue May 8, 2024 · 1 comment · Fixed by #93314 or #94559
Closed

[HLSL] Add experimental_constrained_tan intrinsic #91421

farzonl opened this issue May 8, 2024 · 1 comment · Fixed by #93314 or #94559
Assignees
Labels
clang:codegen HLSL HLSL Language Support

Comments

@farzonl
Copy link
Member

farzonl commented May 8, 2024

We want to do the same thing that cos\sin do in the below examples:

  case Builtin::BI__builtin_cos:
  case Builtin::BI__builtin_cosf:
  case Builtin::BI__builtin_cosf16:
  case Builtin::BI__builtin_cosl:
  case Builtin::BI__builtin_cosf128:
    return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
                                 Intrinsic::cos,
                                 Intrinsic::experimental_constrained_cos));
  
  case Builtin::BI__builtin_sin:
  case Builtin::BI__builtin_sinf:
  case Builtin::BI__builtin_sinf16:
  case Builtin::BI__builtin_sinl:
  case Builtin::BI__builtin_sinf128:
    return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
                                 Intrinsic::sin,
                                 Intrinsic::experimental_constrained_sin));

Originally posted by @farzonl in #90276 (comment)

@farzonl farzonl self-assigned this May 8, 2024
@farzonl farzonl added clang Clang issues not falling into any other category HLSL HLSL Language Support and removed new issue labels May 8, 2024
farzonl added a commit that referenced this issue May 29, 2024
…93314)

In LLVM, the `llvm.experimental.constrained.cos` and
`llvm.experimental.constrained.sin` intrinsics are used for performing
cosine and sine calculations with additional constraints on
floating-point operations. This behavior is expected for all
floating-point math intrinsics. This change adds these constraints for
the `tan` intrinsic.

-  `Builtins.td` - replace TanF128 with F16F128MathTemplate
- `CGBuiltin.cpp` - map existing tan builtins to `tan` and
`constrained_tan` intrinsic
-   `ConstrainedOps.def` map tan and constrained_tan  to an ISDOpcode.
-  `ISDOpcodes.h` - define tan and strict tan  opcodes

resolves  #91421
@EugeneZelenko EugeneZelenko added clang:codegen and removed clang Clang issues not falling into any other category labels May 29, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 29, 2024

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)

We want to do the same thing that cos\sin do in the below examples:
  case Builtin::BI__builtin_cos:
  case Builtin::BI__builtin_cosf:
  case Builtin::BI__builtin_cosf16:
  case Builtin::BI__builtin_cosl:
  case Builtin::BI__builtin_cosf128:
    return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
                                 Intrinsic::cos,
                                 Intrinsic::experimental_constrained_cos));
  
  case Builtin::BI__builtin_sin:
  case Builtin::BI__builtin_sinf:
  case Builtin::BI__builtin_sinf16:
  case Builtin::BI__builtin_sinl:
  case Builtin::BI__builtin_sinf128:
    return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
                                 Intrinsic::sin,
                                 Intrinsic::experimental_constrained_sin));

Originally posted by @farzonl in #90276 (comment)

farzonl added a commit that referenced this issue May 29, 2024
…trinsic (#93314)" (#93721)

This reverts commit b15a0a3.

This should undo PR: #93314
will need to re-open #91421

wait for #90503 to land
@farzonl farzonl reopened this May 29, 2024
farzonl added a commit that referenced this issue Jun 11, 2024
…rinsic (#94559)

Relanding this PR now that
#90503 has merged. with `FTAN`
landing in
[TargetLoweringBase.cpp:L1021](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1020C23-L1021C63
) There is now a llvm tan intrinsic 32\64\128 Expand case for all llvm
backends.

In LLVM, the `llvm.experimental.constrained.cos` and
`llvm.experimental.constrained.sin` intrinsics are used for performing
cosine and sine calculations with additional constraints on
floating-point operations. This behavior is expected for all
floating-point math intrinsics. This change adds these constraints for
the `tan` intrinsic.

-  `Builtins.td` - replace TanF128 with F16F128MathTemplate
- `CGBuiltin.cpp` - map existing tan builtins to `tan` and
`constrained_tan` intrinsic
-   `ConstrainedOps.def` map tan and constrained_tan  to an ISDOpcode.

resolves  #91421

---------

Co-authored-by: Farzon Lotfi <farzon@farzon.com>
Lukacma pushed a commit to Lukacma/llvm-project that referenced this issue Jun 12, 2024
…rinsic (llvm#94559)

Relanding this PR now that
llvm#90503 has merged. with `FTAN`
landing in
[TargetLoweringBase.cpp:L1021](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1020C23-L1021C63
) There is now a llvm tan intrinsic 32\64\128 Expand case for all llvm
backends.

In LLVM, the `llvm.experimental.constrained.cos` and
`llvm.experimental.constrained.sin` intrinsics are used for performing
cosine and sine calculations with additional constraints on
floating-point operations. This behavior is expected for all
floating-point math intrinsics. This change adds these constraints for
the `tan` intrinsic.

-  `Builtins.td` - replace TanF128 with F16F128MathTemplate
- `CGBuiltin.cpp` - map existing tan builtins to `tan` and
`constrained_tan` intrinsic
-   `ConstrainedOps.def` map tan and constrained_tan  to an ISDOpcode.

resolves  llvm#91421

---------

Co-authored-by: Farzon Lotfi <farzon@farzon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen HLSL HLSL Language Support
Projects
Status: No status
3 participants