[LLVMdev] InstCombine adds bit masks, confuses self, others

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Apr 17 16:15:03 PDT 2012


On Apr 17, 2012, at 3:29 PM, Chandler Carruth wrote:

> On Wed, Apr 18, 2012 at 12:22 AM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
> I tried disabling just the InstCombine transforms that hide shl instructions behind bitmasks. Even though DAGCombine has the same transforms, it causes some pretty bad regressions:
> 
> I wonder about your idea of still combining most of the shifts, but leaving the last bits uncombined... Certainly the combining effects seem particularly important to capture because we'll only look through a finite number of shifts to determine demanded bits, etc.

Yes, the idea is to only preserve shl instructions because of their arithmetic/logical duality. I'll keep folding ashr/lshr.

These transformations all still run:

  X << C1 >> C2 --> X << (C1-C2) & Mask
  X << C1 >> C2 --> X >> (C2-C1) & Mask
  X << C1 << C2 --> X << (C1+C2)
  X >> C1 >> C2 --> X >> (C1+C2)

I also allow folding of exact right shifts:

  X >>exact C1 <<nuw C2 --> X <<nuw (C2-C1)
  X >>exact C1 << C2 --> X >>exact (C1-C2)

Since a bit mask isn't needed, scalar evolution should be able to reason about this.

Long chains of shifts should still be collapsed this way.

> But this is all theorizing. =] The actually regressions will likely tell more.

Yeah, all of the regressions I posted actually had identical assembly. I'll try measuring again while holding my breath.

/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120417/b1d03c47/attachment.html>


More information about the llvm-dev mailing list