Login
You're viewing the ruby.social public feed.
  • Nov 27, 2026, 9:46 PM

    heh, just found a nice optimization that GCC does, that Clang doesn't: godbolt.org/z/ET1M34GzG

    uint8_t returns87(uint8_t x) {
    uint8_t product = 3 * x;
    return product == 5 ? x : 87;
    }

    gcc optimizes this to "return 87", clang doesn't. this works because 3 is odd, hence no common divisors with 256. therefore multiplication by 3 is invertible mod 256, so GCC can compute what x must have been if 3 * x == 5 (namely 87).

    💬 1🔄 2⭐ 0

Replies