llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang is suboptimal for `log(pow(x, y))` with fast-math

Open k-arrows opened this issue 2 years ago • 1 comments

Test case: https://godbolt.org/z/1fvYPxY37

#include<math.h>

double test1(double x) { 
  return log(pow(x, -3)); 
}

double test2(double x) { 
  return -3 * log(x); 
}

My expectation is that the output of test1 will be the same as test2.

k-arrows avatar Dec 29 '23 02:12 k-arrows

@EugeneZelenko Could I be assigned this issue? I'm adding a function to InstCombineMulDivRem.cpp (since that's where other opts relating to pow and exp live) and adding a test for it.

tanmaysachan avatar Dec 29 '23 14:12 tanmaysachan