[llvm] b05160d - [SelectionDAG] Simplify how we drop poison flags in SimplifyDemandedBits.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 11 13:42:40 PDT 2022
Author: Craig Topper
Date: 2022-07-11T13:42:33-07:00
New Revision: b05160dbdf828d333e4b71577f70e38d77d2e212
URL: https://github.com/llvm/llvm-project/commit/b05160dbdf828d333e4b71577f70e38d77d2e212
DIFF: https://github.com/llvm/llvm-project/commit/b05160dbdf828d333e4b71577f70e38d77d2e212.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 6e2eee6a319bf..26d96a78304a9 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2509,9 +2509,7 @@ bool TargetLowering::SimplifyDemandedBits(
// won't wrap after simplification.
Flags.setNoSignedWrap(false);
Flags.setNoUnsignedWrap(false);
- SDValue NewOp =
- TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Op1, Flags);
- return TLO.CombineTo(Op, NewOp);
+ Op->setFlags(Flags);
}
return true;
}
More information about the llvm-commits
mailing list