[PATCH] D36498: [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt trunc X, 0) and (icmp sgt trunc X, -1) as equivalent to an and with the sign bit of the truncated type
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 14:59:17 PDT 2017
spatel added a comment.
The comment about multi-uses of the compare in https://reviews.llvm.org/D36711 made me wonder what we're doing here. Should we check one-use before trying to transform?
define i32 @test71_multi_use_cmp(i32 %x) {
%t1 = and i32 %x, 128
%t2 = icmp ne i32 %t1, 0
%t3 = select i1 %t2, i32 40, i32 42
%t4 = select i1 %t2, i32 60, i32 82
%add = add i32 %t3, %t4
ret i32 %add
}
$ ./opt -instcombine test71.ll -S
define i32 @test71_multi_use_cmp(i32 %x) {
%t1 = and i32 %x, 128
%t2 = icmp eq i32 %t1, 0
%1 = lshr exact i32 %t1, 6
%2 = xor i32 %1, 42
%t4 = select i1 %t2, i32 82, i32 60
%add = add nuw nsw i32 %2, %t4
ret i32 %add
}
https://reviews.llvm.org/D36498
More information about the llvm-commits
mailing list