Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2437,6 +2437,13 @@ if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) { Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); } + + // If there will ever be e.g. "LangOpts.C", replace "LangOpts.C11 || LangOpts.C99" with "LangOpts.C" on the next line. + if ( (LangOpts.C11 || LangOpts.C99 || LangOpts.CPlusPlus) // ... + /*...*/ && ( CodeGenOptions::FPC_On == Res.getCodeGenOpts().getFPContractMode() ) // ... // just being careful + /*...*/ && ! LangOpts.CUDA) + LangOpts.DefaultFPContract = 1; + return Success; } Index: clang/test/CodeGen/aarch64-neon-fma.c =================================================================== --- clang/test/CodeGen/aarch64-neon-fma.c +++ clang/test/CodeGen/aarch64-neon-fma.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s +// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -ffp-contract=off -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s // Test new aarch64 intrinsics and types Index: clang/test/CodeGen/fp-contract-pragma.cpp =================================================================== --- clang/test/CodeGen/fp-contract-pragma.cpp +++ clang/test/CodeGen/fp-contract-pragma.cpp @@ -13,6 +13,7 @@ // CHECK: _Z13fp_contract_2fff // CHECK: %[[M:.+]] = fmul float %a, %b // CHECK-NEXT: fadd float %[[M]], %c + #pragma STDC FP_CONTRACT OFF { #pragma STDC FP_CONTRACT ON } Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s +// REQUIRES: aarch64-registered-target + +// CHECK-LABEL: fmadd_double: +// CHECK: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// CHECK-LABEL: fmadd_single: +// CHECK: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h =================================================================== --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h @@ -0,0 +1,14 @@ +// CHECK-LABEL: fmadd_double: +// CHECK: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// CHECK-NEXT: ret +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// CHECK-LABEL: fmadd_single: +// CHECK: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +// CHECK-NEXT: ret +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1___aarch64-backend.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1___aarch64-backend.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %S/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h +// REQUIRES: aarch64-registered-target + +#include "fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h" Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O2___aarch64-backend.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O2___aarch64-backend.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %S/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h +// REQUIRES: aarch64-registered-target + +#include "fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h" Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O3___aarch64-backend.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O3___aarch64-backend.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %S/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h +// REQUIRES: aarch64-registered-target + +#include "fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h"