[SLP] Add support for commutative icmp/fcmp predicates
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 29 Mar 2019 15:28:25 +0000 (15:28 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 29 Mar 2019 15:28:25 +0000 (15:28 +0000)
commit6a75c36ea9bd2bbc8b58fa8732a843477a5fbd69
treeca6ec5c87f9adcf41bd5c4c1e67b4d7ed1982463
parent8da6a6cec31f287a98362cbd097394b1e2dead20
[SLP] Add support for commutative icmp/fcmp predicates

For the cases where the icmp/fcmp predicate is commutative, use reorderInputsAccordingToOpcode to collect and commute the operands.

This requires a helper to recognise commutativity in both general Instruction and CmpInstr types - the CmpInst::isCommutative doesn't overload the Instruction::isCommutative method for reasons I'm not clear on (maybe because its based on predicate not opcode?!?).

Differential Revision: https://reviews.llvm.org/D59992

llvm-svn: 357266
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/cmp_commute.ll