https://github.com/jayfoad created 
https://github.com/llvm/llvm-project/pull/242332

When inserting an element into the low half of an undefined LASX vector,
the insert is done on the low 128 bits and the result was widened with
SUBREG_TO_REG. That means that the instruction defining the low 128 bits
also defined the upper 128 bits, which is not the case. Insert the result
into the undefined source vector with INSERT_SUBREG instead, which keeps
its upper 128 bits undefined.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---

<sub>Stack created with <a href="https://github.com/github/gh-stack";>GitHub 
Stacks CLI</a> • <a href="https://gh.io/stacks-feedback";>Give Feedback 
💬</a></sub>

>From 79bb30d46d9f5eb98549a6c2f3a72085fe8c2b08 Mon Sep 17 00:00:00 2001
From: Jay Foad <[email protected]>
Date: Fri, 13 Nov 2026 13:48:15 +0000
Subject: [PATCH] [LoongArch] Use INSERT_SUBREG for PseudoXVINSGR2VR into an
 undefined vector. NFC

When inserting an element into the low half of an undefined LASX vector,
the insert is done on the low 128 bits and the result was widened with
SUBREG_TO_REG. That means that the instruction defining the low 128 bits
also defined the upper 128 bits, which is not the case. Insert the result
into the undefined source vector with INSERT_SUBREG instead, which keeps
its upper 128 bits undefined.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp 
b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 81172881d6aba..b16486614dc18 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -9539,7 +9539,8 @@ emitPseudoXVINSGR2VR(MachineInstr &MI, MachineBasicBlock 
*BB,
         .addReg(Elt)
         .addImm(Idx);
 
-    BuildMI(*BB, MI, DL, TII->get(LoongArch::SUBREG_TO_REG), XDst)
+    BuildMI(*BB, MI, DL, TII->get(LoongArch::INSERT_SUBREG), XDst)
+        .addReg(XSrc)
         .addReg(ScratchSubReg2)
         .addImm(LoongArch::sub_128);
   } else {

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to