[clang] [llvm] [PowerPC] Add builtins for Post Quantum Cryptography Acceleration (PR #184717)

Lei Huang via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 08:57:41 PDT 2026


================
@@ -612,6 +612,34 @@ let Predicates = [HasFutureVector] in {
                                                      v4i32:$vB))>;
 }
 
+// Post Quantum Cryptography Acceleration patterns.
+// Use AddedComplexity to prefer these patterns over AltiVec patterns.
+let Predicates = [HasFutureVector], AddedComplexity = 400 in {
+  // Vector add
+  def : Pat<(v4i32 (add v4i32:$XA, v4i32:$XB)), (v4i32 (XVADDUWM $XA, $XB))>;
+  def : Pat<(v8i16 (add v8i16:$XA, v8i16:$XB)),
+            (COPY_TO_REGCLASS (XVADDUHM RCCp.AToVSRC, RCCp.BToVSRC), VSRC)>;
+  // Vector subtract
+  // Don't have a VSX negate instruction so use VNEGW instead.
+  def : Pat<(v4i32 (sub (v4i32 immAllZerosV), v4i32:$vB)), (v4i32 (VNEGW $vB))>;
----------------
lei137 wrote:

Actually I made a mistake.  This is needed here to override other priority setup patterns.    Test affected: test/CodeGen/PowerPC/funnel-shift-rot.ll

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


More information about the cfe-commits mailing list