[all-commits] [llvm/llvm-project] ddae50: [RISCV] Combine trunc (sra sext (x), zext (y)) to ...
Vettel via All-commits
all-commits at lists.llvm.org
Sun Sep 17 02:11:41 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ddae50d1e6fd71b98a4abefeeebb7ad6ac3329c5
https://github.com/llvm/llvm-project/commit/ddae50d1e6fd71b98a4abefeeebb7ad6ac3329c5
Author: Vettel <924105575 at qq.com>
Date: 2023-09-17 (Sun, 17 Sep 2023)
Changed paths:
M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
M llvm/test/CodeGen/RISCV/rvv/vsra-sdnode.ll
Log Message:
-----------
[RISCV] Combine trunc (sra sext (x), zext (y)) to sra (x, smin (y, scalarsizeinbits(y) - 1)) (#65728)
For RVV, If we want to perform an i8 or i16 element-wise vector
arithmetic right shift in the upper C/C++ program, the value to be
shifted would be first sign extended to i32, and the shift amount would
also be zero_extended to i32 to perform the vsra.vv instruction, and
followed by a truncate to get the final calculation result, such pattern
will later expanded to a series of "vsetvli" and "vnsrl" instructions
later, this is because the RVV spec only support 2 * SEW -> SEW
truncate. But for vector, the shift amount can also be determined by
smin (Y, ScalarSizeInBits(Y) - 1)). Also, for the vsra instruction, we
only care about the low lg2(SEW) bits as the shift amount.
- Alive2: https://alive2.llvm.org/ce/z/u3-Zdr
- C++ Test cases : https://gcc.godbolt.org/z/q1qE7fbha
More information about the All-commits
mailing list