[llvm-dev] default behavior or (original) (raw)

kamlesh kumar via llvm-dev llvm-dev at lists.llvm.org
Tue May 26 22:36:04 PDT 2020


Hi Devs, going by this link https://llvm.org/docs/LangRef.html#floatenv it says that floating point operation does not have side effects by defaults. but when compile a test case i.e. cat a.c float foo(float a, float b) { return a+b; }

$clang a.c -O2 -S -emit-llvm emit ir like: $cat a.ll

; ModuleID = 'a.c' source_filename = "a.c" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: norecurse nounwind readnone uwtable define dso_local float @foo(float %a, float %b) local_unnamed_addr #0 { entry: %add = fadd float %a, %b ret float %add }

and the setting "no-trapping-math"="false" should mean -ftrapping-math but it does not and it also contradict with documentation.

I think clang should emit this "no-trapping-math"="true" by default if it goes with this assumption https://llvm.org/docs/LangRef.html#floatenv ? what is default behavior of clang -fno-trapping-math or -ftrapping-math? also clang default behavior does not match gcc? https://godbolt.org/z/B3YvxE

./kamlesh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200527/85c57d10/attachment.html>



More information about the llvm-dev mailing list