[all-commits] [llvm/llvm-project] 1b69ce: Currently the options ‘ffast-math’ and ‘ffp-contra...

Zahira Ammarguellat via All-commits all-commits at lists.llvm.org
Fri Sep 16 08:09:01 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b69ce1208976c71bf7ee3932aa272462c1feb1b
      https://github.com/llvm/llvm-project/commit/1b69ce1208976c71bf7ee3932aa272462c1feb1b
  Author: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
  Date:   2022-09-16 (Fri, 16 Sep 2022)

  Changed paths:
    M clang/docs/UsersManual.rst
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/test/CodeGen/ffp-contract-option.c
    A clang/test/Driver/fp-contract.c

  Log Message:
  -----------
  Currently the options ‘ffast-math’ and ‘ffp-contract’ are connected.
When ‘ffast-math’ is set, ffp-contract is altered this way:
-ffast-math/ Ofast -> ffp-contract=fast
-fno-fast-math -> if ffp-contract= fast then ffp-contract=on else
ffp-contract unchanged

This differs from gcc which doesn’t connect the two options.

Connecting these two options in clang, resulted in spurious warnings
when the user combines these two options -ffast-math -fno-fast-math; see
issue https://github.com/llvm/llvm-project/issues/54625.

The issue is that the ‘ffast-math’ option is an on/off flag, but the
‘ffp-contract’ is an on/off/fast flag. So when ‘fno-fast-math’ is used
there is no obvious value for ‘ffp-contract’. What should the value of
ffp-contract be for -ffp-contract=fast -fno-fast-math and -ffast-math
-ffp-contract=fast -fno-fast-math? The current logic sets ffp-contract
back to on in these cases. This doesn’t take into account that the value
of ffp-contract is modified by an explicit ffp-contract` option.
This patch is proposing a set of rules to apply when ffp-contract',
ffast-math and fno-fast-math are combined. These rules would give the
user the expected behavior and no diagnostic would be needed.

See RFC
https://discourse.llvm.org/t/rfc-making-ffast-math-option-unrelated-to-ffp-contract-option/61912




More information about the All-commits mailing list