Skip to content

Commit 8eb5829

Browse files
committed
address pr comments remove tan expand cases as redundant in x86 backend for f32\f64 cases
1 parent a55e3e6 commit 8eb5829

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ enum NodeType {
415415
STRICT_FLDEXP,
416416
STRICT_FSIN,
417417
STRICT_FCOS,
418+
STRICT_FTAN,
418419
STRICT_FEXP,
419420
STRICT_FEXP2,
420421
STRICT_FLOG,
@@ -934,6 +935,7 @@ enum NodeType {
934935
FCBRT,
935936
FSIN,
936937
FCOS,
938+
FTAN,
937939
FPOW,
938940
FPOWI,
939941
/// FLDEXP - ldexp, inspired by libm (op0 * 2**op1).

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
654654
// non-optsize case.
655655
setLoadExtAction(ISD::EXTLOAD, MVT::f64, MVT::f32, Expand);
656656

657-
// clang-format off
658657
for (auto VT : { MVT::f32, MVT::f64 }) {
659658
// Use ANDPD to simulate FABS.
660659
setOperationAction(ISD::FABS, VT, Custom);
@@ -673,9 +672,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
673672
setOperationAction(ISD::FSIN , VT, Expand);
674673
setOperationAction(ISD::FCOS , VT, Expand);
675674
setOperationAction(ISD::FSINCOS, VT, Expand);
676-
setOperationAction(ISD::FTAN , VT, Expand);
677675
}
678-
// clang-format on
679676

680677
// Half type will be promoted by default.
681678
setF16Action(MVT::f16, Promote);
@@ -747,19 +744,15 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
747744
setOperationAction(ISD::FCOPYSIGN, MVT::f32, Custom);
748745

749746
// We don't support sin/cos/fmod
750-
// clang-format off
751747
setOperationAction(ISD::FSIN , MVT::f32, Expand);
752748
setOperationAction(ISD::FCOS , MVT::f32, Expand);
753749
setOperationAction(ISD::FSINCOS, MVT::f32, Expand);
754-
setOperationAction(ISD::FTAN , MVT::f32, Expand);
755-
// clang-format on
756750

757751
if (UseX87) {
758752
// Always expand sin/cos functions even though x87 has an instruction.
759753
setOperationAction(ISD::FSIN, MVT::f64, Expand);
760754
setOperationAction(ISD::FCOS, MVT::f64, Expand);
761755
setOperationAction(ISD::FSINCOS, MVT::f64, Expand);
762-
setOperationAction(ISD::FTAN, MVT::f64, Expand);
763756
}
764757
} else if (UseX87) {
765758
// f32 and f64 in x87.
@@ -775,7 +768,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
775768
setOperationAction(ISD::FSIN , VT, Expand);
776769
setOperationAction(ISD::FCOS , VT, Expand);
777770
setOperationAction(ISD::FSINCOS, VT, Expand);
778-
setOperationAction(ISD::FTAN, VT, Expand);
779771
}
780772
}
781773

@@ -842,10 +834,12 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
842834
}
843835

844836
// Always expand sin/cos functions even though x87 has an instruction.
837+
// clang-format off
845838
setOperationAction(ISD::FSIN , MVT::f80, Expand);
846839
setOperationAction(ISD::FCOS , MVT::f80, Expand);
847840
setOperationAction(ISD::FSINCOS, MVT::f80, Expand);
848-
setOperationAction(ISD::FTAN, MVT::f80, Expand);
841+
setOperationAction(ISD::FTAN , MVT::f80, Expand);
842+
// clang-format on
849843

850844
setOperationAction(ISD::FFLOOR, MVT::f80, Expand);
851845
setOperationAction(ISD::FCEIL, MVT::f80, Expand);
@@ -898,13 +892,15 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
898892
setOperationAction(ISD::FNEG, MVT::f128, Custom);
899893
setOperationAction(ISD::FCOPYSIGN, MVT::f128, Custom);
900894

