The operation computes pow(b, p), where 'b' and 'p' are signed integers
of the same width. The result's type matches the operands' type.
Details
Diff Detail
Event Timeline
Would math.powi or math.powsi be a better name? Is it OK to move the folder and strength reduction to dependent patches?
Thank you for looking into this!
There is D129811, where I try to add FPowSI, so I want to distinguish power operations with integer and floating bases. They are somewhat different in behavior, e.g. FPowSI may have some floating point specific effects (like using rounding mode, trapping FP exceptions), whereas IPowSI does not have any FP-related effects.
Sure, I can split it into three patches: basic, folder and strength reduction. Please let me know if you have major concerns about this patch and D129811. If you do not have any, I will proceed with the splitting.
Ahh OK.
From what I understand, looking at other operations in the arithmetic dialect, we specify the signed semantics as part of the operation name only if we want to distinguish the signed and unsigned behaviour (like arith.divsi vs. arith.divui). In this case, we always want a signed semantics so can't we just call it fpowi, ipowi, just like arith.addi? Or did I miss a point?
I see that LLVM IR does not have an equivalent to the ipowsi instruction. Could this be due to C/C++ not having the exponentiation operation in the language or in the math library? I wonder what other languages that lower to llvm IR do.
You might want to use the Depends on <phabricator-patch-number> syntax to mark dependencies between the fpowsi and ipowsi patch.
Yes, I just wanted to make clear that the power operand is signed in the operation name. I can use just 'i' instead of 'si', since I do not expect that we will need a version with unsigned power operand.
I see that LLVM IR does not have an equivalent to the ipowsi instruction. Could this be due to C/C++ not having the exponentiation operation in the language or in the math library? I wonder what other languages that lower to llvm IR do.
Yes, math.h does not define pow functions with integer power argument as well as integer base argument. C++ does have std::pow overloads with int32 power argument, but they are implemented via math.h's double precision pow (so I think their performance is not as good as it could have been if there was a specialized version as in libgcc). Not sure what the other languages do.
You might want to use the Depends on <phabricator-patch-number> syntax to mark dependencies between the fpowsi and ipowsi patch.
Thanks for the hint! I usually use web interface to add parent revisions. In this case I have a chain of 4 revisions that I was writing one after another, so I just used linear chain: D129809->D129810->D129811->D129812
@kiranchandramohan, @ftynse thank you for your comments!
I split this patch into 3 pieces. New parts are in D130389 and D130390.
I will be unavailable next week, so I will not be able to reply. Sorry for the inconvenience.