[X86] combineMulToPMADDWD - replace ASHR(X,16) -> LSHR(X,16)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 18 Oct 2021 21:12:47 +0000 (22:12 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 18 Oct 2021 21:12:56 +0000 (22:12 +0100)
commita83384498bee076aca07cc88b726e6bd51926e6f
tree63a90424ed4f1f1adbc5c8a3a569a2619b8f4f85
parent7cf1fef45f13991e2d3b97e0612cfb88bf906a50
[X86] combineMulToPMADDWD - replace ASHR(X,16) -> LSHR(X,16)

If we're using an ashr to sign-extend the entire upper 16 bits of the i32 element, then we can replace with a lshr. The sign bit will be correctly shifted for PMADDWD's implicit sign-extension and the upper 16 bits are zero so the upper i16 sext-multiply is guaranteed to be zero.

The lshr also has a better chance of folding with shuffles etc.
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/pmulh.ll