[PATCH] D107692: [DAGCombine] Prevent the transform of combine for multi-use operand

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 7 06:01:56 PDT 2021


lebedev.ri added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4944
   if (N0.getOpcode() == ISD::ADD && N1.getOpcode() == ISD::SRL &&
-      VT.getSizeInBits() <= 64) {
+      VT.getSizeInBits() <= 64 && N0.hasOneUse()) {
     if (ConstantSDNode *ADDI = dyn_cast<ConstantSDNode>(N0.getOperand(1))) {
----------------
dmgreen wrote:
> N0->hasOneUse() would probably be better, to check the Node has one use not the SDValue. (Although here it likely won't make much difference.)
*Why* does it matter for the correctness whether the node has other uses or not?
The peephole should only affect the current root use we started with,
and not affect any other uses whatsoever.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107692/new/

https://reviews.llvm.org/D107692



More information about the llvm-commits mailing list