We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 311a349 commit 08ac738Copy full SHA for 08ac738
libc/src/__support/FPUtil/generic/add_sub.h
@@ -98,11 +98,21 @@ add_or_sub(InType x, InType y) {
98
}
99
100
101
- return static_cast<OutType>(y);
+ // volatile prevents Clang from converting tmp to OutType and then
102
+ // immediately back to InType before negating it, resulting in double
103
+ // rounding.
104
+ volatile InType tmp = y;
105
+ if constexpr (IsSub)
106
+ tmp = -tmp;
107
+ return static_cast<OutType>(tmp);
108
109
- if (y_bits.is_zero())
- return static_cast<OutType>(x);
110
+ if (y_bits.is_zero()) {
111
112
113
114
115
+ }
116
117
118
InType x_abs = x_bits.abs().get_val();
0 commit comments