[llvm] [LLVM][AArch64] Correctly lower funnel shifts by zero. (PR #140058)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu May 15 06:56:48 PDT 2025


================
@@ -7266,12 +7266,18 @@ static SDValue LowerFunnelShift(SDValue Op, SelectionDAG &DAG) {
     MVT VT = Op.getSimpleValueType();
 
     if (Op.getOpcode() == ISD::FSHL) {
+      if (ShiftNo->isZero())
+        return Op.getOperand(0);
+
       unsigned int NewShiftNo =
           VT.getFixedSizeInBits() - ShiftNo->getZExtValue();
----------------
jayfoad wrote:

For power of two bitwidths this can be simplified to `0 - ShiftNo->getZExtValue()`.

For the general case including non-power-of-two bitwidths it would have to be something more complicated like `VT.getFixedSizeInBits() - ShiftNo->getZExtValue() % VT.getFixedSizeInBits()`.

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


More information about the llvm-commits mailing list