[flang-commits] [flang] [llvm] [flang] Support UNSIGNED ** (PR #154601)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Wed Aug 20 13:05:12 PDT 2025


================
@@ -229,6 +229,24 @@ RT_API_ATTRS BTy FPowI(BTy base, ETy exp) {
   return result;
 }
 
+// Exponentiation operator for (Unsigned ** Unsigned) cases
+template <typename Ty> RT_API_ATTRS Ty UPow(Ty base, Ty exp) {
+  if (exp == Ty{0})
+    return Ty{1};
+  Ty result{1};
+  while (true) {
+    if (exp & Ty{1}) {
+      result *= base;
+    }
+    exp >>= 1;
----------------
eugeneepshteyn wrote:

Not `exp -= 1` ?

https://github.com/llvm/llvm-project/pull/154601


More information about the flang-commits mailing list