[InstCombine] Optimize compares with multiple selects as operands
In case of a comparison with two select instructions having the same condition, check whether one of the resulting branches can be simplified. If so, just compare the other branch and select the appropriate result. For example: %tmp1 = select i1 %cmp, i32 %y, i32 %x %tmp2 = select i1 %cmp, i32 %z, i32 %x %cmp2 = icmp slt i32 %tmp2, %tmp1 The icmp will result false for the false value of selects and the result will depend upon the comparison of true values of selects if %cmp is true. Thus, transform this into: %cmp = icmp slt i32 %y, %z %sel = select i1 %cond, i1 %cmp, i1 false Differential Revision: https://reviews.llvm.org/D150360
Loading
Please sign in to comment