[VectorCombine] scalarizeBinop - support an all-constant src vector operand
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 9 Jun 2020 17:36:14 +0000 (18:36 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 9 Jun 2020 18:02:05 +0000 (19:02 +0100)
commit5dc4e7c2b95fc665c1dc86c6b40cf02171f8801d
treecebab77093ca3bcaa682431c09bb6cc230fc1d8b
parentbc38793852c0552337bae54961eb14fb0bacf356
[VectorCombine] scalarizeBinop - support an all-constant src vector operand

scalarizeBinop currently folds

  vec_bo((inselt VecC0, V0, Index), (inselt VecC1, V1, Index))
  ->
  inselt(vec_bo(VecC0, VecC1), scl_bo(V0,V1), Index)

This patch extends this to account for cases where one of the vec_bo operands is already all-constant and performs similar cost checks to determine if the scalar binop with a constant still makes sense:

  vec_bo((inselt VecC0, V0, Index), VecC1)
  ->
  inselt(vec_bo(VecC0, VecC1), scl_bo(V0,extractelt(V1,Index)), Index)

Fixes PR42174

Differential Revision: https://reviews.llvm.org/D80885
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll
llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll