Speculation chained comparison optimization (possibly with outlining)

Even if I’m not thinking clearly, note that in general you have something like:

a(x1) < b(x2) < c(x3) < d(x4) …

Where the functions are actual functions (or just alternatively code above generating the), temporary variables, or constants.

Let’s say you have:

fast(x) < slow(x) < slow2(x) < constant

do you want to evaluate the two slow functions or possibly just the fast one?

Do compilers do this (since chaining is just syntactic sugar and not really new)? I’m not sure comparison chaining is in C++ (or C) now, wasn’t when I used. I learned it from Python, and all the scripting languages can’t/won’t do [whole] program analysis.

Swift (and Rust) is also new, reuses LLVM. I’m just skeptical LLVM or GCC have this as first made for C/C++/Fortran.