Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
!isVectorizedStructTy(cast<StructType>(RetTy)))
return std::nullopt;

auto getLibcallName = [&] {
if (LC == RTLIB::SINCOS_F32)
return "sincosf";
if (LC == RTLIB::SINCOS_F64)
return "sincos";
return getTLI()->getLibcallName(LC);
};

// Find associated libcall.
const char *LCName = getTLI()->getLibcallName(LC);
const char *LCName = getLibcallName();
if (!LCName)
return std::nullopt;

Expand Down
14 changes: 13 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2554,7 +2554,19 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
EVT VT = Node->getValueType(0);
unsigned NumResults = Node->getNumValues();

const char *LCName = TLI->getLibcallName(LC);
/* Downstream change: #87 (sincos vectorization)*/
auto getLibcallName = [&] {
if (VT.isVector()) {
if (LC == RTLIB::SINCOS_F32)
return "sincosf";
if (LC == RTLIB::SINCOS_F64)
return "sincos";
}
return TLI->getLibcallName(LC);
};
/* End downstream change: #87 */

const char *LCName = getLibcallName();
if (!LC || !LCName)
return false;

Expand Down
3 changes: 3 additions & 0 deletions llvm/test/CodeGen/AArch64/veclib-llvm.sincos.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter "(bl|ptrue)" --version 5
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
; RUN: llc -mtriple=aarch64-gnu-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL
; Check we expand to a vector library call on aarch64-amazon-linux:
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=sleefgnuabi < %s | FileCheck %s -check-prefix=SLEEF
; RUN: llc -mtriple=aarch64-amazon-linux -mattr=+neon,+sve -vector-library=ArmPL < %s | FileCheck %s -check-prefix=ARMPL

define void @test_sincos_v4f32(<4 x float> %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; SLEEF-LABEL: test_sincos_v4f32:
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/Transforms/LoopVectorize/AArch64/sincos.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|extractvalue|store)" --version 5
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve < %s -S -o - -debug-only=loop-vectorize 2>%t.1 | FileCheck %s --check-prefix=CHECK
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.2 | FileCheck %s --check-prefix=CHECK-ARMPL
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-amazon-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.3 | FileCheck %s --check-prefix=CHECK-ARMPL
; RUN: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
; Check we vectorize the functions with the vector-library on aarch64-amazon-linux:
; RUN: FileCheck --input-file=%t.3 --check-prefix=CHECK-COST-ARMPL %s
; REQUIRES: asserts

; CHECK-COST-LABEL: sincos_f32
Expand Down