[all-commits] [llvm/llvm-project] b4b06d: __arithmetic_fence enforces ordering on expression...

Zahira Ammarguellat via All-commits all-commits at lists.llvm.org
Thu Jan 26 11:18:43 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b4b06d8ff82647824a658356e1e8f7dc9d1ac7d2
      https://github.com/llvm/llvm-project/commit/b4b06d8ff82647824a658356e1e8f7dc9d1ac7d2
  Author: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
  Date:   2023-01-26 (Thu, 26 Jan 2023)

  Changed paths:
    M clang/lib/Basic/Targets/SPIR.h
    M clang/test/CodeGen/arithmetic-fence-builtin.c
    M clang/test/Sema/arithmetic-fence-builtin.c

  Log Message:
  -----------
  __arithmetic_fence enforces ordering on expression evaluation when fast-math
is enabled.
In fast math mode some floating-point optimizations are performed such as
reassociation and distribution.

For example, the compiler may transform (a+b)+c into a+(b+c). Although these
two expressions are equivalent in integer arithmetic, they may not be in
floating-point arithmetic. The builtin tells the compiler that the expression
in parenthesis can’t be re-associated or distributed.
__arithmetic_fence(a+b)+c is not equivalent to a+(b+c).

This patch adds the support of the builtin to SPIR target.

Differential Revision: https://reviews.llvm.org/D142583




More information about the All-commits mailing list