Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-fno-approx-funcs doesn't override -Ofast or -ffast-math #51532

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52565
Status NEW
Importance P normal
Reported by Andy Kaylor (andrew.kaylor@intel.com)
Reported on 2021-11-19 15:11:00 -0800
Last modified on 2021-11-24 14:02:25 -0800
Version trunk
Hardware All All
CC htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, msd.ataei@gmail.com, neeilans@live.com, richard-llvm@metafoo.co.uk, shivam98.tkg@gmail.com, spatel+llvm@rotateright.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

If I compile the following code with 'clang -O2 -ffast-math -fno-approx-funcs' the IR generated sets the 'fast' flag (implying 'afn' on the call and issues no diagnostic indicating that the -fno-approx-funcs option was ignored.

#include <math.h>

float f(float x) {
  return logf(x);
}
define dso_local float @f(float %0) local_unnamed_addr #0 {
  %2 = tail call fast float @llvm.log.f32(float %0)
  ret float %2
}

attributes #0 = { mustprogress nofree nosync nounwind readnone uwtable willreturn "approx-func-fp-math"="true" "denormal-fp-math"="preserve-sign,preserve-sign" "denormal-fp-math-f32"="ieee,ieee" "frame-pointer"="none" "min-legal-vector-width"="0" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="true" }

D106191 needed many more changes to clang/lib/Driver/ToolChains/Clang.cpp to get this option to interact correctly with the other floating point options.

Quuxplusone commented 2 years ago

Proposed this PR to fix this bug: https://reviews.llvm.org/D114564