> 2. When I write if (a == 2) and if (2 == a), the results are > same > > 3. The vec_duplicate operand is the 5th operand in both cmp and > eqne patterns. I think they are equal.
A comparison with a constant is always canonicalized to have the constant second, that's why you won't see a difference. A vector constant follows the same rule because swap_commutative_operands_p will place it second. I'm not sure whether we need the vec_duplicate first, honestly. I don't remember a canonicalization rule that puts it there. We do have something for constants and vec_merge. As long as things come from expand I think a constant will always be second and this patch removes the patterns where the duplicate is first. Generally with fast math we could invert the condition so a comparison should be "commutative". With NaNs I think we also allow it if the unordered comparisons are supported. But I'm not even certain that we try something like that with vectors. On the other hand - as there is no canonical order nothing would prevent it from being first in the future? Will need to think about it some more (and try with NaNs) but we could give try removing the patterns with GCC15 I suppose. The rest should still be handled in a more generic fashion. Regards Robin