[llvm] [InstCombine] Add log-pow simplification for FP exponent edge case. (PR #76641)

Joshua Cranmer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 12:40:34 PST 2024


================
@@ -12,6 +12,28 @@ define double @log_pow(double %x, double %y) {
   ret double %log
 }
 
+define double @log_powi_const(double %x) {
+; CHECK-LABEL: @log_powi_const(
+; CHECK-NEXT:    [[LOG1:%.*]] = call fast double @llvm.log.f64(double [[X:%.*]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul fast double [[LOG1]], -3.000000e+00
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %pow = call fast double @llvm.powi.f64.i32(double %x, i32 -3)
+  %log = call fast double @log(double %pow)
----------------
jcranmer-intel wrote:

The current trend is using `reassoc` for these sorts of transformations, but I'm not entirely happy with that logic. I'm putting together a RFC on tweaking the fast math flags and bringing some more clarity to these flags.

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


More information about the llvm-commits mailing list