brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 3775bd5 Raw
58 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast-honor-pragmas -emit-llvm -o - %s | FileCheck %s3 4float test_default(float a, float b, float c) {5  float tmp = a;6  tmp += b;7  tmp += c;8  return tmp;9}10 11// CHECK: define{{.*}} float @_Z12test_defaultfff(float noundef nofpclass(nan inf) %a, float noundef nofpclass(nan inf) %b, float noundef nofpclass(nan inf) %c) [[FAST_ATTRS:#[0-9]+]]12// CHECK: fadd fast float {{%.+}}, {{%.+}}13// CHECK: fadd fast float {{%.+}}, {{%.+}}14 15float test_precise_on_pragma(float a, float b, float c) {16  float tmp = a;17  {18    #pragma float_control(precise, on)19    tmp += b;20  }21  tmp += c;22  return tmp;23}24 25// CHECK: define{{.*}} float @_Z22test_precise_on_pragmafff(float noundef nofpclass(nan inf) %a, float noundef nofpclass(nan inf) %b, float noundef nofpclass(nan inf) %c) [[PRECISE_ATTRS:#[0-9]+]]26// CHECK: fadd float {{%.+}}, {{%.+}}27// CHECK: fadd fast float {{%.+}}, {{%.+}}28 29float test_reassociate_off_pragma(float a, float b, float c) {30  float tmp = a;31  {32    #pragma clang fp reassociate(off)33    tmp += b;34  }35  tmp += c;36  return tmp;37}38 39// CHECK: define{{.*}} float @_Z27test_reassociate_off_pragmafff(float noundef nofpclass(nan inf) %a, float noundef nofpclass(nan inf) %b, float noundef nofpclass(nan inf) %c)40// CHECK: fadd nnan ninf nsz arcp contract afn float {{%.+}}, {{%.+}}41// CHECK: fadd fast float {{%.+}}, {{%.+}}42 43float test_contract_on_pragma(float a, float b, float c) {44  float tmp = a * b;45  {46    #pragma clang fp contract(on)47    tmp += c;48  }49  return tmp;50}51 52// CHECK: define{{.*}} float @_Z23test_contract_on_pragmafff(float noundef nofpclass(nan inf) %a, float noundef nofpclass(nan inf) %b, float noundef nofpclass(nan inf) %c)53// CHECK: fmul fast float {{%.+}}, {{%.+}}54// CHECK: fadd reassoc nnan ninf nsz arcp afn float {{%.+}}, {{%.+}}55 56// CHECK: attributes [[FAST_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true"{{.*}} }57// CHECK: attributes [[PRECISE_ATTRS]] = { {{.*}}"no-infs-fp-math"="false" {{.*}}"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"{{.*}} }58