Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions include/boost/numeric/interval/detail/ppc_rounding_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ struct rounding_control<long double>:
#if __SIZEOF_LONG_DOUBLE__ == 8
// Same format as double.
__asm__ __volatile__ ("" : "+d"(r_));
#elif defined(__clang__)
// Clang has no register constraint that works for both 128-bit ABIs.
__asm__ __volatile__ ("" : "+m"(r_));
#else
// Which register can hold a 128-bit long double depends on the ABI: FPRs
// for IBM double-double, a VSX register for IEEE 128-bit. Clang accepts
// neither in all cases, hence the memory fallback.
__asm__ __volatile__ ("" : "+wa,d,m"(r_));
// FPRs for IBM double-double, a VSX register for IEEE 128-bit. A single
// alternative, as GCC rejects a "+" operand with several when the value
// is a constant.
__asm__ __volatile__ ("" : "+wadm"(r_));
#endif
return r_;
}
Expand Down
12 changes: 12 additions & 0 deletions test/rounding_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,21 @@ void test() {
BOOST_TEST(div_down<T>(one, three) < div_up<T>(one, three));
}

// Exact constants reach force_rounding once the division is folded; GCC
// used to reject the PowerPC long double asm then.
template<class T>
void test_constant() {
typedef boost::numeric::interval<T> I;
I q = I(6) / I(2);
BOOST_TEST(q.lower() == 3 && q.upper() == 3);
}

int main() {
test<float>();
test<double>();
test<long double>();
test_constant<float>();
test_constant<double>();
test_constant<long double>();
return boost::report_errors();
}
Loading