<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - __attribute__((optnone)) not respected with -ffast-math or -Ofast"
   href="https://llvm.org/bugs/show_bug.cgi?id=30745">30745</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((optnone)) not respected with -ffast-math or -Ofast
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>sebpop@gmail.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sebpop@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
      }
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>