[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

Melanie Blower via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 13 13:03:54 PDT 2020


mibintc created this revision.
mibintc added reviewers: rjmccall, scanon.
Herald added a project: clang.
mibintc marked 3 inline comments as done.
mibintc added a comment.

added some inline explanation



================
Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+    Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);
----------------
I changed this because the FAST version of this test clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' attribute on the instruction dump.  All the LLVM FMF bits must be set for the fast attribute print.  By default, the value for OpenCL is ffp-contract=on


================
Comment at: clang/lib/Sema/SemaAttr.cpp:460
   case PFC_Push:
-    Action = Sema::PSK_Push_Set;
-    FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures.getAsOpaqueInt());
+    if (FpPragmaStack.Stack.empty()) {
+      FpPragmaStack.Act(Loc, Sema::PSK_Set, StringRef(),
----------------
When i was adding a test, I realized that pragma float_control(push) then pop wasn't working as expected. If the stack is empty, which is most of the time, first need to push the current fp features onto the stack so they can be restored at the pop


================
Comment at: clang/test/CodeGen/constrained-math-builtins.c:157
 
-  // CHECK: call contract float @llvm.experimental.constrained.fmuladd.f32
+  // CHECK: call float @llvm.experimental.constrained.fmuladd.f32
   // CHECK: fneg
----------------
most of the test changes here are just a revert of the test changes from the original patch for float_control


Previously, the IRBuilder.FMF.allowContract was initialized to true if either (ffp-contract=fast or ffp-contract=on) ; with this patch that bit will only be set if ffp-contract=fast.  This problem was pointed out by michele.scandale in a reply to https://reviews.llvm.org/D72841


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79903

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/fp-contract-on-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-class.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl
  clang/test/CodeGenOpenCL/single-precision-constant.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79903.263826.patch
Type: text/x-patch
Size: 18019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200513/0b5133bf/attachment-0001.bin>


More information about the cfe-commits mailing list