[llvm] Fold SVE mul and mul_u to neg during isel (PR #160828)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 07:07:04 PDT 2025
================
@@ -723,6 +723,19 @@ class SVE2p1_Cvt_VG2_Pat<string name, SDPatternOperator intrinsic, ValueType out
: Pat<(out_vt (intrinsic in_vt:$Zn1, in_vt:$Zn2)),
(!cast<Instruction>(name) (REG_SEQUENCE ZPR2Mul2, in_vt:$Zn1, zsub0, in_vt:$Zn2, zsub1))>;
+class SVE_2_Op_Neg_One_Passthru_Pat<ValueType vt, SDPatternOperator op, ValueType pt,
+ Instruction inst, ValueType immT>
+: Pat<(vt (op pt:$Op1, vt:$Op2, (vt (splat_vector (immT -1))))),
+ (inst $Op2, $Op1, $Op2)>;
+
+// Same as above, but commutative
+multiclass SVE_2_Op_Neg_One_Passthru_Pat_Comm<ValueType vt, SDPatternOperator op, ValueType pt,
+ Instruction inst, ValueType immT> {
+def : Pat<(vt (op pt:$Op1, vt:$Op2, (vt (splat_vector (immT -1))))),
+ (inst $Op2, $Op1, $Op2)>;
+def : Pat<(vt (op pt:$Op1, (vt (splat_vector (immT -1))), vt:$Op2)),
+ (inst $Op2, $Op1, $Op2)>;
+}
----------------
paulwalker-arm wrote:
Is this required? I'd expect constants to be canonicalised to the RHS. `sve-intrinsic-simplify-binop.ll` has a test for this, see `commute_constant_to_rhs`.
https://github.com/llvm/llvm-project/pull/160828
More information about the llvm-commits
mailing list