[PATCH] D42574: [ARM] Lower lower saturate to 0 and lower saturate to -1 using bit-operations

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 31 15:00:26 PST 2018


eugenis added a comment.

I've reverted your commit in r323929.
It miscompiles the following program on armv7-linux-android:
#include <stdio.h>

typedef unsigned long long u64;
typedef signed long long s64;
s64 f(u64 x) {

  return (x > (u64)0x7fffffffffffffffULL) ? (s64)1 : -(s64)x;

}

int main() {

  volatile u64 x = 42;
  s64 y = f(x);
  printf("%lld\n", y);

}

Without this patch, the output is -42.
With your patch, the output is 4294967254.

It also breaks the android bot:

  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/7279


Repository:
  rL LLVM

https://reviews.llvm.org/D42574





More information about the llvm-commits mailing list