[PATCH] D33342: [InstCombine] try to canonicalize xor-of-icmps to and-of-icmps
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 07:12:52 PDT 2017
spatel added a comment.
In https://reviews.llvm.org/D33342#768301, @efriedma wrote:
> This approach seems relatively expensive and not very flexible... e.g. we can't even transform "(x < 5) ^ (x == 4)". Is there really no better way to catch simple cases?
Can you provide an IR example of the case you're thinking of? Did I mistranslate the comment above?
$ cat xoricmps.ll
define i1 @xor_icmps_signed(i8 %x) {
%cmp1 = icmp slt i8 %x, 5
%cmp2 = icmp eq i8 %x, 4
%r = xor i1 %cmp1, %cmp2
ret i1 %r
}
define i1 @xor_icmps_unsigned(i8 %x) {
%cmp1 = icmp ult i8 %x, 5
%cmp2 = icmp eq i8 %x, 4
%r = xor i1 %cmp1, %cmp2
ret i1 %r
}
$ ./opt -instcombine xoricmps.ll -S
define i1 @xor_icmps_signed(i8 %x) {
%1 = icmp slt i8 %x, 4
ret i1 %1
}
define i1 @xor_icmps_unsigned(i8 %x) {
%1 = icmp ult i8 %x, 4
ret i1 %1
}
https://reviews.llvm.org/D33342
More information about the llvm-commits
mailing list