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
Not sure why these three are special either... from a brief look at the commit, I would guess it was done to mirror the integer transforms, without any real consideration for what should be canonical.
If I were doing it from scratch, I might say we should consider ordered predicates canonical, since they're the ones people are used to working with.