I am trying to compute $x^2$ where $x$ is a double precision floating point number. I need conservative rounding, which means I need $x \cdot x$ rounded up and $x \cdot x$ rounded down. If the rounding mode is set to FE_UPWARDS, the code is
double lo = -(x * -x); double hi = x * x;
However, this does not work for me on clang 3.4: the compiler notices the "common subexpression" and does only one multiply. Does anyone know how to convince clang to not do this, ideally without harming other optimizations? In particular, I would like to avoid noninline functions.