[SelectionDAG] Simplify how we drop poison flags in SimplifyDemandedBits.
authorCraig Topper <craig.topper@sifive.com>
Mon, 11 Jul 2022 20:31:07 +0000 (13:31 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 11 Jul 2022 20:42:33 +0000 (13:42 -0700)
commitb05160dbdf828d333e4b71577f70e38d77d2e212
tree05a1ffd53ac66dd44853d0327240b7d99451ae23
parent66cdd6548ac51f2039b9f0bc10ec03f387b210c4
[SelectionDAG] Simplify how we drop poison flags in SimplifyDemandedBits.

As far as I can tell what was happening in the original code is
that the getNode call receives the same operands as the original
node with different SDNodeFlags. The logic inside getNode detects
that the node already exists and intersects the flags into the
existing node and returns it. This results in Op and NewOp for the
TLO.CombineTo call always being the same node.

We may have already called CombineTo as part of the recursive handling.
A second call to CombineTo as we unwind the recursion overwrites
the previous CombineTo. I think this means any time we updated the
poison flags that was the only change that ends up getting made
and we relied on DAGCombiner to revisit and call SimplifyDemandedBits
again. The second time the poison flags wouldn't need to be dropped
and we would keep the CombineTo call from further down the recursion.

We can instead call setFlags to drop the poison flags and remove the
call to TLO.CombineTo. This way we keep the CombineTo from deeper in
the recursion which should be more efficient.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D129511
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp