Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
If we do this we should at least be targetted and restrict it to the tests that need the flag. For example you could put: list(APPEND CFLAGS -ffp-contract=off)to MultiSource/Applications/oggenc/CMakeLists.txt and CFLAGS += -ffp-contract=off into MultiSource/Applications/oggenc/Makefile that at least forces us to think about why a specific benchmark fails and maybe we can find a way to rather use fpcmp/set an absolution/relative tollerance for when comparing the results (though admittedly I don't see how we can do that in a case of oggenc where a .ogg file is produced). - Matthias > On Sep 23, 2016, at 2:53 PM, Hal Finkel via cfe-commits > <cfe-commits@lists.llvm.org> wrote: > > We currently have logic in the test suite that sets -ffp-contract=off on > PowerPC (because the default for GCC and other compilers on PowerPC/Linux > systems is essentially -ffp-contract=fast). We might just want to do this now > for all platforms. > > -Hal > > - Original Message - >> From: "Steve Canon" <sca...@apple.com <mailto:sca...@apple.com>> >> To: reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org >> <mailto:reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org> >> Cc: "a skolnik" <a.skol...@samsung.com <mailto:a.skol...@samsung.com>>, >> clatt...@apple.com <mailto:clatt...@apple.com>, hfin...@anl.gov >> <mailto:hfin...@anl.gov>, "yaxun liu" <yaxun@amd.com >> <mailto:yaxun....@amd.com>>, >> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org> >> Sent: Friday, September 23, 2016 4:47:32 PM >> Subject: Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default >> >> Without digging into them yet, these are almost caused by >> overly-sensitive tests that are erroneously expecting bit-exact >> results. >> >> - Steve >> >> Sent from my iPhone >> >>> On Sep 23, 2016, at 4:42 PM, Renato Golin <renato.go...@linaro.org> >>> wrote: >>> >>> rengolin added a subscriber: rengolin. >>> rengolin added a comment. >>> >>> Folks, this commit has broken both AArch64 test-suite buildbots: >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 >>> >>> I have reverted in r282289, let me know if you need help testing on >>> AArch64. >>> >>> >>> Repository: >>> rL LLVM >>> >>> https://reviews.llvm.org/D24481 >>> >>> >>> >> > > -- > Hal Finkel > Lead, Compiler Technology and Programming Languages > Leadership Computing Facility > Argonne National Laboratory > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits> ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
That's not a great long-term solution for obvious reasons, but I think it's a great quick fix. Sent from my iPhone > On Sep 23, 2016, at 5:53 PM, Hal Finkel <hfin...@anl.gov> wrote: > > We currently have logic in the test suite that sets -ffp-contract=off on > PowerPC (because the default for GCC and other compilers on PowerPC/Linux > systems is essentially -ffp-contract=fast). We might just want to do this now > for all platforms. > > -Hal > > - Original Message - >> From: "Steve Canon" <sca...@apple.com> >> To: reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org >> Cc: "a skolnik" <a.skol...@samsung.com>, clatt...@apple.com, >> hfin...@anl.gov, "yaxun liu" <yaxun@amd.com>, >> cfe-commits@lists.llvm.org >> Sent: Friday, September 23, 2016 4:47:32 PM >> Subject: Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default >> >> Without digging into them yet, these are almost caused by >> overly-sensitive tests that are erroneously expecting bit-exact >> results. >> >> - Steve >> >> Sent from my iPhone >> >>> On Sep 23, 2016, at 4:42 PM, Renato Golin <renato.go...@linaro.org> >>> wrote: >>> >>> rengolin added a subscriber: rengolin. >>> rengolin added a comment. >>> >>> Folks, this commit has broken both AArch64 test-suite buildbots: >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 >>> >>> I have reverted in r282289, let me know if you need help testing on >>> AArch64. >>> >>> >>> Repository: >>> rL LLVM >>> >>> https://reviews.llvm.org/D24481 >>> >>> >>> >> > > -- > Hal Finkel > Lead, Compiler Technology and Programming Languages > Leadership Computing Facility > Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
We currently have logic in the test suite that sets -ffp-contract=off on PowerPC (because the default for GCC and other compilers on PowerPC/Linux systems is essentially -ffp-contract=fast). We might just want to do this now for all platforms. -Hal - Original Message - > From: "Steve Canon" <sca...@apple.com> > To: reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org > Cc: "a skolnik" <a.skol...@samsung.com>, clatt...@apple.com, hfin...@anl.gov, > "yaxun liu" <yaxun@amd.com>, > cfe-commits@lists.llvm.org > Sent: Friday, September 23, 2016 4:47:32 PM > Subject: Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default > > Without digging into them yet, these are almost caused by > overly-sensitive tests that are erroneously expecting bit-exact > results. > > - Steve > > Sent from my iPhone > > > On Sep 23, 2016, at 4:42 PM, Renato Golin <renato.go...@linaro.org> > > wrote: > > > > rengolin added a subscriber: rengolin. > > rengolin added a comment. > > > > Folks, this commit has broken both AArch64 test-suite buildbots: > > > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 > > > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 > > > > I have reverted in r282289, let me know if you need help testing on > > AArch64. > > > > > > Repository: > > rL LLVM > > > > https://reviews.llvm.org/D24481 > > > > > > > -- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Without digging into them yet, these are almost caused by overly-sensitive tests that are erroneously expecting bit-exact results. - Steve Sent from my iPhone > On Sep 23, 2016, at 4:42 PM, Renato Golinwrote: > > rengolin added a subscriber: rengolin. > rengolin added a comment. > > Folks, this commit has broken both AArch64 test-suite buildbots: > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 > > I have reverted in r282289, let me know if you need help testing on AArch64. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D24481 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
rengolin added a subscriber: rengolin. rengolin added a comment. Folks, this commit has broken both AArch64 test-suite buildbots: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 I have reverted in r282289, let me know if you need help testing on AArch64. Repository: rL LLVM https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
This revision was automatically updated to reflect the committed changes. Closed by commit rL282259: set the underlying value of “#pragma STDC FP_CONTRACT” on by default (authored by spop). Changed prior to commit: https://reviews.llvm.org/D24481?vs=72186=72299#toc Repository: rL LLVM https://reviews.llvm.org/D24481 Files: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/aarch64-neon-fma.c cfe/trunk/test/CodeGen/aarch64-scalar-fma.c cfe/trunk/test/CodeGen/fp-contract-pragma.cpp cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c cfe/trunk/test/Driver/clang_f_opts.c Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -2445,6 +2445,12 @@ if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) { Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); } + + if ((LangOpts.C11 || LangOpts.C99 || LangOpts.CPlusPlus) && + (CodeGenOptions::FPC_On == Res.getCodeGenOpts().getFPContractMode()) && + !LangOpts.CUDA) +LangOpts.DefaultFPContract = 1; + return Success; } Index: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c === --- cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c +++ cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s --check-prefix ALL_BUILDS +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 + +// REQUIRES: aarch64-registered-target + +// ALL_BUILDS-LABEL: fmadd_double: +// ALL_BUILDS: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// NON_O0-NEXT: ret +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// ALL_BUILDS: fmadd_single: +// ALL_BUILDS: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +// NON_O0-NEXT: ret +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: cfe/trunk/test/CodeGen/aarch64-neon-fma.c === --- cfe/trunk/test/CodeGen/aarch64-neon-fma.c +++ cfe/trunk/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: cfe/trunk/test/CodeGen/aarch64-scalar-fma.c === --- cfe/trunk/test/CodeGen/aarch64-scalar-fma.c +++ cfe/trunk/test/CodeGen/aarch64-scalar-fma.c @@ -0,0 +1,177 @@ +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=fast -S -o - %s | FileCheck -check-prefix=CHECK-FAST -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=on -S -o - %s | FileCheck -check-prefix=CHECK-ON -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=off -S -o - %s | FileCheck -check-prefix=CHECK-OFF -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -S -o - %s | FileCheck -check-prefix=CHECK-ON -check-prefix=CHECK-ALL %s +// REQUIRES: aarch64-registered-target + +float test1(float x, float y, float z) { + return x*y + z; + // CHECK-ALL-LABEL: test1: + // CHECK-FAST: fmadd + // CHECK-ON: fmadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test2(double x, double y, double z) { + z -= x*y; + return z; + // CHECK-ALL-LABEL: test2: + // CHECK-FAST: fmsub + // CHECK-ON: fmsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +float test3(float x, float y, float z) { + float tmp = x*y; + return tmp + z; + // CHECK-ALL-LABEL: test3: + // CHECK-FAST: fmadd + // CHECK-ON: fmul + // CHECK-ON-NEXT: fadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test4(double x, double y, double z) { + double tmp = x*y; + return tmp - z; + // CHECK-ALL-LABEL: test4: + // CHECK-FAST: fnmsub + // CHECK-ON: fmul + // CHECK-ON-NEXT: fsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +#pragma STDC FP_CONTRACT ON + +float test5(float x, float y, float z) { + return x*y + z; + // CHECK-ALL-LABEL: test5: + // CHECK-FAST: fmadd + // CHECK-ON: fmadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test6(double x, double y, double z) { + z -= x*y; + return z; + // CHECK-ALL-LABEL: test6: + // CHECK-FAST: fmsub + // CHECK-ON: fmsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +float
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
scanon accepted this revision. scanon added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
yaxunl added a comment. LGTM. Thanks. https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Abe updated this revision to Diff 72186. Abe added a comment. Minor edits for style-guidelines conformance. https://reviews.llvm.org/D24481 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aarch64-neon-fma.c clang/test/CodeGen/aarch64-scalar-fma.c clang/test/CodeGen/fp-contract-pragma.cpp clang/test/CodeGen/fp-contract-pragma___on-by-default.c clang/test/Driver/clang_f_opts.c Index: clang/test/Driver/clang_f_opts.c === --- clang/test/Driver/clang_f_opts.c +++ clang/test/Driver/clang_f_opts.c @@ -34,10 +34,13 @@ // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffast-math%s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffp-contract=on %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-ON-CHECK %s + // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast -// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-ON-CHECK: -ffp-contract=on // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s Index: clang/test/CodeGen/fp-contract-pragma___on-by-default.c === --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s --check-prefix ALL_BUILDS +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 + +// REQUIRES: aarch64-registered-target + +// ALL_BUILDS-LABEL: fmadd_double: +// ALL_BUILDS: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// NON_O0-NEXT: ret +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// ALL_BUILDS: fmadd_single: +// ALL_BUILDS: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +// NON_O0-NEXT: ret +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: clang/test/CodeGen/fp-contract-pragma.cpp === --- clang/test/CodeGen/fp-contract-pragma.cpp +++ clang/test/CodeGen/fp-contract-pragma.cpp @@ -1,27 +1,25 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// Is FP_CONTRACT honored in a simple case? -float fp_contract_1(float a, float b, float c) { -// CHECK: _Z13fp_contract_1fff +// Is FP_CONTRACT on by default, at least at -O3? +float fp_contract_8(float a, float b, float c) { +// CHECK: _Z13fp_contract_8fff // CHECK: tail call float @llvm.fmuladd - #pragma STDC FP_CONTRACT ON return a * b + c; } // Is FP_CONTRACT state cleared on exiting compound statements? float fp_contract_2(float a, float b, float c) { // 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 } return a * b + c; } // Does FP_CONTRACT survive template instantiation? -class Foo {}; -Foo operator+(Foo, Foo); template T template_muladd(T a, T b, T c) { @@ -62,15 +60,23 @@ return a * b + c; } +// Does FP_CONTRACT inside a function override the same in the file scope? +float fp_contract_1(float a, float b, float c) { +// CHECK: _Z13fp_contract_1fff +// CHECK: tail call float @llvm.fmuladd + #pragma STDC FP_CONTRACT ON + return a * b + c; +} + + // If the multiply has multiple uses, don't produce fmuladd. // This used to assert (PR25719): // https://llvm.org/bugs/show_bug.cgi?id=25719 -float fp_contract_7(float a, float b, float c) { +float fp_contract_7(float a, float b, float c, float& d_passed_by_ref) { // CHECK: _Z13fp_contract_7fff // CHECK: %[[M:.+]] = fmul float %b, 2.00e+00 -// CHECK-NEXT: fsub float %[[M]], %c #pragma STDC FP_CONTRACT ON - return (a = 2 * b) - c; + return (d_passed_by_ref = 2 * b) - c; } Index: clang/test/CodeGen/aarch64-scalar-fma.c === --- /dev/null +++ clang/test/CodeGen/aarch64-scalar-fma.c @@ -0,0 +1,177 @@ +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=fast -S -o - %s | FileCheck -check-prefix=CHECK-FAST -check-prefix=CHECK-ALL %s +// RUN:
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
yaxunl added inline comments. Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2441 @@ +2440,3 @@ + + if ((LangOpts.C11 || LangOpts.C99 || LangOpts.CPlusPlus) + && ( CodeGenOptions::FPC_On == Res.getCodeGenOpts().getFPContractMode() ) The format of this line looks strange. Did you check with clang-format-diff.py if it is OK? https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Abe updated this revision to Diff 72103. Abe added a comment. Combined "fp-contract-pragma___on-by-default___-O0___aarch64-backend.c" and "fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.c" into a single file ["fp-contract-pragma___on-by-default.c"]. https://reviews.llvm.org/D24481 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aarch64-neon-fma.c clang/test/CodeGen/aarch64-scalar-fma.c clang/test/CodeGen/fp-contract-pragma.cpp clang/test/CodeGen/fp-contract-pragma___on-by-default.c clang/test/Driver/clang_f_opts.c Index: clang/test/Driver/clang_f_opts.c === --- clang/test/Driver/clang_f_opts.c +++ clang/test/Driver/clang_f_opts.c @@ -34,10 +34,13 @@ // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffast-math%s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffp-contract=on %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-ON-CHECK %s + // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast -// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-ON-CHECK: -ffp-contract=on // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s Index: clang/test/CodeGen/fp-contract-pragma___on-by-default.c === --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s --check-prefix ALL_BUILDS +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 + +// REQUIRES: aarch64-registered-target + +// ALL_BUILDS-LABEL: fmadd_double: +// ALL_BUILDS: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// NON_O0-NEXT: ret +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// ALL_BUILDS: fmadd_single: +// ALL_BUILDS: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +// NON_O0-NEXT: ret +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: clang/test/CodeGen/fp-contract-pragma.cpp === --- clang/test/CodeGen/fp-contract-pragma.cpp +++ clang/test/CodeGen/fp-contract-pragma.cpp @@ -1,27 +1,25 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// Is FP_CONTRACT honored in a simple case? -float fp_contract_1(float a, float b, float c) { -// CHECK: _Z13fp_contract_1fff +// Is FP_CONTRACT on by default, at least at -O3? +float fp_contract_8(float a, float b, float c) { +// CHECK: _Z13fp_contract_8fff // CHECK: tail call float @llvm.fmuladd - #pragma STDC FP_CONTRACT ON return a * b + c; } // Is FP_CONTRACT state cleared on exiting compound statements? float fp_contract_2(float a, float b, float c) { // 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 } return a * b + c; } // Does FP_CONTRACT survive template instantiation? -class Foo {}; -Foo operator+(Foo, Foo); template T template_muladd(T a, T b, T c) { @@ -62,15 +60,23 @@ return a * b + c; } +// Does FP_CONTRACT inside a function override the same in the file scope? +float fp_contract_1(float a, float b, float c) { +// CHECK: _Z13fp_contract_1fff +// CHECK: tail call float @llvm.fmuladd + #pragma STDC FP_CONTRACT ON + return a * b + c; +} + + // If the multiply has multiple uses, don't produce fmuladd. // This used to assert (PR25719): // https://llvm.org/bugs/show_bug.cgi?id=25719 -float fp_contract_7(float a, float b, float c) { +float fp_contract_7(float a, float b, float c, float& d_passed_by_ref) { // CHECK: _Z13fp_contract_7fff // CHECK: %[[M:.+]] = fmul float %b, 2.00e+00 -// CHECK-NEXT: fsub float %[[M]], %c #pragma STDC FP_CONTRACT ON - return (a = 2 * b) - c; + return (d_passed_by_ref = 2 * b) - c; } Index: clang/test/CodeGen/aarch64-scalar-fma.c === --- /dev/null +++ clang/test/CodeGen/aarch64-scalar-fma.c @@ -0,0 +1,177
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
yaxunl added inline comments. Comment at: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.c:8 @@ +7,3 @@ +// CHECK: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// CHECK-NEXT: ret +double fmadd_double(double a, double b, double c) { This check seems unnecessary and can be removed. The same as below. Then this test can be merged with fp-contract-pragma___on-by-default___-O0___aarch64-backend.c https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Abe updated this revision to Diff 71959. Abe added a comment. Collapsed 4 test-case files that didn`t really need to be separate into 1 file, as suggested by Yaxun Liu. https://reviews.llvm.org/D24481 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aarch64-neon-fma.c clang/test/CodeGen/aarch64-scalar-fma.c clang/test/CodeGen/fp-contract-pragma.cpp clang/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.c clang/test/Driver/clang_f_opts.c Index: clang/test/Driver/clang_f_opts.c === --- clang/test/Driver/clang_f_opts.c +++ clang/test/Driver/clang_f_opts.c @@ -34,10 +34,13 @@ // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffast-math%s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffp-contract=on %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-ON-CHECK %s + // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast -// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-ON-CHECK: -ffp-contract=on // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s Index: clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.c === --- /dev/null +++ clang/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -O3 -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]}} +// 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___-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.cpp === --- clang/test/CodeGen/fp-contract-pragma.cpp +++ clang/test/CodeGen/fp-contract-pragma.cpp @@ -1,27 +1,25 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// Is FP_CONTRACT honored in a simple case? -float fp_contract_1(float a, float b, float c) { -// CHECK: _Z13fp_contract_1fff +// Is FP_CONTRACT on by default, at least at -O3? +float fp_contract_8(float a, float b, float c) { +// CHECK: _Z13fp_contract_8fff // CHECK: tail call float @llvm.fmuladd - #pragma STDC FP_CONTRACT ON return a * b + c; } // Is FP_CONTRACT state cleared on exiting compound statements? float fp_contract_2(float a, float b, float c) { // 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 } return a * b + c; } // Does FP_CONTRACT survive template instantiation? -class Foo {}; -Foo operator+(Foo, Foo); template T template_muladd(T a, T b, T c) { @@ -62,15 +60,23 @@ return a * b + c; } +// Does FP_CONTRACT inside a function override the same in the file scope? +float fp_contract_1(float a, float b, float c) { +// CHECK: _Z13fp_contract_1fff +// CHECK: tail call float @llvm.fmuladd + #pragma STDC FP_CONTRACT ON + return a * b + c; +} + + // If the multiply has multiple uses, don't produce fmuladd. // This used to assert (PR25719): //
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Abe added a comment. In https://reviews.llvm.org/D24481#547694, @yaxunl wrote: > Is it possible to merge > cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O[0-3]___aarch64-backend.c > as one and remove > cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h? > They look the same except the RUN commands. Why not using one file with > multiple RUn commands? That seems like a good idea. I didn`t write it that way yet b/c I was unsure of the semantics of multiple "RUN" command-comments in a single file. If a single file has e.g.: // RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s // RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s // RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s ... then that will cause 3 compilations and 3 tests, right? https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Abe updated this revision to Diff 71953. Abe added a comment. Removed some comments that I felt were good for clarity but at least 2 people disagreed. https://reviews.llvm.org/D24481 Files: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/aarch64-neon-fma.c cfe/trunk/test/CodeGen/aarch64-scalar-fma.c cfe/trunk/test/CodeGen/fp-contract-pragma.cpp cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1___aarch64-backend.c cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O2___aarch64-backend.c cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O3___aarch64-backend.c cfe/trunk/test/Driver/clang_f_opts.c Index: cfe/trunk/test/Driver/clang_f_opts.c === --- cfe/trunk/test/Driver/clang_f_opts.c +++ cfe/trunk/test/Driver/clang_f_opts.c @@ -34,10 +34,13 @@ // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s -// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffast-math%s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// RUN: %clang -### -S -ffp-contract=on %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-ON-CHECK %s + // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast -// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off +// FP-CONTRACT-ON-CHECK: -ffp-contract=on // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s Index: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O3___aarch64-backend.c === --- /dev/null +++ cfe/trunk/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" Index: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O2___aarch64-backend.c === --- /dev/null +++ cfe/trunk/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: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1___aarch64-backend.c === --- /dev/null +++ cfe/trunk/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: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h === --- /dev/null +++ cfe/trunk/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: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O0___aarch64-backend.c === --- /dev/null +++ cfe/trunk/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
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
yaxunl added a comment. > ... then that will cause 3 compilations and 3 tests, right? Right. https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
yaxunl added a comment. Is it possible to merge cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O[0-3]___aarch64-backend.c as one and remove cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default___-O1...3___aarch64-backend.h? They look the same except the RUN commands. Why not using one file with multiple RUn commands? https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits