• Simon Pilgrim's avatar
    [TTI] Add DemandedElts to getScalarizationOverhead · 090cae84
    Simon Pilgrim authored
    The improvements to the x86 vector insert/extract element costs in D74976 resulted in the estimated costs for vector initialization and scalarization increasing higher than should be expected. This is particularly noticeable on pre-SSE4 targets where the available of legal INSERT_VECTOR_ELT ops is more limited.
    This patch does 2 things:
    1 - it implements X86TTIImpl::getScalarizationOverhead to more accurately represent the typical costs of a ISD::BUILD_VECTOR pattern.
    2 - it adds a DemandedElts mask to getScalarizationOverhead to permit the SLP's BoUpSLP::getGatherCost to be rewritten to use it directly instead of accumulating raw vector insertion costs.
    This fixes PR45418 where a v4i8 (zext'd to v4i32) was no longer vectorizing.
    A future patch should extend X86TTIImpl::getScalarizationOverhead to tweak the EXTRACT_VECTOR_ELT scalarization costs as well.
    Reviewed By: @craig.topper
    Differential Revision: https://reviews.llvm.org/D78216