[llvm] [DAGCombine] Remove oneuse restrictions for RISCV in folding (shl (add_nsw x, c1)), c2) and folding (shl(sext(add x, c1)), c2) in some scenarios (PR #101294)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 14:23:53 PDT 2024


================
@@ -2156,6 +2157,23 @@ bool HexagonTargetLowering::hasBitTest(SDValue X, SDValue Y) const {
   return X.getValueType().isScalarInteger(); // 'tstbit'
 }
 
+bool HexagonTargetLowering::isDesirableToCommuteWithShift(
+    const SDNode *N, CombineLevel Level) const {
+  using namespace llvm::SDPatternMatch;
+  assert((N->getOpcode() == ISD::SHL || N->getOpcode() == ISD::SRA ||
+          N->getOpcode() == ISD::SRL) &&
+         "Expected shift op");
+
+  SDValue ShiftLHS = N->getOperand(0);
+  SDValue Add;
+
+  if (ShiftLHS->hasOneUse() ||
+      sd_match(ShiftLHS, m_OneUse(m_SExt(m_OneUse(m_Value(Add))))))
----------------
mshockwave wrote:

what are you trying to achieve here? I think either `ShiftLHS->hasOneUse()` or the sd_match call is redundant

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


More information about the llvm-commits mailing list