Hi all, This is initial patch for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57371 . Per Joseph's suggestion it optimizes (float)lhs CMP rhs (double)lhs CMP rhs to lhs CMP (typeof(x))rhs whenever typeof(x) can be precisely represented by floating-point type (e.g. short by float or int by double) and rhs can be precisely represented by typeof(x).
Bootstrapped/regtested on x64. Ok for trunk? I'd like to extend this further in follow-up patches: 1) fold always-false/always-true comparisons e.g. short x; (float)x > INT16_MAX; // Always false 2) get rid of cast in comparisons with zero regardless of typeof(lhs) when -fno-trapping-math: (float_or_double)lhs CMP 0 -Y
pr57371-1.patch
Description: Binary data