[llvm] [DXIL] Implement pow lowering (PR #86733)
Damyan Pepper via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 09:30:25 PDT 2024
================
@@ -197,6 +198,26 @@ static bool expandLog10Intrinsic(CallInst *Orig) {
return expandLogIntrinsic(Orig, numbers::ln2f / numbers::ln10f);
}
+static bool expandPowIntrinsic(CallInst *Orig) {
+
+ Value *X = Orig->getOperand(0);
+ Value *Y = Orig->getOperand(1);
+ Type *Ty = X->getType();
+ IRBuilder<> Builder(Orig->getParent());
+ Builder.SetInsertPoint(Orig);
+
+ auto *Log2Call =
+ Builder.CreateIntrinsic(Ty, Intrinsic::log2, {X}, nullptr, "elt.log2");
+ auto *Mul = Builder.CreateFMul(Log2Call, Y);
+ auto *Exp2Call =
+ Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {Mul}, nullptr, "elt.exp2");
+ Exp2Call->setTailCall(Orig->isTailCall());
+ Exp2Call->setAttributes(Orig->getAttributes());
----------------
damyanp wrote:
I don't know...it's the sort of thing that looks like it's important and worth doing, but what do I know?! If you can't think of a way to write a test that observes whether or not these have been copied properly then maybe it shouldn't be there. Maybe this is something we should deal with in a follow-up issue, since it sounds like it is more widespread than just the code touched in this PR.
https://github.com/llvm/llvm-project/pull/86733
More information about the llvm-commits
mailing list