mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 14:56:10 +00:00

Previously treatment of the attribute `optnone` was modified in https://github.com/llvm/llvm-project/pull/85605 ([clang] Set correct FPOptions if attribute 'optnone' presents). As a side effect FPContract was disabled for optnone. It created unneeded divergence with the behavior of -O0, which enables this optimization. In the discussion https://github.com/llvm/llvm-project/pull/85605#issuecomment-2089350379 it was pointed out that FP contraction should be enabled even if all optimizations are turned off, otherwise results of calculations would be different. This change enables FPContract at optnone.
25 lines
1015 B
C++
25 lines
1015 B
C++
// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -ast-dump %s \
|
|
// RUN: | FileCheck %s
|
|
|
|
#pragma STDC FENV_ROUND FE_DOWNWARD
|
|
#pragma float_control(precise, off)
|
|
|
|
template <typename T>
|
|
__attribute__((optnone)) T func_22(T x, T y) {
|
|
return x + y;
|
|
}
|
|
|
|
// CHECK-LABEL: FunctionTemplateDecl {{.*}} func_22
|
|
// CHECK: FunctionDecl {{.*}} func_22 'T (T, T)'
|
|
// CHECK: CompoundStmt {{.*}} FPContractMode=1 ConstRoundingMode=downward MathErrno=1
|
|
// CHECK: ReturnStmt
|
|
// CHECK: BinaryOperator {{.*}} '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1
|
|
// CHECK: FunctionDecl {{.*}} func_22 'float (float, float)'
|
|
// CHECK: CompoundStmt {{.*}} FPContractMode=1 ConstRoundingMode=downward MathErrno=1
|
|
// CHECK: ReturnStmt
|
|
// CHECK: BinaryOperator {{.*}} 'float' '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1
|
|
|
|
float func_23(float x, float y) {
|
|
return func_22(x, y);
|
|
}
|