[PATCH] D28625: [InstCombine] try to shrink bitwise logic with phi operand

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 12:38:13 PST 2017

spatel added a comment.

In https://reviews.llvm.org/D28625#650685, @efriedma wrote:

> Err, sorry, it looks like my comment wasn't really clear about what I was thinking about...
> The optimization sort of has two weaknesses in its current state: one the optimization doesn't work if the initial value isn't a constant.  Two, it only works if there's a single logical operation per loop iteration.  The first could probably be fixed using known bits; I'm more worried about the second one... it's probably not something we would deal with in instcombine.  Maybe that's not important.

For the first, yes, I considered adding phis in demanded bits simplify, but that seemed like overkill for the cases I'm seeing, so I thought a more specific solution was the way to go. For the second, if we have a chain of logic ops, then they should all shrink once we can shrink the first link in that chain. Ie, we already have very similar transforms in foldLogicCastConstant() and shrinkBitwiseLogic(). If you have an example of the pattern you're imagining, we can certainly try to see if the current group of shrinking transforms will handle it?


More information about the llvm-commits mailing list