Skip to content

Commit 41f3483

Browse files
authored
Revert "[DirectX] Add atan2 intrinsic and expand for DXIL backend (p1) (#108865)"
This reverts commit 26029d7.
1 parent 12285cc commit 41f3483

File tree

5 files changed

+0
-188
lines changed

5 files changed

+0
-188
lines changed

llvm/docs/LangRef.rst

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15583,43 +15583,6 @@ trapping or setting ``errno``.
1558315583
When specified with the fast-math-flag 'afn', the result may be approximated
1558415584
using a less accurate calculation.
1558515585

15586-
'``llvm.atan2.*``' Intrinsic
15587-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
15588-
15589-
Syntax:
15590-
"""""""
15591-
15592-
This is an overloaded intrinsic. You can use ``llvm.atan2`` on any
15593-
floating-point or vector of floating-point type. Not all targets support
15594-
all types however.
15595-
15596-
::
15597-
15598-
declare float @llvm.atan2.f32(float %X, float %Y)
15599-
declare double @llvm.atan2.f64(double %X, double %Y)
15600-
declare x86_fp80 @llvm.atan2.f80(x86_fp80 %X, x86_fp80 %Y)
15601-
declare fp128 @llvm.atan2.f128(fp128 %X, fp128 %Y)
15602-
declare ppc_fp128 @llvm.atan2.ppcf128(ppc_fp128 %X, ppc_fp128 %Y)
15603-
15604-
Overview:
15605-
"""""""""
15606-
15607-
The '``llvm.atan2.*``' intrinsics return the arctangent of the operand.
15608-
15609-
Arguments:
15610-
""""""""""
15611-
15612-
The arguments and return value are floating-point numbers of the same type.
15613-
15614-
Semantics:
15615-
""""""""""
15616-
15617-
Return the same value as a corresponding libm '``atan2``' function but without
15618-
trapping or setting ``errno``.
15619-
15620-
When specified with the fast-math-flag 'afn', the result may be approximated
15621-
using a less accurate calculation.
15622-
1562315586
'``llvm.sinh.*``' Intrinsic
1562415587
^^^^^^^^^^^^^^^^^^^^^^^^^^^
1562515588

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
10161016
def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10171017
def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10181018
def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1019-
def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
10201019
def int_sin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10211020
def int_cos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
10221021
def int_tan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;

llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ using namespace llvm;
3636
static bool isIntrinsicExpansion(Function &F) {
3737
switch (F.getIntrinsicID()) {
3838
case Intrinsic::abs:
39-
case Intrinsic::atan2:
4039
case Intrinsic::exp:
4140
case Intrinsic::log:
4241
case Intrinsic::log10:
@@ -308,54 +307,6 @@ static Value *expandNormalizeIntrinsic(CallInst *Orig) {
308307
return Builder.CreateFMul(X, MultiplicandVec);
309308
}
310309

311-
static Value *expandAtan2Intrinsic(CallInst *Orig) {
312-
Value *Y = Orig->getOperand(0);
313-
Value *X = Orig->getOperand(1);
314-
Type *Ty = X->getType();
315-
IRBuilder<> Builder(Orig);
316-
Builder.setFastMathFlags(Orig->getFastMathFlags());
317-
318-
Value *Tan = Builder.CreateFDiv(Y, X);
319-
320-
CallInst *Atan =
321-
Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan}, nullptr, "Elt.Atan");
322-
Atan->setTailCall(Orig->isTailCall());
323-
Atan->setAttributes(Orig->getAttributes());
324-
325-
// Modify atan result based on https://en.wikipedia.org/wiki/Atan2.
326-
Constant *Pi = ConstantFP::get(Ty, llvm::numbers::pi);
327-
Constant *HalfPi = ConstantFP::get(Ty, llvm::numbers::pi / 2);
328-
Constant *NegHalfPi = ConstantFP::get(Ty, -llvm::numbers::pi / 2);
329-
Constant *Zero = ConstantFP::get(Ty, 0);
330-
Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
331-
Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
332-
333-
// x > 0 -> atan.
334-
Value *Result = Atan;
335-
Value *XLt0 = Builder.CreateFCmpOLT(X, Zero);
336-
Value *XEq0 = Builder.CreateFCmpOEQ(X, Zero);
337-
Value *YGe0 = Builder.CreateFCmpOGE(Y, Zero);
338-
Value *YLt0 = Builder.CreateFCmpOLT(Y, Zero);
339-
340-
// x < 0, y >= 0 -> atan + pi.
341-
Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
342-
Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
343-
344-
// x < 0, y < 0 -> atan - pi.
345-
Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
346-
Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
347-
348-
// x == 0, y < 0 -> -pi/2
349-
Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
350-
Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
351-
352-
// x == 0, y > 0 -> pi/2
353-
Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
354-
Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
355-
356-
return Result;
357-
}
358-
359310
static Value *expandPowIntrinsic(CallInst *Orig) {
360311

361312
Value *X = Orig->getOperand(0);
@@ -467,9 +418,6 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
467418
case Intrinsic::abs:
468419
Result = expandAbs(Orig);
469420
break;
470-
case Intrinsic::atan2:
471-
Result = expandAtan2Intrinsic(Orig);
472-
break;
473421
case Intrinsic::exp:
474422
Result = expandExpIntrinsic(Orig);
475423
break;

llvm/test/CodeGen/DirectX/atan2.ll

Lines changed: 0 additions & 87 deletions
This file was deleted.

llvm/test/CodeGen/DirectX/atan2_error.ll

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)