[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 2 Sep 2021 15:46:58 +0000 (16:46 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 2 Sep 2021 16:36:22 +0000 (17:36 +0100)
commitd66d520fe11c4298169e64515c853d805a3f7ab5
tree630d377db79bd86eb51393b030709e2b72f557ec
parente5438f386854136d848989315f53788808afa37a
[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper bits

PMADDWD(v8i16 x, v8i16 y) == (v4i32) { (int)x[0]*y[0] + (int)x[1]*y[1], ..., (int)x[6]*y[6] + (int)x[7]*y[7] }

Currently combineMulToPMADDWD only folds cases where the upper 17 bits of both vXi32 inputs are known zero (i.e. the first half is positive and the second half of the pair is zero in each 2xi16 pair), this can be relaxed to only require one zero-extended input if the other input has at least 17 sign bits.

That way the sign of the result is still preserved, and the second half is still zero.

Noticed while investigating PR47437.

Differential Revision: https://reviews.llvm.org/D108522
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/madd.ll
llvm/test/CodeGen/X86/pmaddubsw.ll
llvm/test/CodeGen/X86/shrink_vmul.ll