This transform is never a pessimization at the IR level (since it
replaces an icmp with another), and has potentiall payoffs:
- It may make the icmp fold away or become loop invariant.
- It may make the A & (L - 1) computation dead.
This shows up in Java, in range checks generated by array accesses of
the form a[i & (a.length - 1)].
Isn't X - 1 always canonicalized to X + -1 ? Your transform is permitted to assume canonicalization occurred earlier.