[PATCH] D17267: [DemandedBits] Introduce a getMinimumBitWidth() member function

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 05:42:12 PST 2016


jmolloy created this revision.
jmolloy added a reviewer: hfinkel.
jmolloy added a subscriber: llvm-commits.
jmolloy set the repository for this revision to rL LLVM.
Herald added a subscriber: mzolotukhin.

One of the major uses of DemandedBits is the loop vectorizer. It uses demandedbits to determine if an integer value can be losslessly truncated. This does not require the full power of demanded bits.

A non-demanded bit is a "don't care" bit - it can be changed to zero or one (or kept the same) without affecting the instruction's result. This is a powerful definition, but the loop vectorizer only needs a more limited form (which can be deduced in more situations) - "would removing this bit entirely affect the result?"

This can trigger in more situations because if we determine (via KnownBits) that a bit is part of a zero or sign extension, that bit can be happily removed (but not changed!)

This information is fairly trivial to track alongside AliveBits. We know track a set of "MustKeepBits" alongside AliveBits. MustKeepBits is a subset of the non-demanded bits (so MustKeepBits & AliveBits = 0). getDemandedBits(I) now changes from AliveBits[I] To AliveBits[I] | MustKeepBits[I].

This allows us to reenable tests that were removed following a revert due to PR26071.

I'm aware that the name "MustKeepBits" isn't perfect, and am open to bikeshedding.

Repository:
  rL LLVM

http://reviews.llvm.org/D17267

Files:
  include/llvm/Analysis/DemandedBits.h
  lib/Analysis/DemandedBits.cpp
  lib/Analysis/VectorUtils.cpp
  test/Analysis/DemandedBits/basic.ll
  test/Transforms/LoopVectorize/AArch64/loop-vectorization-factors.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17267.47984.patch
Type: text/x-patch
Size: 15921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160215/cad98d79/attachment.bin>


More information about the llvm-commits mailing list