[llvm] [DAG] Remove OneUse restriction when folding (shl (add x, c1), c2) (PR #69105)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 06:08:10 PDT 2023


================
@@ -3304,6 +3304,17 @@ X86TargetLowering::preferredShiftLegalizationStrategy(
                                                             ExpansionFactor);
 }
 
+bool X86TargetLowering::isDesirableToCommuteWithShift(
+    const SDNode *N, CombineLevel Level) const {
+  assert((N->getOpcode() == ISD::SHL || N->getOpcode() == ISD::SRA ||
+          N->getOpcode() == ISD::SRL) &&
+         "Expected shift op");
+
+  if (!N->getOperand(0)->hasOneUse())
+    return false;
+  return true;
----------------
RKSimon wrote:

Can't we just say `return N->getOperand(0)->hasOneUse()` ?

https://github.com/llvm/llvm-project/pull/69105


More information about the llvm-commits mailing list