[all-commits] [llvm/llvm-project] e9fa6f: [RISCV] Fold (vXi8 (trunc (vselect (setltu, X, 256...

Craig Topper via All-commits all-commits at lists.llvm.org
Fri Jun 7 09:57:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e9fa6ffaf7e86fe9f91fbcaabce5436311ac814c
      https://github.com/llvm/llvm-project/commit/e9fa6ffaf7e86fe9f91fbcaabce5436311ac814c
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2024-06-07 (Fri, 07 Jun 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    A llvm/test/CodeGen/RISCV/rvv/trunc-select-to-max-usat.ll

  Log Message:
  -----------
  [RISCV] Fold (vXi8 (trunc (vselect (setltu, X, 256), X, (sext (setgt X, 0))))) to vmax+vnclipu. (#94720)

This pattern is an obscured way to express saturating a signed value
into a smaller unsigned value.

If (setltu, X, 256) is true, then the value is already in the desired
range so we can pick X. If it's false, we select (sext (setgt X, 0))
which is 0 for negative values and all ones for positive values. The all
ones value when truncated to the final type will still be all ones like
we want.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list