[PATCH] D41603: [InstCombine] fold min/max tree with common operand (PR35717)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 27 16:14:45 PST 2017
spatel created this revision.
spatel added reviewers: efriedma, hfinkel, majnemer.
Herald added a subscriber: mcrosier.
This might be over the edge of what we want from instcombine, but I'm not sure. There is precedence for factorization transforms in instcombine for FP ops with fast-math.
I think it would take more work to add this to reassociate because that's specialized for binops, and min/max are not binops (or even single instructions). Also, I don't have evidence that larger min/max trees than this exist in real code.
In the motivating example from https://bugs.llvm.org/show_bug.cgi?id=35717 , we have:
int test(int xc, int xm, int xy) {
int xk;
if (xc < xm)
xk = xc < xy ? xc : xy;
else
xk = xm < xy ? xm : xy;
return xk;
}
This patch is a preliminary step towards solving that case. We would still need to canonicalize the min/max to allow the fold for that example.
https://rise4fun.com/Alive/Qjne
https://rise4fun.com/Alive/3yg
https://reviews.llvm.org/D41603
Files:
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/minmax-fold.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41603.128249.patch
Type: text/x-patch
Size: 7668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171228/f1c0b5d9/attachment.bin>
More information about the llvm-commits
mailing list