Skip to content

Commit 68a1583

Browse files
[TLI] replace-with-veclib works with FRem Instruction. (llvm#76166)
Updated SLEEF and ArmPL tests with Fixed-Width and Scalable cases for frem. Those are mapped to fmod/fmodf.
1 parent 1c67466 commit 68a1583

File tree

4 files changed

+169
-73
lines changed

4 files changed

+169
-73
lines changed

llvm/lib/CodeGen/ReplaceWithVeclib.cpp

Lines changed: 90 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// Replaces calls to LLVM vector intrinsics (i.e., calls to LLVM intrinsics
10-
// with vector operands) with matching calls to functions from a vector
11-
// library (e.g., libmvec, SVML) according to TargetLibraryInfo.
9+
// Replaces LLVM IR instructions with vector operands (i.e., the frem
10+
// instruction or calls to LLVM intrinsics) with matching calls to functions
11+
// from a vector library (e.g libmvec, SVML) using TargetLibraryInfo interface.
1212
//
1313
//===----------------------------------------------------------------------===//
1414

@@ -69,88 +69,98 @@ Function *getTLIFunction(Module *M, FunctionType *VectorFTy,
6969
return TLIFunc;
7070
}
7171

72-
/// Replace the call to the vector intrinsic ( \p CalltoReplace ) with a call to
73-
/// the corresponding function from the vector library ( \p TLIVecFunc ).
74-
static void replaceWithTLIFunction(CallInst &CalltoReplace, VFInfo &Info,
72+
/// Replace the instruction \p I with a call to the corresponding function from
73+
/// the vector library (\p TLIVecFunc).
74+
static void replaceWithTLIFunction(Instruction &I, VFInfo &Info,
7575
Function *TLIVecFunc) {
76-
IRBuilder<> IRBuilder(&CalltoReplace);
77-
SmallVector<Value *> Args(CalltoReplace.args());
76+
IRBuilder<> IRBuilder(&I);
77+
auto *CI = dyn_cast<CallInst>(&I);
78+
SmallVector<Value *> Args(CI ? CI->args() : I.operands());
7879
if (auto OptMaskpos = Info.getParamIndexForOptionalMask()) {
79-
auto *MaskTy = VectorType::get(Type::getInt1Ty(CalltoReplace.getContext()),
80-
Info.Shape.VF);
80+
auto *MaskTy =
81+
VectorType::get(Type::getInt1Ty(I.getContext()), Info.Shape.VF);
8182
Args.insert(Args.begin() + OptMaskpos.value(),
8283
Constant::getAllOnesValue(MaskTy));
8384
}
8485

85-
// Preserve the operand bundles.
86+
// If it is a call instruction, preserve the operand bundles.
8687
SmallVector<OperandBundleDef, 1> OpBundles;
87-
CalltoReplace.getOperandBundlesAsDefs(OpBundles);
88-
CallInst *Replacement = IRBuilder.CreateCall(TLIVecFunc, Args, OpBundles);
89-
CalltoReplace.replaceAllUsesWith(Replacement);
88+
if (CI)
89+
CI->getOperandBundlesAsDefs(OpBundles);
90+
91+
auto *Replacement = IRBuilder.CreateCall(TLIVecFunc, Args, OpBundles);
92+
I.replaceAllUsesWith(Replacement);
9093
// Preserve fast math flags for FP math.
9194
if (isa<FPMathOperator>(Replacement))
92-
Replacement->copyFastMathFlags(&CalltoReplace);
95+
Replacement->copyFastMathFlags(&I);
9396
}
9497

95-
/// Returns true when successfully replaced \p CallToReplace with a suitable
96-
/// function taking vector arguments, based on available mappings in the \p TLI.
97-
/// Currently only works when \p CallToReplace is a call to vectorized
98-
/// intrinsic.
98+
/// Returns true when successfully replaced \p I with a suitable function taking
99+
/// vector arguments, based on available mappings in the \p TLI. Currently only
100+
/// works when \p I is a call to vectorized intrinsic or the frem instruction.
99101
static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
100-
CallInst &CallToReplace) {
101-
if (!CallToReplace.getCalledFunction())
102-
return false;
102+
Instruction &I) {
103+
// At the moment VFABI assumes the return type is always widened unless it is
104+
// a void type.
105+
auto *VTy = dyn_cast<VectorType>(I.getType());
106+
ElementCount EC(VTy ? VTy->getElementCount() : ElementCount::getFixed(0));
103107

104-
auto IntrinsicID = CallToReplace.getCalledFunction()->getIntrinsicID();
105-
// Replacement is only performed for intrinsic functions.
106-
if (IntrinsicID == Intrinsic::not_intrinsic)
107-
return false;
108-
109-
// Compute arguments types of the corresponding scalar call. Additionally
110-
// checks if in the vector call, all vector operands have the same EC.
111-
ElementCount VF = ElementCount::getFixed(0);
112-
SmallVector<Type *> ScalarArgTypes;
113-
for (auto Arg : enumerate(CallToReplace.args())) {
114-
auto *ArgTy = Arg.value()->getType();
115-
if (isVectorIntrinsicWithScalarOpAtArg(IntrinsicID, Arg.index())) {
116-
ScalarArgTypes.push_back(ArgTy);
117-
} else if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
118-
ScalarArgTypes.push_back(ArgTy->getScalarType());
119-
// Disallow vector arguments with different VFs. When processing the first
120-
// vector argument, store it's VF, and for the rest ensure that they match
121-
// it.
122-
if (VF.isZero())
123-
VF = VectorArgTy->getElementCount();
124-
else if (VF != VectorArgTy->getElementCount())
108+
// Compute the argument types of the corresponding scalar call and the scalar
109+
// function name. For calls, it additionally finds the function to replace
110+
// and checks that all vector operands match the previously found EC.
111+
SmallVector<Type *, 8> ScalarArgTypes;
112+
std::string ScalarName;
113+
Function *FuncToReplace = nullptr;
114+
if (auto *CI = dyn_cast<CallInst>(&I)) {
115+
FuncToReplace = CI->getCalledFunction();
116+
Intrinsic::ID IID = FuncToReplace->getIntrinsicID();
117+
assert(IID != Intrinsic::not_intrinsic && "Not an intrinsic");
118+
for (auto Arg : enumerate(CI->args())) {
119+
auto *ArgTy = Arg.value()->getType();
120+
if (isVectorIntrinsicWithScalarOpAtArg(IID, Arg.index())) {
121+
ScalarArgTypes.push_back(ArgTy);
122+
} else if (auto *VectorArgTy = dyn_cast<VectorType>(ArgTy)) {
123+
ScalarArgTypes.push_back(VectorArgTy->getElementType());
124+
// When return type is void, set EC to the first vector argument, and
125+
// disallow vector arguments with different ECs.
126+
if (EC.isZero())
127+
EC = VectorArgTy->getElementCount();
128+
else if (EC != VectorArgTy->getElementCount())
129+
return false;
130+
} else
131+
// Exit when it is supposed to be a vector argument but it isn't.
125132
return false;
126-
} else
127-
// Exit when it is supposed to be a vector argument but it isn't.
133+
}
134+
// Try to reconstruct the name for the scalar version of the instruction,
135+
// using scalar argument types.
136+
ScalarName = Intrinsic::isOverloaded(IID)
137+
? Intrinsic::getName(IID, ScalarArgTypes, I.getModule())
138+
: Intrinsic::getName(IID).str();
139+
} else {
140+
assert(VTy && "Return type must be a vector");
141+
auto *ScalarTy = VTy->getScalarType();
142+
LibFunc Func;
143+
if (!TLI.getLibFunc(I.getOpcode(), ScalarTy, Func))
128144
return false;
145+
ScalarName = TLI.getName(Func);
146+
ScalarArgTypes = {ScalarTy, ScalarTy};
129147
}
130148

131-
// Try to reconstruct the name for the scalar version of this intrinsic using
132-
// the intrinsic ID and the argument types converted to scalar above.
133-
std::string ScalarName =
134-
(Intrinsic::isOverloaded(IntrinsicID)
135-
? Intrinsic::getName(IntrinsicID, ScalarArgTypes,
136-
CallToReplace.getModule())
137-
: Intrinsic::getName(IntrinsicID).str());
138-
139149
// Try to find the mapping for the scalar version of this intrinsic and the
140150
// exact vector width of the call operands in the TargetLibraryInfo. First,
141151
// check with a non-masked variant, and if that fails try with a masked one.
142152
const VecDesc *VD =
143-
TLI.getVectorMappingInfo(ScalarName, VF, /*Masked*/ false);
144-
if (!VD && !(VD = TLI.getVectorMappingInfo(ScalarName, VF, /*Masked*/ true)))
153+
TLI.getVectorMappingInfo(ScalarName, EC, /*Masked*/ false);
154+
if (!VD && !(VD = TLI.getVectorMappingInfo(ScalarName, EC, /*Masked*/ true)))
145155
return false;
146156

147157
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Found TLI mapping from: `" << ScalarName
148-
<< "` and vector width " << VF << " to: `"
158+
<< "` and vector width " << EC << " to: `"
149159
<< VD->getVectorFnName() << "`.\n");
150160

151161
// Replace the call to the intrinsic with a call to the vector library
152162
// function.
153-
Type *ScalarRetTy = CallToReplace.getType()->getScalarType();
163+
Type *ScalarRetTy = I.getType()->getScalarType();
154164
FunctionType *ScalarFTy =
155165
FunctionType::get(ScalarRetTy, ScalarArgTypes, /*isVarArg*/ false);
156166
const std::string MangledName = VD->getVectorFunctionABIVariantString();
@@ -162,27 +172,37 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
162172
if (!VectorFTy)
163173
return false;
164174

165-
Function *FuncToReplace = CallToReplace.getCalledFunction();
166-
Function *TLIFunc = getTLIFunction(CallToReplace.getModule(), VectorFTy,
175+
Function *TLIFunc = getTLIFunction(I.getModule(), VectorFTy,
167176
VD->getVectorFnName(), FuncToReplace);
168-
replaceWithTLIFunction(CallToReplace, *OptInfo, TLIFunc);
169-
170-
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Replaced call to `"
171-
<< FuncToReplace->getName() << "` with call to `"
172-
<< TLIFunc->getName() << "`.\n");
177+
replaceWithTLIFunction(I, *OptInfo, TLIFunc);
178+
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Replaced call to `" << ScalarName
179+
<< "` with call to `" << TLIFunc->getName() << "`.\n");
173180
++NumCallsReplaced;
174181
return true;
175182
}
176183

184+
/// Supported instruction \p I must be a vectorized frem or a call to an
185+
/// intrinsic that returns either void or a vector.
186+
static bool isSupportedInstruction(Instruction *I) {
187+
Type *Ty = I->getType();
188+
if (auto *CI = dyn_cast<CallInst>(I))
189+
return (Ty->isVectorTy() || Ty->isVoidTy()) && CI->getCalledFunction() &&
190+
CI->getCalledFunction()->getIntrinsicID() !=
191+
Intrinsic::not_intrinsic;
192+
if (I->getOpcode() == Instruction::FRem && Ty->isVectorTy())
193+
return true;
194+
return false;
195+
}
196+
177197
static bool runImpl(const TargetLibraryInfo &TLI, Function &F) {
178198
bool Changed = false;
179-
SmallVector<CallInst *> ReplacedCalls;
199+
SmallVector<Instruction *> ReplacedCalls;
180200
for (auto &I : instructions(F)) {
181-
if (auto *CI = dyn_cast<CallInst>(&I)) {
182-
if (replaceWithCallToVeclib(TLI, *CI)) {
183-
ReplacedCalls.push_back(CI);
184-
Changed = true;
185-
}
201+
if (!isSupportedInstruction(&I))
202+
continue;
203+
if (replaceWithCallToVeclib(TLI, I)) {
204+
ReplacedCalls.push_back(&I);
205+
Changed = true;
186206
}
187207
}
188208
// Erase the calls to the intrinsics that have been replaced

llvm/test/CodeGen/AArch64/replace-intrinsics-with-veclib-armpl.ll renamed to llvm/test/CodeGen/AArch64/replace-with-veclib-armpl.ll

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare <vscale x 2 x double> @llvm.cos.nxv2f64(<vscale x 2 x double>)
1515
declare <vscale x 4 x float> @llvm.cos.nxv4f32(<vscale x 4 x float>)
1616

1717
;.
18-
; CHECK: @llvm.compiler.used = appending global [32 x ptr] [ptr @armpl_vcosq_f64, ptr @armpl_vcosq_f32, ptr @armpl_svcos_f64_x, ptr @armpl_svcos_f32_x, ptr @armpl_vsinq_f64, ptr @armpl_vsinq_f32, ptr @armpl_svsin_f64_x, ptr @armpl_svsin_f32_x, ptr @armpl_vexpq_f64, ptr @armpl_vexpq_f32, ptr @armpl_svexp_f64_x, ptr @armpl_svexp_f32_x, ptr @armpl_vexp2q_f64, ptr @armpl_vexp2q_f32, ptr @armpl_svexp2_f64_x, ptr @armpl_svexp2_f32_x, ptr @armpl_vexp10q_f64, ptr @armpl_vexp10q_f32, ptr @armpl_svexp10_f64_x, ptr @armpl_svexp10_f32_x, ptr @armpl_vlogq_f64, ptr @armpl_vlogq_f32, ptr @armpl_svlog_f64_x, ptr @armpl_svlog_f32_x, ptr @armpl_vlog2q_f64, ptr @armpl_vlog2q_f32, ptr @armpl_svlog2_f64_x, ptr @armpl_svlog2_f32_x, ptr @armpl_vlog10q_f64, ptr @armpl_vlog10q_f32, ptr @armpl_svlog10_f64_x, ptr @armpl_svlog10_f32_x], section "llvm.metadata"
18+
; CHECK: @llvm.compiler.used = appending global [36 x ptr] [ptr @armpl_vcosq_f64, ptr @armpl_vcosq_f32, ptr @armpl_svcos_f64_x, ptr @armpl_svcos_f32_x, ptr @armpl_vsinq_f64, ptr @armpl_vsinq_f32, ptr @armpl_svsin_f64_x, ptr @armpl_svsin_f32_x, ptr @armpl_vexpq_f64, ptr @armpl_vexpq_f32, ptr @armpl_svexp_f64_x, ptr @armpl_svexp_f32_x, ptr @armpl_vexp2q_f64, ptr @armpl_vexp2q_f32, ptr @armpl_svexp2_f64_x, ptr @armpl_svexp2_f32_x, ptr @armpl_vexp10q_f64, ptr @armpl_vexp10q_f32, ptr @armpl_svexp10_f64_x, ptr @armpl_svexp10_f32_x, ptr @armpl_vlogq_f64, ptr @armpl_vlogq_f32, ptr @armpl_svlog_f64_x, ptr @armpl_svlog_f32_x, ptr @armpl_vlog2q_f64, ptr @armpl_vlog2q_f32, ptr @armpl_svlog2_f64_x, ptr @armpl_svlog2_f32_x, ptr @armpl_vlog10q_f64, ptr @armpl_vlog10q_f32, ptr @armpl_svlog10_f64_x, ptr @armpl_svlog10_f32_x, ptr @armpl_vfmodq_f64, ptr @armpl_vfmodq_f32, ptr @armpl_svfmod_f64_x, ptr @armpl_svfmod_f32_x], section "llvm.metadata"
1919
;.
2020
define <2 x double> @llvm_cos_f64(<2 x double> %in) {
2121
; CHECK-LABEL: define <2 x double> @llvm_cos_f64
@@ -424,6 +424,46 @@ define <vscale x 4 x float> @llvm_pow_vscale_f32(<vscale x 4 x float> %in, <vsca
424424
ret <vscale x 4 x float> %1
425425
}
426426

427+
define <2 x double> @frem_f64(<2 x double> %in) {
428+
; CHECK-LABEL: define <2 x double> @frem_f64
429+
; CHECK-SAME: (<2 x double> [[IN:%.*]]) {
430+
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x double> @armpl_vfmodq_f64(<2 x double> [[IN]], <2 x double> [[IN]])
431+
; CHECK-NEXT: ret <2 x double> [[TMP1]]
432+
;
433+
%1= frem <2 x double> %in, %in
434+
ret <2 x double> %1
435+
}
436+
437+
define <4 x float> @frem_f32(<4 x float> %in) {
438+
; CHECK-LABEL: define <4 x float> @frem_f32
439+
; CHECK-SAME: (<4 x float> [[IN:%.*]]) {
440+
; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @armpl_vfmodq_f32(<4 x float> [[IN]], <4 x float> [[IN]])
441+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
442+
;
443+
%1= frem <4 x float> %in, %in
444+
ret <4 x float> %1
445+
}
446+
447+
define <vscale x 2 x double> @frem_vscale_f64(<vscale x 2 x double> %in) #0 {
448+
; CHECK-LABEL: define <vscale x 2 x double> @frem_vscale_f64
449+
; CHECK-SAME: (<vscale x 2 x double> [[IN:%.*]]) #[[ATTR1]] {
450+
; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 2 x double> @armpl_svfmod_f64_x(<vscale x 2 x double> [[IN]], <vscale x 2 x double> [[IN]], <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer))
451+
; CHECK-NEXT: ret <vscale x 2 x double> [[TMP1]]
452+
;
453+
%1= frem <vscale x 2 x double> %in, %in
454+
ret <vscale x 2 x double> %1
455+
}
456+
457+
define <vscale x 4 x float> @frem_vscale_f32(<vscale x 4 x float> %in) #0 {
458+
; CHECK-LABEL: define <vscale x 4 x float> @frem_vscale_f32
459+
; CHECK-SAME: (<vscale x 4 x float> [[IN:%.*]]) #[[ATTR1]] {
460+
; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x float> @armpl_svfmod_f32_x(<vscale x 4 x float> [[IN]], <vscale x 4 x float> [[IN]], <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer))
461+
; CHECK-NEXT: ret <vscale x 4 x float> [[TMP1]]
462+
;
463+
%1= frem <vscale x 4 x float> %in, %in
464+
ret <vscale x 4 x float> %1
465+
}
466+
427467
attributes #0 = { "target-features"="+sve" }
428468
;.
429469
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

llvm/test/CodeGen/AArch64/replace-intrinsics-with-veclib-sleef-scalable.ll renamed to llvm/test/CodeGen/AArch64/replace-with-veclib-sleef-scalable.ll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
target triple = "aarch64-unknown-linux-gnu"
55

66
;.
7-
; CHECK: @llvm.compiler.used = appending global [16 x ptr] [ptr @_ZGVsMxv_cos, ptr @_ZGVsMxv_cosf, ptr @_ZGVsMxv_exp, ptr @_ZGVsMxv_expf, ptr @_ZGVsMxv_exp2, ptr @_ZGVsMxv_exp2f, ptr @_ZGVsMxv_exp10, ptr @_ZGVsMxv_exp10f, ptr @_ZGVsMxv_log, ptr @_ZGVsMxv_logf, ptr @_ZGVsMxv_log10, ptr @_ZGVsMxv_log10f, ptr @_ZGVsMxv_log2, ptr @_ZGVsMxv_log2f, ptr @_ZGVsMxv_sin, ptr @_ZGVsMxv_sinf], section "llvm.metadata"
7+
; CHECK: @llvm.compiler.used = appending global [18 x ptr] [ptr @_ZGVsMxv_cos, ptr @_ZGVsMxv_cosf, ptr @_ZGVsMxv_exp, ptr @_ZGVsMxv_expf, ptr @_ZGVsMxv_exp2, ptr @_ZGVsMxv_exp2f, ptr @_ZGVsMxv_exp10, ptr @_ZGVsMxv_exp10f, ptr @_ZGVsMxv_log, ptr @_ZGVsMxv_logf, ptr @_ZGVsMxv_log10, ptr @_ZGVsMxv_log10f, ptr @_ZGVsMxv_log2, ptr @_ZGVsMxv_log2f, ptr @_ZGVsMxv_sin, ptr @_ZGVsMxv_sinf, ptr @_ZGVsMxvv_fmod, ptr @_ZGVsMxvv_fmodf], section "llvm.metadata"
88
;.
99
define <vscale x 2 x double> @llvm_ceil_vscale_f64(<vscale x 2 x double> %in) {
1010
; CHECK-LABEL: @llvm_ceil_vscale_f64(
@@ -384,6 +384,24 @@ define <vscale x 4 x float> @llvm_trunc_vscale_f32(<vscale x 4 x float> %in) {
384384
ret <vscale x 4 x float> %1
385385
}
386386

387+
define <vscale x 2 x double> @frem_f64(<vscale x 2 x double> %in) {
388+
; CHECK-LABEL: @frem_f64(
389+
; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 2 x double> @_ZGVsMxvv_fmod(<vscale x 2 x double> [[IN:%.*]], <vscale x 2 x double> [[IN]], <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> poison, i1 true, i64 0), <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer))
390+
; CHECK-NEXT: ret <vscale x 2 x double> [[TMP1]]
391+
;
392+
%1= frem <vscale x 2 x double> %in, %in
393+
ret <vscale x 2 x double> %1
394+
}
395+
396+
define <vscale x 4 x float> @frem_f32(<vscale x 4 x float> %in) {
397+
; CHECK-LABEL: @frem_f32(
398+
; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 4 x float> @_ZGVsMxvv_fmodf(<vscale x 4 x float> [[IN:%.*]], <vscale x 4 x float> [[IN]], <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> poison, i1 true, i64 0), <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer))
399+
; CHECK-NEXT: ret <vscale x 4 x float> [[TMP1]]
400+
;
401+
%1= frem <vscale x 4 x float> %in, %in
402+
ret <vscale x 4 x float> %1
403+
}
404+
387405
declare <vscale x 2 x double> @llvm.ceil.nxv2f64(<vscale x 2 x double>)
388406
declare <vscale x 4 x float> @llvm.ceil.nxv4f32(<vscale x 4 x float>)
389407
declare <vscale x 2 x double> @llvm.copysign.nxv2f64(<vscale x 2 x double>, <vscale x 2 x double>)

llvm/test/CodeGen/AArch64/replace-intrinsics-with-veclib-sleef.ll renamed to llvm/test/CodeGen/AArch64/replace-with-veclib-sleef.ll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
target triple = "aarch64-unknown-linux-gnu"
55

66
;.
7-
; CHECK: @llvm.compiler.used = appending global [16 x ptr] [ptr @_ZGVnN2v_cos, ptr @_ZGVnN4v_cosf, ptr @_ZGVnN2v_exp, ptr @_ZGVnN4v_expf, ptr @_ZGVnN2v_exp2, ptr @_ZGVnN4v_exp2f, ptr @_ZGVnN2v_exp10, ptr @_ZGVnN4v_exp10f, ptr @_ZGVnN2v_log, ptr @_ZGVnN4v_logf, ptr @_ZGVnN2v_log10, ptr @_ZGVnN4v_log10f, ptr @_ZGVnN2v_log2, ptr @_ZGVnN4v_log2f, ptr @_ZGVnN2v_sin, ptr @_ZGVnN4v_sinf], section "llvm.metadata"
7+
; CHECK: @llvm.compiler.used = appending global [18 x ptr] [ptr @_ZGVnN2v_cos, ptr @_ZGVnN4v_cosf, ptr @_ZGVnN2v_exp, ptr @_ZGVnN4v_expf, ptr @_ZGVnN2v_exp2, ptr @_ZGVnN4v_exp2f, ptr @_ZGVnN2v_exp10, ptr @_ZGVnN4v_exp10f, ptr @_ZGVnN2v_log, ptr @_ZGVnN4v_logf, ptr @_ZGVnN2v_log10, ptr @_ZGVnN4v_log10f, ptr @_ZGVnN2v_log2, ptr @_ZGVnN4v_log2f, ptr @_ZGVnN2v_sin, ptr @_ZGVnN4v_sinf, ptr @_ZGVnN2vv_fmod, ptr @_ZGVnN4vv_fmodf], section "llvm.metadata"
88
;.
99
define <2 x double> @llvm_ceil_f64(<2 x double> %in) {
1010
; CHECK-LABEL: @llvm_ceil_f64(
@@ -384,6 +384,24 @@ define <4 x float> @llvm_trunc_f32(<4 x float> %in) {
384384
ret <4 x float> %1
385385
}
386386

387+
define <2 x double> @frem_f64(<2 x double> %in) {
388+
; CHECK-LABEL: @frem_f64(
389+
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x double> @_ZGVnN2vv_fmod(<2 x double> [[IN:%.*]], <2 x double> [[IN]])
390+
; CHECK-NEXT: ret <2 x double> [[TMP1]]
391+
;
392+
%1= frem <2 x double> %in, %in
393+
ret <2 x double> %1
394+
}
395+
396+
define <4 x float> @frem_f32(<4 x float> %in) {
397+
; CHECK-LABEL: @frem_f32(
398+
; CHECK-NEXT: [[TMP1:%.*]] = call <4 x float> @_ZGVnN4vv_fmodf(<4 x float> [[IN:%.*]], <4 x float> [[IN]])
399+
; CHECK-NEXT: ret <4 x float> [[TMP1]]
400+
;
401+
%1= frem <4 x float> %in, %in
402+
ret <4 x float> %1
403+
}
404+
387405
declare <2 x double> @llvm.ceil.v2f64(<2 x double>)
388406
declare <4 x float> @llvm.ceil.v4f32(<4 x float>)
389407
declare <2 x double> @llvm.copysign.v2f64(<2 x double>, <2 x double>)

0 commit comments

Comments
 (0)