[all-commits] [llvm/llvm-project] d1902d: [RISCV][P-ext] Fold bitcast of v4i8/v2i16 const sp...

SiHuaN via All-commits all-commits at lists.llvm.org
Mon May 25 20:31:46 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d1902d34606e070df3ffb1cadbd3aac0f1165484
      https://github.com/llvm/llvm-project/commit/d1902d34606e070df3ffb1cadbd3aac0f1165484
  Author: SiHuaN <liyongtai at iscas.ac.cn>
  Date:   2026-05-26 (Tue, 26 May 2026)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    A llvm/test/CodeGen/RISCV/rvp-bitcast-const-fold.ll

  Log Message:
  -----------
  [RISCV][P-ext] Fold bitcast of v4i8/v2i16 const splat to scalar on RV64 (#199513)

clang lowers `int8x4_t f(int8x4_t a) { return ~a; }` to a
bitcast-wrapped vector xor with splat(-1). v4i8/v2i16 aren't legal on
RV64, so the xor gets scalarized to i64 with the constant still wrapped
in BITCAST:
      `i64 = xor X, (bitcast (v8i8 splat -1))`

The scalar `not` PatFrag (xor X, -1) requires a literal constant and
can't see through BITCAST, so XORI -1 (= `not`) misses and we emit `li
-1; xor` (2 insns). The v8i8/v4i16/v2i32 paths stay at vector level and
match the bitcast-aware vector `vnot` td-pat, so they're fine; only the
widened-from-v4i8/v2i16 path falls through to scalar `not`.

Fix it by folding the bitcast of a v4i8/v2i16 constant splat to a scalar
i32 constant pre-legalization. Type promotion sign-extends to i64 -1 and
XORI matches.



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