[clang] [llvm] [RISCV][P-ext] Support Packed Absolute Value and Absolute Difference (PR #203840)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 15 08:08:44 PDT 2026


================
@@ -92,6 +92,18 @@ typedef uint32_t uint32x2_t __attribute__((__vector_size__(8)));
     return (rty)(__rs1 op __rs2);                                              \
   }
 
+#define __packed_pabs(name, ty, rty)                                           \
+  static __inline__ rty __DEFAULT_FN_ATTRS __riscv_##name(ty __rs1) {          \
+    return (rty)__builtin_elementwise_abs(__rs1);                              \
+  }
+
+#define __packed_pabd(name, ty, rty)                                           \
+  static __inline__ rty __DEFAULT_FN_ATTRS __riscv_##name(ty __rs1,            \
+                                                          ty __rs2) {          \
+    return (rty)(__builtin_elementwise_max(__rs1, __rs2) -                     \
----------------
topperc wrote:

I think we should use an intrinsic for this. Using a pattern can be broken by other optimizations making the intrinsic not produce the correct instruction.

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


More information about the cfe-commits mailing list