[PATCH] D109555: [APInt] Enable APInt to support zero bit integers.

Chris Lattner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 16:20:37 PDT 2021


lattner created this revision.
Herald added subscribers: dexonsmith, hiraditya.
lattner requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Motivation: APInt not supporting zero bit values leads to
a lot of special cases in various bits of code, particularly
when using APInt as a bit vector (where you want to start with
zero bits and then concat on more.  This is particularly
challenging in the CIRCT project, where the absence of zero-bit
ConstantOp forces duplication of ops and makes instcombine-like
logic far more complicated.

Approach: zero bit integers are weird.  There are two reasonable
approaches: either make it illegal to do general arithmetic on
them (e.g. sign extends), or treat them as as implicitly having
a zero value.  This patch takes the conservative approach, which
enables their use in bitvector applications.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109555

Files:
  llvm/include/llvm/ADT/APInt.h
  llvm/lib/Support/APInt.cpp
  llvm/unittests/ADT/APIntTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109555.371747.patch
Type: text/x-patch
Size: 17689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210909/0a310a64/attachment.bin>


More information about the llvm-commits mailing list