[PATCH] D51964: [InstCombine] Fold (xor (min/max X, Y), -1) -> (max/min ~X, ~Y) when X and Y are freely invertible.
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 13 10:40:24 PDT 2018
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.
I don't know how to solve the infinite loop bug completely yet (if anyone else does, please suggest), and given that this solves the existing bug while adding an optimization, I'll say LGTM.
But please do:
1. Commit the tests with baseline checks.
2. Add a TODO comment about using createMinMax() (we're dropping metadata in all of the related transforms, so it would be good to handle that in 1 place if possible)
3. Add this test for the existing bug:
define i32 @PR38915(i32 %x, i32 %y, i32 %z) {
%xn = sub i32 0, %x
%yn = sub i32 0, %y
%c1 = icmp sgt i32 %xn, %yn
%m1 = select i1 %c1, i32 %xn, i32 %yn
%m1n = xor i32 %m1, -1
%c2 = icmp sgt i32 %m1n, %z
%m2 = select i1 %c2, i32 %m1n, i32 %z
%m2n = xor i32 %m2, -1
ret i32 %m2n
}
Repository:
rL LLVM
https://reviews.llvm.org/D51964
More information about the llvm-commits
mailing list