[PATCH] D32143: [InstSimplify] use ConstantRange to simplify more and-of-icmps
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 09:34:40 PDT 2017
spatel added a comment.
This is a fun one. The ultimate problem is that by making InstSimplify smarter, we revealed a shortcoming in InstCombine. InstCombine is missing a fold for xor-of-icmps like this:
; (a > 0) ^ (a == 1) --> ((a > 0) & (a != 1)) | ((a <= 0) & (a == 1)) --> (a > 1)
define i1 @test1(i64 %a) {
%b = icmp sgt i64 %a, 0
%c = icmp eq i64 %a, 1
%and = xor i1 %c, %b
ret i1 %and
}
I think we can avoid the problem in your original test case though. Ie, there's another InstCombine bug because it creates an unnecessary instruction:
IC: ADD: %notctmp = xor i1 %c, false
And that's what triggers another fold (the 'and' in the original code becomes an 'xor') which produces the pattern that we don't know how to fold yet.
Repository:
rL LLVM
https://reviews.llvm.org/D32143
More information about the llvm-commits
mailing list