diff options
author | Alon Zakai <azakai@google.com> | 2023-08-02 15:52:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 15:52:01 -0700 |
commit | 138aff44c56bdcc0c036a1e11a19ea518331e6ba (patch) | |
tree | 5a646195ec3fb0ca6662158e845df2a492b35f18 /src/ir/possible-contents.cpp | |
parent | 7df30640820c9b4acfc69ffc7616809a727d1241 (diff) | |
download | binaryen-138aff44c56bdcc0c036a1e11a19ea518331e6ba.tar.gz binaryen-138aff44c56bdcc0c036a1e11a19ea518331e6ba.tar.bz2 binaryen-138aff44c56bdcc0c036a1e11a19ea518331e6ba.zip |
[NFC] Remove some unneeded cruft from PossibleContents::intersect() (#5854)
In order of appearance in this diff:
* Use heapType rather than otherHeapType when either will do, for brevity.
* We checked isNull after checking for isLiteral (line 173), but every null is a literal.
* Calling setNoneOrNull simplifies some repetitive code.
* We checked isLiteral yet again lower down.
Diffstat (limited to 'src/ir/possible-contents.cpp')
-rw-r--r-- | src/ir/possible-contents.cpp | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 232ebb7ad..b44046b39 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -188,48 +188,27 @@ void PossibleContents::intersect(const PossibleContents& other) { auto setNoneOrNull = [&]() { if (nullability == Nullable) { - value = Literal::makeNull(otherHeapType); + value = Literal::makeNull(heapType); } else { value = None(); } }; - if (isNull()) { - // The intersection is either this null itself, or nothing if a null is not - // allowed. - setNoneOrNull(); - return; - } - // If the heap types are not compatible then they are in separate hierarchies // and there is no intersection, aside from possibly a null of the bottom // type. auto isSubType = HeapType::isSubType(heapType, otherHeapType); auto otherIsSubType = HeapType::isSubType(otherHeapType, heapType); if (!isSubType && !otherIsSubType) { - if (nullability == Nullable && - heapType.getBottom() == otherHeapType.getBottom()) { - value = Literal::makeNull(heapType.getBottom()); + if (heapType.getBottom() == otherHeapType.getBottom()) { + setNoneOrNull(); } else { value = None(); } return; } - if (isLiteral()) { - // The information about the value being identical to a particular literal - // is not removed by intersection, if the type is in the cone we are - // intersecting with. - if (isSubType) { - return; - } - - // The type must change in a nontrivial manner, so continue down to the - // generic code path. This will stop being a Literal. TODO: can we do better - // here? - } - - // Intersect the cones, as there is no more specific information we can use. + // The heap types are compatible, so intersect the cones. auto depthFromRoot = heapType.getDepth(); auto otherDepthFromRoot = otherHeapType.getDepth(); |