[PATCH] D101209: [PowerPC] Provide fastmath sqrt and div functions in altivec.h
Bardia Mahjour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 28 08:46:40 PDT 2021
bmahjour requested changes to this revision.
bmahjour added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15130
+ Value *Y = EmitScalarExpr(E->getArg(1));
+ auto Ret = Builder.CreateFDiv(X, Y, "recipdiv");
+ Builder.setFastMathFlags(FMF);
----------------
I wonder if we can do better than "fdiv fast"... does the current lowering of "fdiv fast" employ an estimation algorithm via iterative refinement on POWER?
================
Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15134
+ }
+ llvm::Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
+ auto Ret = Builder.CreateCall(F, X);
----------------
This doesn't implement a reciprocal square root, it just performs a square root! At the very least we need a divide instruction following the call to the intrinsic, but I'm not sure if that'll result in the most optimal codegen at the end. Perhaps we need a new builtin?
================
Comment at: clang/test/CodeGen/builtins-ppc-vsx.c:2297
+ // CHECK-LABEL: test_rsqrtd
+ // CHECK: call fast <2 x double> @llvm.sqrt.v2f64
+ // CHECK-LE-LABEL: test_rsqrtd
----------------
See my comment above about the missing reciprocal operation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101209/new/
https://reviews.llvm.org/D101209
More information about the cfe-commits
mailing list