[llvm] [X86] optimize ssse3 horizontal saturating add/sub (PR #169591)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 02:32:04 PST 2025


================
@@ -4949,6 +4949,12 @@ defm PMULHRSW    : SS3I_binop_rm<0x0B, "pmulhrsw", X86mulhrs, v8i16, v8i16,
                                  VR128, memop, i128mem, SchedWriteVecIMul.XMM>;
 }
 
+def : Pat<(v8i16 (X86hadds VR128:$src1, VR128:$src2)),
+          (PHADDSWrr VR128:$src1, VR128:$src2)>;
+
+def : Pat<(v8i16 (X86hsubs VR128:$src1, VR128:$src2)),
+          (PHSUBSWrr VR128:$src1, VR128:$src2)>;
+
----------------
phoebewang wrote:

Traditionally, we define the patten together with the instruction. You can move the intrinsic map to the `IntrinsicsWithoutChain` in X86IntrinsicsInfo.h

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


More information about the llvm-commits mailing list