There should be a slight efficiency improvement from handling icmp/fcmp with one matcher and reducing duplicated code.
The larger motivation is that there are questions about how predicate canonicalization is handled, and the refactoring should make it easier if we want to change any of that behavior.
I'll post those questions here for reference, but I expect we should answer these in follow-up patches and/or llvm-dev:
- As noted in the code comment, we've chosen 3 of the 16 FCMP preds as not canonical. Why those 3? It goes back to rL32751 from what I can tell, but I'm not sure if there's a justification for that rule.
- We currently do not canonicalize most select conditions. Should we use the same rule that applies to branches for selects?
- We currently do canonicalize some FP select conditions, and those rules would conflict with the rule shown here. Should one or both be changed? Canonicalize to use ordered comparisons by swapping the select operands. e.g. // (X ugt Y) ? X : Y -> (X ole Y) ? Y : X