Go to file
Zvi Rackover c1d5955684 [X86] Unsigned saturation subtraction canonicalization [the backend part]
Summary:
On behalf of julia.koval@intel.com

The patch transforms canonical version of unsigned saturation, which is sub(max(a,b),a) or sub(a,min(a,b)) to special psubus insturuction on targets, which support it(8bit and 16bit uints).
umax(a,b) - b -> subus(a,b)
a - umin(a,b) -> subus(a,b)

There is also extra case handled, when right part of sub is 32 bit and can be truncated, using UMIN(this transformation was discussed in https://reviews.llvm.org/D25987).

The example of special case code:

```
void foo(unsigned short *p, int max, int n) {

  int i;
  unsigned m;
  for (i = 0; i < n; i++) {
    m = *--p;
    *p = (unsigned short)(m >= max ? m-max : 0);
  }
}
```
Max in this example is truncated to max_short value, if it is greater than m, or just truncated to 16 bit, if it is not. It is vaid transformation, because if max > max_short, result of the expression will be zero.

Here is the table of types, I try to support, special case items are bold:

| Size | 128 | 256 | 512
| -----  | -----  | -----   | -----
| i8 | v16i8 | v32i8 | v64i8
| i16 | v8i16 | v16i16 | v32i16
| i32 | | **v8i32** | **v16i32**
| i64 | | | **v8i64**

Reviewers: zvi, spatel, DavidKreitzer, RKSimon

Reviewed By: zvi

Subscribers: llvm-commits

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

llvm-svn: 315237
2017-10-09 20:01:10 +00:00
clang PR13575: Fix USR mangling for fixed-size arrays 2017-10-09 19:51:33 +00:00
clang-tools-extra [clangd] Added a command-line arg to mirror clangd input into a file. 2017-10-09 16:58:16 +00:00
compiler-rt [sanitizer] Don't intercept signal and sigaction on Fuchsia 2017-10-09 18:29:52 +00:00
debuginfo-tests Revert r313600 due to bot failures on Green Dragon. 2017-09-19 14:51:37 +00:00
libclc Implement mem_fence on ptx 2017-10-09 19:43:04 +00:00
libcxx [libc++] Support Microsoft ABI without vcruntime headers 2017-10-09 19:25:17 +00:00
libcxxabi Fix ASAN build with older compiler-rt versions. 2017-09-14 22:37:34 +00:00
libunwind [docs] Mention that SjLj works on any OS on the archs where supported by the compiler 2017-10-06 19:14:07 +00:00
lld Rename ignoreInterpSection -> needsInterpSection. 2017-10-08 03:52:15 +00:00
lldb Update ABISysV_arm64::RegisterIsVolatile to accept registers prefixed with r 2017-10-09 17:49:32 +00:00
llgo irgen: Create functions instead of global variables for builtin hash and equal algorithms. 2017-06-04 22:11:28 +00:00
llvm [X86] Unsigned saturation subtraction canonicalization [the backend part] 2017-10-09 20:01:10 +00:00
openmp KMP_HW_SUBSET vs KMP_PLACE_THREADS rival envirables fix 2017-10-06 19:23:19 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly [ScopBuilder] Introduce -polly-stmt-granularity=scalar-indep option. 2017-10-05 13:43:00 +00:00