[llvm-bugs] [Bug 30745] New: __attribute__((optnone)) not respected with -ffast-math or -Ofast

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 20 07:55:37 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30745

            Bug ID: 30745
           Summary: __attribute__((optnone)) not respected with
                    -ffast-math or -Ofast
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: sebpop at gmail.com
          Reporter: sebpop at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

After changing the test-suite Polybench to compile a version of the
computational kernel with strict FP computations, adding
__attribute__((optnone)) and #pragma STDC FP_CONTRACT OFF, I have seen that
some tests do not pass the exact compare between the output of the strictFP
computation and the reference output.

It looks like attribute optnone does not have an effect on -ffast-math:

$ clang ~/foo.c -S -emit-llvm -O3 -o O3.ll
$ clang ~/foo.c -S -emit-llvm -Ofast -o Ofast.ll
$ diff -u O3.ll Ofast.ll
--- O3.ll       2016-10-19 10:17:07.892901815 -0400
+++ Ofast.ll    2016-10-19 10:23:27.784910049 -0400
@@ -73,7 +73,7 @@
   %idxprom7 = sext i32 %13 to i64
   %arrayidx8 = getelementptr inbounds [1024 x double], [1024 x double]*
%arrayidx, i64 0, i64 %idxprom7
   %14 = load double, double* %arrayidx8, align 8, !tbaa !5
-  %mul = fmul double %10, %14
+  %mul = fmul fast double %10, %14
   %15 = load [1024 x double]*, [1024 x double]** %B.addr, align 8, !tbaa !7
   %16 = load i32, i32* %i, align 4, !tbaa !1
   %idxprom9 = sext i32 %16 to i64
[...]
-attributes #0 = { noinline nounwind optnone uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }
+attributes #0 = { noinline nounwind optnone uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="true" "no-jump-tables"="false" "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"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="true"
"use-soft-float"="false" }

$ cat ~/foo.c

__attribute__((optnone))
void kernel_symm_StrictFP(int ni, int nj,
                          double alpha,
                          double beta,
                          double C[1024 + 0][1024 + 0],
                          double A[1024 + 0][1024 + 0],
                          double B[1024 + 0][1024 + 0])
{
#pragma STDC FP_CONTRACT OFF
  int i, j, k;
  double acc;


  for (i = 0; i < ni; i++)
    for (j = 0; j < nj; j++)
      {
 acc = 0;
 for (k = 0; k < j - 1; k++)
   {
     C[k][j] += alpha * A[k][i] * B[i][j];
     acc += B[k][j] * A[k][i];
   }
 C[i][j] = beta * C[i][j] + alpha * A[i][i] * B[i][j] + alpha * acc;
      }
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161020/b183f476/attachment-0001.html>


More information about the llvm-bugs mailing list