[RFC][InstSimplify] Optimize compares with multiple selects as operands

Hello, I recently posted a patch for this: https://reviews.llvm.org/D150360

This introduces another condition for folding (simplifies) the cmp instruction with appropriate result when the operands are two select instructions. We can determine the outcome based upon the operands of select instructions in some conditions. For example, if we have:

%tmp1 = select i1 %cmp, i32 1, i32 %param
%tmp2 = select i1 %cmp, i32 9, i32 %param
%cmp2 = icmp slt i32 %tmp2, %tmp1

We can simplify %cmp2 to false, because both branches of both the selects
will result false.
Can anyone please review the patch?
Thanks!

1 Like