[clang] Fix bug with -ffp-contract=fast-honor-pragmas (PR #104857)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 20 04:26:09 PDT 2024
================
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast-honor-pragmas -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+ // CHECK-LABEL: fp_contract_1fff(
+ // CHECK: fmul contract float
+ // CHECK: fadd contract float
+ return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+ // CHECK-LABEL: fp_contract_2fff(
+ // CHECK: fmul contract float
+ // CHECK: fsub contract float
+ return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+ // CHECK-LABEL: fp_contract_3Pfff(
+ // CHECK: fmul contract float
+ // CHECK: fadd contract float
+ a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+ // CHECK-LABEL: fp_contract_4Pfff(
+ // CHECK: fmul contract float
+ // CHECK: fsub contract float
+ a[0] -= b * c;
+}
+
+float fp_contract_5(float a, float b, float c) {
+ // CHECK-LABEL: fp_contract_5fff(
+ // CHECK: fmul contract float
+ // CHECK: fadd contract float
+ float t = a * b;
+ return t + c;
+}
----------------
AaronBallman wrote:
Please add a newline to the end of the file.
https://github.com/llvm/llvm-project/pull/104857
More information about the cfe-commits
mailing list