[llvm] [Mips] Optimize (shift x (and y, BitWidth - 1)) to (shift x, y) (PR #73889)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 18:43:42 PST 2023


================
@@ -324,6 +326,20 @@ bool MipsDAGToDAGISel::SelectInlineAsmMemoryOperand(
   return true;
 }
 
+bool MipsDAGToDAGISel::isUnneededShiftMask(SDNode *N,
+                                             unsigned ShAmtBits) const {
+  assert(N->getOpcode() == ISD::AND && "Unexpected opcode");
+
+  const APInt &RHS = cast<ConstantSDNode>(N->getOperand(1))->getAPIntValue();
+  if (RHS.countr_one() >= ShAmtBits) {
+    LLVM_DEBUG(dbgs() << DEBUG_TYPE << " Need optimize 'and & shl/srl/sra' and operand value bits is " << RHS.countr_one() << "\n");
----------------
topperc wrote:

80 columns

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


More information about the llvm-commits mailing list