You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We get the expected optimization if the source was:
voidfoo(inta, intb) {
if (a >= 0&&a<32&&b >=0&&b<128)
bar(a, b);
}
So this is an ordering or reassociation problem. In the original code, we see the 2 initial sign-bit checks and combine those. Then, we don't have the optimization power to unwind the and+or logic tree to see the bigger, better optimization.
To amend my earlier comment: if we are going to solve this generally, then it's not a reassociation problem (the source code could also have been written in the form that directly corresponds to the IR in comment 1).
If this is not something that ConstraintElimination could be made to handle, we could view this as missing pieces of and-of-icmps logic like:
Extended Description
The if's condition can be optimized to
(unsigned)a < 32 && (unsigned)b < 128
. This transformation is done by GCC, but not by LLVM.The text was updated successfully, but these errors were encountered: