Define intersectWith and unionWith as two complementary ways of
combining KnownBits. The names are chosen for consistency with
ConstantRange.
Deprecate commonBits as a synonym for intersectWith.
Paths
| Differential D150443
[KnownBits] Define and use intersectWith and unionWith ClosedPublic Authored by foad on May 12 2023, 5:46 AM.
Details Summary Define intersectWith and unionWith as two complementary ways of Deprecate commonBits as a synonym for intersectWith.
Diff Detail
Event Timeline
This revision is now accepted and ready to land.May 12 2023, 3:01 PM Comment Actions Two pieces of feedback on the API:
Comment Actions
No because union is a keyword :-( Apart from that I think it is a good candidate. I did think seriously about union/intersect, as well as other options like and/or.
Maybe but I don't think there is much consistency. I chose to do it this way for a couple of reasons:
But I don't mind changing it if there is consensus that having A.meet(B) modify A is surprising. Comment Actions meet and join sound like advanced stuff from something called lattice theory.
Comment Actions
Because operator& already does something different. It returns the known bits of the expression A&B, given the known bits of A and the known bits of B. That was probably my idea. I thought it would be nice if simple operators like A&B, A+B, A<<B etc all worked consistently in that way. But I guess we could abandon that plan and change the meaning of operator&. Comment Actions
This may be a bit surprising, but in a way it makes sense. Comment Actions
Oh, so that's why the corresponding ConstantRange methods are called unionWith and intersectWith... foad retitled this revision from [KnownBits] Define and use meet and join operations to [KnownBits] Define and use intersectWith and unionWith.May 15 2023, 3:25 AM Comment Actions
Thanks, I did not know about them. It seems best to copy that design. Comment Actions LGTM
This revision was landed with ongoing or failed builds.May 16 2023, 1:27 AM Closed by commit rGd8229e2f1424: [KnownBits] Define and use intersectWith and unionWith (authored by foad). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 522489 llvm/include/llvm/Support/KnownBits.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Support/KnownBits.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Lanai/LanaiISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/Sparc/SparcISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
|
Personally the text after the 'i.e' seems more useful for understanding the code (and I think matches the motivation for the code better) so I would swap the order.
'Returns the information that is known to be true for both this (aka LHS) and RHS. Another way to look at it is the greatest lower bound of LHS and RHS.'
Likewise below.