search for: floatcast

Displaying 3 results from an estimated 3 matches for "floatcast".

Did you mean: float_cast
2016 Apr 14
2
Integer -> Floating point -> Integer cast optimizations
.... > > If x matches the condition `countTrailingZeros(abs(x)) > (log2(abs(x)) - 23)`, then we can remove the float casts. > > So, if we can establish that abs(x) is <= 2**23, we can remove the casts. LLVM does not currently perform that optimization on this C code: > > int floatcast(int x) { > if (abs(x) <= 16777216) { // abs(x) is definitely <= 2**23 and fits into our mantissa cleanly > float flt = (float)x; > return (int)flt; > } > return x; > } > > Things get more interesting when you bring in higher integers and leading zero...
2016 Apr 15
2
Integer -> Floating point -> Integer cast optimizations
...ndition `countTrailingZeros(abs(x)) > (log2(abs(x)) - 23)`, then we can remove the float casts. >>> >>> So, if we can establish that abs(x) is <= 2**23, we can remove the casts. LLVM does not currently perform that optimization on this C code: >>> >>> int floatcast(int x) { >>> if (abs(x) <= 16777216) { // abs(x) is definitely <= 2**23 and fits into our mantissa cleanly >>> float flt = (float)x; >>> return (int)flt; >>> } >>> return x; >>> } >>> >>> Things get more int...
2016 Apr 07
7
Implementing a proposed InstCombine optimization
I am not entirely sure this is safe. Transforming this to an fsub could change the value stored on platforms that implement negates using arithmetic instead of with bitmath (such as ours) and either canonicalize NaNs or don’t support denormals. This is actually important because this kind of bitmath on floats is very commonly used as part of algorithms for complex math functions that need to get