Issue |
140239
|
Summary |
Incorrect optimization around __builtin_set_flt_rounds
|
Labels |
|
Assignees |
|
Reporter |
zhangjunphy
|
Clang seems to believe these two additions produce the same result and will optimize away the later one. However this is incorrect due to the `__builtin_set_flt_rounds` call, potentially changing the rounding mode.
Input:
```
void f(float a, float b, float *d, float *e) {
*d = a + b;
__builtin_set_flt_rounds(2);
*e = a + b;
}
```
ir:
```
define dso_local void @f(float, float, float*, float*)(float noundef %a, float noundef %b, ptr noundef writeonly captures(none) initializes((0, 4)) %d, ptr noundef writeonly captures(none) initializes((0, 4)) %e) local_unnamed_addr {
entry:
%add = fadd float %a, %b
store float %add, ptr %d, align 4
tail call void @llvm.set.rounding(i32 2)
store float %add, ptr %e, align 4
ret void
}
```
godbolt: https://godbolt.org/z/aaKnhvqMj
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs