[all-commits] [llvm/llvm-project] 2f6beb: [RISCV] Add inline expansion for vector ftrunc/fce...

Craig Topper via All-commits all-commits at lists.llvm.org
Wed Dec 1 11:25:48 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2f6beb7b0e9e7ade6fd5ebc54c0fde5ddad0ef19
      https://github.com/llvm/llvm-project/commit/2f6beb7b0e9e7ade6fd5ebc54c0fde5ddad0ef19
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-12-01 (Wed, 01 Dec 2021)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    A llvm/test/CodeGen/RISCV/rvv/fceil-sdnode.ll
    A llvm/test/CodeGen/RISCV/rvv/ffloor-sdnode.ll
    M llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp.ll
    A llvm/test/CodeGen/RISCV/rvv/ftrunc-sdnode.ll

  Log Message:
  -----------
  [RISCV] Add inline expansion for vector ftrunc/fceil/ffloor.

This prevents scalarization of fixed vector operations or crashes
on scalable vectors.

We don't have direct support for these operations. To emulate
ftrunc we can convert to the same sized integer and back to fp using
round to zero. We don't need to do a convert if the value is large
enough to have no fractional bits or is a nan.

The ceil and floor lowering would be better if we changed FRM, but
we don't model FRM correctly yet. So I've used the trunc lowering
with a conditional add or subtract with 1.0 if the truncate rounded
in the wrong direction.

There are also missed opportunities to use masked instructions.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D113543




More information about the All-commits mailing list