Issue 87758
Summary Clang differences when using commandline options or pragmas to turn on fast-math functionallity
Labels
Assignees
Reporter karka228
    When looking at the output from clang -cc1 for the program below

```
float powf(float x, float y);
float sqrtf(float x);

float f2(float x, int y) {
  x = powf(x,y);
  x = sqrtf(x);
  return x;
}
```
Compiled with:
`$ clang -cc1 foo.c -triple x86_64-linux-gnu -emit-llvm -o - -ffast-math -ffp-contract=fast`

The result of the `-ffast-math` and ` -ffp-contract=fast` options is that both calls to pow and sqrt are annotated with fast math flag `fast` (see LangRef):

```
  %2 = call fast float @llvm.pow.f32(float %0, float %conv)
  %4 = call fast float @llvm.sqrt.f32(float %3)
```

When instead turning on fast math with `#pragma float_control(precise,off)` like this:

```
float powf(float x, float y);
float sqrtf(float x);

#pragma float_control(push)
#pragma float_control(precise,off)

float f2(float x, int y) {
  x = powf(x,y);
  x = sqrtf(x);
  return x;
}
#pragma float_control(pop)
```
Compiled with:
`$ clang -cc1 foo.c -triple x86_64-linux-gnu -emit-llvm -o -`

The result of the pragma is that only the sqrt call get to be annotated with the fast math flag `fast`:

```
  %2 = call float @llvm.pow.f32(float %0, float %conv)
  %4 = call fast float @llvm.sqrt.f32(float %3)
```

Why are not `llvm.pow.f32` not annotated with fast math flag `fast` when using `#pragma float_control(precise,off)`?

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to