]> granicus.if.org Git - llvm/commit
[X86] Add pattern matching for PMADDUBSW
authorCraig Topper <craig.topper@intel.com>
Tue, 31 Jul 2018 17:12:08 +0000 (17:12 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 31 Jul 2018 17:12:08 +0000 (17:12 +0000)
commitbc59a99d64ab73ece92129b069b77a72d87607a6
tree455e5c00d130cc9c31bc2cc5b3f1546c256f8ea4
parentf8da0e7688c207464d917db772503a675a5d05a9
[X86] Add pattern matching for PMADDUBSW

Summary:
Similar to D49636, but for PMADDUBSW. This instruction has the additional complexity that the addition of the two products saturates to 16-bits rather than wrapping around. And one operand is treated as signed and the other as unsigned.

A C example that triggers this pattern

```
static const int N = 128;

int8_t A[2*N];
uint8_t B[2*N];
int16_t C[N];

void foo() {
  for (int i = 0; i != N; ++i)
    C[i] = MIN(MAX((int16_t)A[2*i]*(int16_t)B[2*i] + (int16_t)A[2*i+1]*(int16_t)B[2*i+1], -32768), 32767);
}
```

Reviewers: RKSimon, spatel, zvi

Reviewed By: RKSimon, zvi

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D49829

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338402 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/pmaddubsw.ll