This adds the most basic form of predicated add and sub patterns, selecting from vselect(m, add(x, y), x).
Details
Diff Detail
Event Timeline
I'm tempted to suggest this is better done as a canonicalisation via DAGCombine? Otherwise we then have to start duplicating other instances of these patterns, for example within mla/mls patfrags.
With (add node:$op1, (vselect node:$pred, node:$op2, (SVEDup0))) having one less use of op1 than (vselect node:$pred, (add node:$op1, node:$op2), node:$op1), such a canonicalisation might have other benefits where combines/patterns are guarded by hasOneUse().
Hello. Yes, that was actually the plan, but the other way around. There is a function that can canonicalize in the DAG through shouldFoldSelectWithIdentityConstant, to the select(add) form. Instcombine will fold the other way to add(select(..)). See d321f3aa64b4eaedd790dafe974cfdc0517cb22b for example. It is probably simpler to go via that method than dealing with the identity values for all node types (especially fp types). The predicated instructions are not as general in SVE as they are in MVE (MVE doesn't require destructive operands for many operations), but I think it should be better in general so long as there can always use predicated moves. I have patches for that and some other operations like and/or/xor/mul/mla/mls, but they needed some extra tests.
I will put the last part up now, that enables shouldFoldSelectWithIdentityConstant for SVE. There is one case that looks a little worse, but has a pair of selects that could be simplified.
If you shuffle your patches can this use VSelectCommPredOrPassthruPatFrags?