Make main/alternate operation selection logic for CmpInst consistent across SLP vectorizer.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
5876 | !*IsMain? |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
5876 | Nope. The intent is check the optional does not have a value. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | Why did you removed this check? I believe it might help to build some nodes, though terminating with gathers. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | IMO, it is redundant ( i.e. removing it is no-op) Confusion probably comes from returning value of isCmpSameOrSwapped() routine. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | It will be covered if ops are compatible, if they are incompatible, isCmpSameOrSwapped returns None and the functions returns InstructionsState(VL[BaseIndex], nullptr, nullptr);, saying that it is a gather sequence. But we can build a vector node even if there are no compatible operands, the operands will form the gather-based nodes instead. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | I see what you mean. we make a call to areCompatibleCmpOps and then simply ignore it here. Right? |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | Thinking of another possible alternative: current behavior should be retained without sacrificing consistency. We can make isCmpSameOrSwapped to return an optional enum instead: MatchWithOperands - corresponds to current "true" in buildTree_rec () we then also check for SwappedPredicateMatch in order to swap LHS/RHS. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | You don’t need to make it optimal then, just add another enum value. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
582–586 | Agree. But that is a minor detail. |
LG with a nit
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
492 | "swapped, false otherwise." |
"swapped, false otherwise."