[llvm] [AArch64] Convert negative constant aarch64_neon_sshl to VASHR (PR #68918)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 10:41:20 PDT 2023
================
@@ -19100,9 +19100,14 @@ static SDValue tryCombineShiftImm(unsigned IID, SDNode *N, SelectionDAG &DAG) {
case Intrinsic::aarch64_neon_sshl:
case Intrinsic::aarch64_neon_ushl:
// For positive shift amounts we can use SHL, as ushl/sshl perform a regular
- // left shift for positive shift amounts. Below, we only replace the current
- // node with VSHL, if this condition is met.
- Opcode = AArch64ISD::VSHL;
+ // left shift for positive shift amounts. For negative shifts we can use a
+ // VASHR/VLSHR as appropiate.
+ if (ShiftAmount < 0) {
+ Opcode = IID == Intrinsic::aarch64_neon_sshl ? AArch64ISD::VASHR
+ : AArch64ISD::VLSHR;
+ ShiftAmount = -ShiftAmount;
+ } else
+ Opcode = AArch64ISD::VSHL;
IsRightShift = false;
----------------
davemgreen wrote:
Yeah I originally had it like that. The idea is that we are converting a right shift to a !right shift by inverting the ShiftAmount, so in both case the code below wants IsRightShift = false.
https://github.com/llvm/llvm-project/pull/68918
More information about the llvm-commits
mailing list