[llvm] [X86] Convert lshr(x, BW-1) -> and(x, 1) iff x is allsignbits (PR #83596)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 09:34:54 PST 2024


================
@@ -29006,6 +29007,12 @@ static SDValue LowerShiftByScalarImmediate(SDValue Op, SelectionDAG &DAG,
       Op.getOpcode() == ISD::SRA)
     return ArithmeticShiftRight64(ShiftAmt);
 
+  // If we're right logical shifting the MSB to LSB of an all-signbits value
+  // then we can just perform as a mask.
+  if (Op.getOpcode() == ISD::SRL && ShiftAmt == (EltSizeInBits - 1))
+    if (DAG.ComputeNumSignBits(R) == EltSizeInBits)
----------------
goldsteinn wrote:

Also, is there a reason this isn't in `DAGComber`. seems pretty general.

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


More information about the llvm-commits mailing list