This patch implements missed optimization stated in PR19753
This will work for 'ashr exact' only for now in the 'instcombine' pass.
Test Case :
define i1 @exact_ashr_eq_false(i32 %a) {
%shr = ashr exact i32 -30, %a %cmp = icmp eq i32 %shr, -15 ret i1 %cmp
}
Result after applying patch :
define i1 @exact_ashr_eq_false(i32 %a) {
%cmp = icmp eq i32 %a, 1 ret i1 %cmp
}
It calculates the quotient of division of the 2 constants and takes log2, and then puts this value for comparison in icmp instruction.
Added the test case given in the bug report.
Please help in reviewing the patch.