Two comparison operations and a logical operation are combined into selection using MIN or MAX and comparison operation.
For optimization to be applied conditions have to be satisfied:
- In comparison operations has to be the one common operand.
- Supports only signed and unsigned integers.
- Comparison has to be the same with respect to common operand.
- There are no more users of comparison except logic operation.
- Every combination of comparison and AND, OR are supported.
It will convert
%l0 = %a < %c %l1 = %b < %c %res = %l0 or %l1
into
%sel = min(%a, %b) %res = %sel < %c
It supports several comparison operations (<, <=, >, >=), signed, unsigned values and different order of operands if they do not violate conditions.
clang-format not found in user’s local PATH; not linting file.