[llvm] [Hexagon] Use word splats for repeated HVX build-vector words (PR #204808)

Ikhlas Ajbar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 22:00:35 PDT 2026


================
@@ -0,0 +1,159 @@
+; RUN: llc -mtriple=hexagon < %s | FileCheck %s
+
+target triple = "hexagon"
+
+; buildHvxVectorReg packs i8 elements into i32 words before initializing an
+; HVX vector from the most frequent word. That initialization must use a word
+; splat even though the final vector type is i8; a byte splat would broadcast
+; only the low byte of %x.
+define void @splat_i32_word_into_i8_vector(ptr %out, i32 %x, i8 %y) #0 {
+; CHECK-LABEL: splat_i32_word_into_i8_vector:
+; CHECK: v{{[0-9]+}} = vsplat(r{{[0-9]+}})
+; CHECK-NOT: .b = vsplat
+; CHECK: vmem
+entry:
+  %x0 = trunc i32 %x to i8
+  %s1 = lshr i32 %x, 8
+  %x1 = trunc i32 %s1 to i8
+  %s2 = lshr i32 %x, 16
+  %x2 = trunc i32 %s2 to i8
+  %s3 = lshr i32 %x, 24
+  %x3 = trunc i32 %s3 to i8
+
+  %v00 = insertelement <64 x i8> undef, i8 %x0, i32 0
----------------
iajbar wrote:

Please replace undef with poison

https://github.com/llvm/llvm-project/pull/204808


More information about the llvm-commits mailing list