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

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 17:05:52 PST 2024


================
@@ -12,6 +12,75 @@ 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:%.*]])
----------------
andykaylor wrote:

This is a bit of a problem, though not one introduced by this PR. The call to log() may set errno in some circumstances, but the call to llvm.log isn't required to do so. If you compile with clang, it will call llvm.log in place of log() when math errno support isn't required. You can get clang to set fast on a call to the log library function using "-ffast-math -fmath-errno" but I'm not sure what that means since the fast-math flags allow us to replace the function.

I'm being pedantic here, and I don't mean for this to block the PR, but this is the primary difference between the library function and the intrinsic, so it seems worth thinking about.

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


More information about the llvm-commits mailing list