[all-commits] [llvm/llvm-project] 8c1dc5: [RISCV] Add test for miscompile of vector.interlea...

Craig Topper via All-commits all-commits at lists.llvm.org
Tue Apr 2 11:59:55 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8c1dc5dd589ce6c056b95e43b72338ddea40789c
      https://github.com/llvm/llvm-project/commit/8c1dc5dd589ce6c056b95e43b72338ddea40789c
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M llvm/test/CodeGen/RISCV/rvv/vector-interleave.ll

  Log Message:
  -----------
  [RISCV] Add test for miscompile of vector.interleave when odd vector is literal poison.

The interleave lowering relies on a math trick that requires passing
the odd vector to two math instructions. In order to be correct
these instructions must see the same value.

If the odd vector is provably poison or undef, SelectionDAG will
create a vwadd and vwmaccu where the operand is a copy from IMPLICIT_DEF.
Later this will become just the undef flag on the operand. This
gives the register allocator freedom to pick a different register
for each instruction.


  Commit: a9af66a90e625fdb3c7ad2193e827a49d185fe60
      https://github.com/llvm/llvm-project/commit/a9af66a90e625fdb3c7ad2193e827a49d185fe60
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/rvv/vector-interleave.ll

  Log Message:
  -----------
  [RISCV] Lower (vector_interleave X, undef) to (vzext_vl X). (#87283)

If the odd vector is undef or poison, the widening add and multiply trick
doesn't work unless we freeze the odd vector.

Unfortunately, freezing doesn't work when the operand is provably
undef/poison. MIR doesn't have a representation for freeze so it
just becomes a COPY from IMPLICIT_DEF which freely propagates undef
to each operand independently.

To work around this, check for undef explicitly and lower to a VZEXT_VL
of the even vector. This produces better code than we'd get from a
freeze anyway.

I've left a FIXME for adding a freeze. I'll do that as a separate patch
as it affects other tests and doesn't help with the new test.


Compare: https://github.com/llvm/llvm-project/compare/d595080b4829...a9af66a90e62

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