isAllOnes() should return true for zero bit values because
there are no zeros in it.
Thanks to Jay Foad for pointing this out.
Paths
| Differential D111241
[APInt] Fix isAllOnes and extractBits for zero width values. ClosedPublic Authored by lattner on Oct 6 2021, 9:53 AM.
Details Summary isAllOnes() should return true for zero bit values because Thanks to Jay Foad for pointing this out.
Diff Detail
Event TimelineComment Actions This makes me happy!
This revision is now accepted and ready to land.Oct 6 2021, 11:56 AM This revision was landed with ongoing or failed builds.Oct 6 2021, 12:38 PM Closed by commit rGad37a45a2e13: [APInt] Fix isAllOnes and extractBits for zero width values. (authored by lattner). · Explain Why This revision was automatically updated to reflect the committed changes. Comment Actions Did this get an audit for existing users? It can be argued in both ways. E.g. "".isdigit() in Python is False, because there is no digit contained and that's pretty much the same use case. Comment Actions
AFAIK there are no in-tree users to audit: zero-width APInts were only introduced very recently, and I don't think they're used in-tree except for unit tests. Comment Actions Right, they are only being used in the CIRCT incubator project afaik, and it is fine.
Revision Contents
Diff 377580 llvm/include/llvm/ADT/APInt.h
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/APIntTest.cpp
|
'true' would be better than '1U', but isn't there an EXPECT_TRUE for this?