diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-10-25 18:47:56 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-10-25 18:47:56 +0000 |
commit | 8f9235dd7fd0fea8d4a3122933fc1b91242d5e2c (patch) | |
tree | eb83d09f22fe1c6bbcb26de0440505a4d447270c | |
parent | e542804343ac52f40b2310eff4b3f1f045d5e5f4 (diff) | |
download | bcm5719-llvm-8f9235dd7fd0fea8d4a3122933fc1b91242d5e2c.tar.gz bcm5719-llvm-8f9235dd7fd0fea8d4a3122933fc1b91242d5e2c.zip |
[InstCombine] add tests for missing icmp + shl nuw fold
Patch by bryant!
Differential Revision: https://reviews.llvm.org/D25952
llvm-svn: 285095
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll b/llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll new file mode 100644 index 00000000000..d5a1b87565a --- /dev/null +++ b/llvm/test/Transforms/InstCombine/icmp-shl-nuw.ll @@ -0,0 +1,80 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt %s -instcombine -S | FileCheck %s + +define i1 @icmp_ugt_32(i64) { +; CHECK-LABEL: @icmp_ugt_32( +; CHECK-NEXT: [[C:%.*]] = shl nuw i64 %0, 32 +; CHECK-NEXT: [[D:%.*]] = icmp ugt i64 [[C]], 4294967295 +; CHECK-NEXT: ret i1 [[D]] +; + %c = shl nuw i64 %0, 32 + %d = icmp ugt i64 %c, 4294967295 + ret i1 %d +} + +define i1 @icmp_ule_64(i128) { +; CHECK-LABEL: @icmp_ule_64( +; CHECK-NEXT: [[TMP2:%.*]] = trunc i128 %0 to i64 +; CHECK-NEXT: [[D:%.*]] = icmp eq i64 [[TMP2]], 0 +; CHECK-NEXT: ret i1 [[D]] +; + %c = shl nuw i128 %0, 64 + %d = icmp ule i128 %c, 18446744073709551615 + ret i1 %d +} + +define i1 @icmp_ugt_16(i64) { +; CHECK-LABEL: @icmp_ugt_16( +; CHECK-NEXT: [[C:%.*]] = shl nuw i64 %0, 16 +; CHECK-NEXT: [[D:%.*]] = icmp ugt i64 [[C]], 1048575 +; CHECK-NEXT: ret i1 [[D]] +; + %c = shl nuw i64 %0, 16 + %d = icmp ugt i64 %c, 1048575 ; 0x0f_ffff + ret i1 %d +} + +; FIXME: InstCombine ought not to emit the potentially illegal i48. +define <2 x i1> @icmp_ule_16x2(<2 x i64>) { +; CHECK-LABEL: @icmp_ule_16x2( +; CHECK-NEXT: [[TMP2:%.*]] = trunc <2 x i64> %0 to <2 x i48> +; CHECK-NEXT: [[D:%.*]] = icmp eq <2 x i48> [[TMP2]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %c = shl nuw <2 x i64> %0, <i64 16, i64 16> + %d = icmp ule <2 x i64> %c, <i64 65535, i64 65535> + ret <2 x i1> %d +} + +define i1 @icmp_ult_8(i64) { +; CHECK-LABEL: @icmp_ult_8( +; CHECK-NEXT: [[C:%.*]] = shl nuw i64 %0, 8 +; CHECK-NEXT: [[D:%.*]] = icmp ult i64 [[C]], 4095 +; CHECK-NEXT: ret i1 [[D]] +; + %c = shl nuw i64 %0, 8 + %d = icmp ult i64 %c, 4095 ; 0x0fff + ret i1 %d +} + +define <2 x i1> @icmp_uge_8x2(<2 x i16>) { +; CHECK-LABEL: @icmp_uge_8x2( +; CHECK-NEXT: [[C:%.*]] = shl nuw <2 x i16> %0, <i16 8, i16 8> +; CHECK-NEXT: [[D:%.*]] = icmp ugt <2 x i16> [[C]], <i16 4094, i16 4094> +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %c = shl nuw <2 x i16> %0, <i16 8, i16 8> + %d = icmp uge <2 x i16> %c, <i16 4095, i16 4095> + ret <2 x i1> %d +} + +define <2 x i1> @icmp_ugt_16x2(<2 x i32>) { +; CHECK-LABEL: @icmp_ugt_16x2( +; CHECK-NEXT: [[C:%.*]] = shl nuw <2 x i32> %0, <i32 16, i32 16> +; CHECK-NEXT: [[D:%.*]] = icmp ugt <2 x i32> [[C]], <i32 1048575, i32 1048575> +; CHECK-NEXT: ret <2 x i1> [[D]] +; + %c = shl nuw <2 x i32> %0, <i32 16, i32 16> + %d = icmp ugt <2 x i32> %c, <i32 1048575, i32 1048575> + ret <2 x i1> %d +} |