Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-fapprox-funcs doesn't work correctly with #pragma float_control(precise, on) #51533

Open Quuxplusone opened 2 years ago

Quuxplusone commented 2 years ago
Bugzilla Link PR52566
Status NEW
Importance P normal
Reported by Andy Kaylor (andrew.kaylor@intel.com)
Reported on 2021-11-19 15:21:34 -0800
Last modified on 2021-11-20 13:08:13 -0800
Version trunk
Hardware All All
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, neeilans@live.com, richard-llvm@metafoo.co.uk, spatel+llvm@rotateright.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

If I compile the following code with 'clang -O2 -fapprox-funcs' the "approx-func-fp-math" attribute will be incorrectly set to 'true' and the 'afn' flag will be set on the call to logf. The float_control pragma should disable this.

#include <math.h>

#pragma float_control(precise, on)
float f(float x) {
  return logf(x);
}
define dso_local float @f(float %0) local_unnamed_addr #0 {
  %2 = tail call afn float @logf(float %0) #2
  ret float %2
}

attributes #0 = { mustprogress nofree nounwind uwtable willreturn "approx-func-fp-math"="true" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }