[PATCH] D79452: [VectorCombine] scalarize binop of inserted elements into undef
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 00:30:13 PDT 2020
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Seems fairly uncontroversial to me.
================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:320
+ Value *V0, *V1;
+ uint64_t Index;
+ if (!match(Ins0, m_OneUse(m_InsertElement(m_Undef(), m_Value(V0),
----------------
Hm, do we have an interface to ask for cost of `InsertElement` with variable insert index?
================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:340-341
+ int OldCost = InsertCost + InsertCost + VectorOpCost;
+ int NewCost = ScalarOpCost + InsertCost;
+ if (OldCost < NewCost)
+ return false;
----------------
`// We want to scalarize unless vector variant actually has lower cost`
================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:357
+ Value *Insert =
+ Builder.CreateInsertElement(UndefValue::get(VecTy), ScalarBO, Index);
+ I.replaceAllUsesWith(Insert);
----------------
This should retain the name from `I`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79452/new/
https://reviews.llvm.org/D79452
More information about the llvm-commits
mailing list