895+
// clang-format off
901896
setOperationAction(ISD::FSIN, MVT::f128, LibCall);
902897
setOperationAction(ISD::STRICT_FSIN, MVT::f128, LibCall);
903898
setOperationAction(ISD::FCOS, MVT::f128, LibCall);
904899
setOperationAction(ISD::STRICT_FCOS, MVT::f128, LibCall);
905900
setOperationAction(ISD::FSINCOS, MVT::f128, LibCall);
906-
setOperationAction(ISD::FTAN, MVT::f128, LibCall);
907-
setOperationAction(ISD::STRICT_FTAN, MVT::f128, LibCall);
901+
setOperationAction(ISD::FTAN, MVT::f128, LibCall);
902+
setOperationAction(ISD::STRICT_FTAN, MVT::f128, LibCall);
903+
// clang-format on
908904
// No STRICT_FSINCOS
909905
setOperationAction(ISD::FSQRT, MVT::f128, LibCall);
910906
setOperationAction(ISD::STRICT_FSQRT, MVT::f128, LibCall);
@@ -956,10 +952,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
956952
for (auto VT : { MVT::v8f16, MVT::v16f16, MVT::v32f16,
957953
MVT::v4f32, MVT::v8f32, MVT::v16f32,
958954
MVT::v2f64, MVT::v4f64, MVT::v8f64 }) {
955+
// clang-format off
959956
setOperationAction(ISD::FSIN, VT, Expand);
960957
setOperationAction(ISD::FSINCOS, VT, Expand);
961958
setOperationAction(ISD::FCOS, VT, Expand);
962-
setOperationAction(ISD::FTAN, VT, Expand);
959+
setOperationAction(ISD::FTAN, VT, Expand);
963960
setOperationAction(ISD::FREM, VT, Expand);
964961
setOperationAction(ISD::FCOPYSIGN, VT, Expand);
965962
setOperationAction(ISD::FPOW, VT, Expand);
@@ -969,6 +966,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
969966
setOperationAction(ISD::FEXP, VT, Expand);
970967
setOperationAction(ISD::FEXP2, VT, Expand);
971968
setOperationAction(ISD::FEXP10, VT, Expand);
969+
// clang-format on
972970
}
973971

974972
// First set operation action for all vector types to either promote
@@ -2486,14 +2484,21 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
24862484
// function casting to f64 and calling `fmod`.
24872485
if (Subtarget.is32Bit() &&
24882486
(Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()))
2489-
for (ISD::NodeType Op :
2490-
{ISD::FCEIL, ISD::STRICT_FCEIL, ISD::FCOS, ISD::STRICT_FCOS,
2491-
ISD::FEXP, ISD::STRICT_FEXP, ISD::FFLOOR, ISD::STRICT_FFLOOR,
2492-
ISD::FREM, ISD::STRICT_FREM, ISD::FLOG, ISD::STRICT_FLOG,
2493-
ISD::FLOG10, ISD::STRICT_FLOG10, ISD::FPOW, ISD::STRICT_FPOW,
2494-
ISD::FSIN, ISD::STRICT_FSIN, ISD::FTAN, ISD::STRICT_FTAN})
2487+
// clang-format off
2488+
for (ISD::NodeType Op :
2489+
{ISD::FCEIL, ISD::STRICT_FCEIL,
2490+
ISD::FCOS, ISD::STRICT_FCOS,
2491+
ISD::FEXP, ISD::STRICT_FEXP,
2492+
ISD::FFLOOR, ISD::STRICT_FFLOOR,
2493+
ISD::FREM, ISD::STRICT_FREM,
2494+
ISD::FLOG, ISD::STRICT_FLOG,
2495+
ISD::FLOG10, ISD::STRICT_FLOG10,
2496+
ISD::FPOW, ISD::STRICT_FPOW,
2497+
ISD::FSIN, ISD::STRICT_FSIN,
2498+
ISD::FTAN, ISD::STRICT_FTAN})
24952499
if (isOperationExpand(Op, MVT::f32))
24962500
setOperationAction(Op, MVT::f32, Promote);
2501+
// clang-format on
24972502

24982503
// We have target-specific dag combine patterns for the following nodes:
24992504
setTargetDAGCombine({ISD::VECTOR_SHUFFLE,

0 commit comments

Comments
 (0)