[llvm] [PowerPC] Implement vector uncompress instructions (PR #150702)

Lei Huang via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 12:00:01 PDT 2025


https://github.com/lei137 updated https://github.com/llvm/llvm-project/pull/150702

>From 945400da66e8aee143111553f8efa24910239e9a Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 25 Jul 2025 17:52:11 +0000
Subject: [PATCH 1/2] Implement vector uncompress instructions

---
 llvm/lib/Target/PowerPC/PPCInstrFuture.td     | 33 +++++++++++++++++++
 .../PowerPC/ppc-encoding-ISAFuture.txt        | 18 ++++++++++
 .../PowerPC/ppc64le-encoding-ISAFuture.txt    | 18 ++++++++++
 llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s | 24 ++++++++++++++
 4 files changed, 93 insertions(+)

diff --git a/llvm/lib/Target/PowerPC/PPCInstrFuture.td b/llvm/lib/Target/PowerPC/PPCInstrFuture.td
index e8a4e52780e80..6918357241e4d 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrFuture.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrFuture.td
@@ -106,6 +106,21 @@ class VXForm_VRTB5_UIM3<bits<11> xo, bits<2> R, dag OOL, dag IOL, string asmstr,
   let Inst{21 -31} = xo;
 }
 
+class VXForm_VRTAB5<bits<11> xo, dag OOL, dag IOL, string asmstr,
+                    list<dag> pattern> : I<4, OOL, IOL, asmstr, NoItinerary> {
+  bits<5> VRT;
+  bits<5> VRA;
+  bits<5> VRB;
+
+  let Pattern = pattern;
+
+  let Inst{6 -10} = VRT;
+  let Inst{11 -15} = VRA;
+  let Inst{16 -20} = VRB;
+  let Inst{21 -31} = xo;
+}
+
+
 let Predicates = [IsISAFuture] in {
   defm SUBFUS : XOForm_RTAB5_L1r<31, 72, (outs g8rc:$RT),
                                  (ins g8rc:$RA, g8rc:$RB, u1imm:$L),
@@ -143,6 +158,7 @@ let Predicates = [HasVSX, IsISAFuture] in {
                                    "stxvprll $XTp, $addr, $RB", IIC_LdStLFD, []>;
   }
 
+
   def VUPKHSNTOB : VXForm_VRTB5<387, 0, (outs vrrc:$VRT), (ins vrrc:$VRB),
                                 "vupkhsntob $VRT, $VRB", []>;
   def VUPKLSNTOB : VXForm_VRTB5<387, 1, (outs vrrc:$VRT), (ins vrrc:$VRB),
@@ -159,4 +175,21 @@ let Predicates = [HasVSX, IsISAFuture] in {
   def VUPKINT4TOFP32
       : VXForm_VRTB5_UIM3<387, 2, (outs vrrc:$VRT), (ins vrrc:$VRB, u3imm:$UIM),
                           "vupkint4tofp32 $VRT, $VRB, $UIM", []>;
+
+  def VUCMPRHN : VXForm_VRTAB5<3, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                               "vucmprhn $VRT, $VRA, $VRB", []>;
+  def VUCMPRLN : VXForm_VRTAB5<67, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                               "vucmprln $VRT, $VRA, $VRB", []>;
+  def VUCMPRHB
+      : VXForm_VRTAB5<131, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                      "vucmprhb $VRT, $VRA, $VRB", []>;
+  def VUCMPRLB
+      : VXForm_VRTAB5<195, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                      "vucmprlb $VRT, $VRA, $VRB", []>;
+  def VUCMPRHH
+      : VXForm_VRTAB5<259, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                      "vucmprhh $VRT, $VRA, $VRB", []>;
+  def VUCMPRLH
+      : VXForm_VRTAB5<323, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
+                      "vucmprlh $VRT, $VRA, $VRB", []>;
 }
diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt
index 6adaa5cfdaefc..da3601b00b199 100644
--- a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt
+++ b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt
@@ -213,3 +213,21 @@
 
 #CHECK: vupkint8tofp32 3, 5, 2
 0x10,0x6e,0x29,0x83
+
+#CHECK: vucmprhn 0, 2, 3
+0x10,0x02,0x18,0x03
+
+#CHECK: vucmprln 3, 5, 6
+0x10,0x65,0x30,0x43
+
+#CHECK: vucmprhb 1, 3, 6
+0x10,0x23,0x30,0x83
+
+#CHECK: vucmprlb 2, 4, 5
+0x10,0x44,0x28,0xC3
+
+#CHECK: vucmprlh 2, 4, 5
+0x10,0x44,0x29,0x43
+
+#CHECK: vucmprhh 1, 3, 6
+0x10,0x23,0x31,0x03
diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt
index 84f9bc8e67b60..66d05043301b6 100644
--- a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt
+++ b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt
@@ -207,3 +207,21 @@
 
 #CHECK: vupkint8tofp32 3, 5, 2
 0x83,0x29,0x6e,0x10
+
+#CHECK: vucmprhn 0, 2, 3
+0x03,0x18,0x02,0x10
+
+#CHECK: vucmprln 3, 5, 6
+0x43,0x30,0x65,0x10
+
+#CHECK: vucmprhb 1, 3, 6
+0x83,0x30,0x23,0x10
+
+#CHECK: vucmprlb 2, 4, 5
+0xC3,0x28,0x44,0x10
+
+#CHECK: vucmprlh 2, 4, 5
+0x43,0x29,0x44,0x10
+
+#CHECK: vucmprhh 1, 3, 6
+0x03,0x31,0x23,0x10
diff --git a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s
index 8316bbd9854ea..6ae7bd785773d 100644
--- a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s
+++ b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s
@@ -306,3 +306,27 @@
            vupkint8tofp32 3, 5, 2
 #CHECK-BE: vupkint8tofp32 3, 5, 2         # encoding: [0x10,0x6e,0x29,0x83]
 #CHECK-LE: vupkint8tofp32 3, 5, 2         # encoding: [0x83,0x29,0x6e,0x10]
+
+           vucmprhn 0, 2, 3
+#CHECK-BE: vucmprhn 0, 2, 3                # encoding: [0x10,0x02,0x18,0x03]
+#CHECK-LE: vucmprhn 0, 2, 3                # encoding: [0x03,0x18,0x02,0x10]
+
+           vucmprln 3, 5, 6
+#CHECK-BE: vucmprln 3, 5, 6                # encoding: [0x10,0x65,0x30,0x43]
+#CHECK-LE: vucmprln 3, 5, 6                # encoding: [0x43,0x30,0x65,0x10]
+
+           vucmprhb 1, 3, 6
+#CHECK-BE: vucmprhb 1, 3, 6                # encoding: [0x10,0x23,0x30,0x83]
+#CHECK-LE: vucmprhb 1, 3, 6                # encoding: [0x83,0x30,0x23,0x10]
+
+           vucmprlb 2, 4, 5
+#CHECK-BE: vucmprlb 2, 4, 5                # encoding: [0x10,0x44,0x28,0xc3]
+#CHECK-LE: vucmprlb 2, 4, 5                # encoding: [0xc3,0x28,0x44,0x10]
+
+           vucmprlh 2, 4, 5
+#CHECK-BE: vucmprlh 2, 4, 5               # encoding: [0x10,0x44,0x29,0x43]
+#CHECK-LE: vucmprlh 2, 4, 5               # encoding: [0x43,0x29,0x44,0x10]
+
+           vucmprhh 1, 3, 6
+#CHECK-BE: vucmprhh 1, 3, 6               # encoding: [0x10,0x23,0x31,0x03]
+#CHECK-LE: vucmprhh 1, 3, 6               # encoding: [0x03,0x31,0x23,0x10]

>From 3e26d2e75e2b54fa7e7a9c515d3181b2bf96b227 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Tue, 2 Sep 2025 18:59:48 +0000
Subject: [PATCH 2/2] remove extra spacing

---
 llvm/lib/Target/PowerPC/PPCInstrFuture.td | 2 --
 1 file changed, 2 deletions(-)

diff --git a/llvm/lib/Target/PowerPC/PPCInstrFuture.td b/llvm/lib/Target/PowerPC/PPCInstrFuture.td
index 6918357241e4d..7277e368f4202 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrFuture.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrFuture.td
@@ -120,7 +120,6 @@ class VXForm_VRTAB5<bits<11> xo, dag OOL, dag IOL, string asmstr,
   let Inst{21 -31} = xo;
 }
 
-
 let Predicates = [IsISAFuture] in {
   defm SUBFUS : XOForm_RTAB5_L1r<31, 72, (outs g8rc:$RT),
                                  (ins g8rc:$RA, g8rc:$RB, u1imm:$L),
@@ -158,7 +157,6 @@ let Predicates = [HasVSX, IsISAFuture] in {
                                    "stxvprll $XTp, $addr, $RB", IIC_LdStLFD, []>;
   }
 
-
   def VUPKHSNTOB : VXForm_VRTB5<387, 0, (outs vrrc:$VRT), (ins vrrc:$VRB),
                                 "vupkhsntob $VRT, $VRB", []>;
   def VUPKLSNTOB : VXForm_VRTB5<387, 1, (outs vrrc:$VRT), (ins vrrc:$VRB),



More information about the llvm-commits mailing list