[PATCH] D75062: [VectorCombine] make cost calc consistent for binops and cmps

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 10:02:57 PST 2020


spatel created this revision.
spatel added reviewers: lebedev.ri, efriedma, RKSimon.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

Code duplication (subsequently removed by refactoring) allowed a logic discrepancy to creep in here.

We were being conservative about creating a vector binop -- but not a vector cmp -- in the case where a vector op has the same estimated cost as the scalar op. We want to be more aggressive here because that can allow other combines based on reduced instruction count/uses.

We have the reverse transform with target hook in DAGCombiner already -- scalarizeExtractedBinop() -- so that provides a later opportunity to invert (potentially with a more accurate cost model).

AFAIK, this does not conflict with InstCombine. We have a scalarize transform there, but it relies on finding a constant operand or a matching insertelement, so that means it eliminates an extractelement from the sequence (so we won't have 2 extracts by the time we get here if InstCombine succeeds).


https://reviews.llvm.org/D75062

Files:
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/test/Transforms/VectorCombine/X86/extract-binop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75062.246237.patch
Type: text/x-patch
Size: 5326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200224/d98d04d6/attachment.bin>


More information about the llvm-commits mailing list