From: Roman Lebedev Date: Thu, 13 Sep 2018 20:33:02 +0000 (+0000) Subject: [NFC][InstCombine] Test what happens if 'unefficient high bit check' pattern is on... X-Git-Tag: llvmorg-8.0.0-rc1~8771 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=083744852ab4a95ccde9fae49377583c181247d7;p=platform%2Fupstream%2Fllvm.git [NFC][InstCombine] Test what happens if 'unefficient high bit check' pattern is on both sides. Came up in https://reviews.llvm.org/D52001#1233827 While we don't do a good job here, we at least want to make sure that we don't have any inf-loops. llvm-svn: 342171 --- diff --git a/llvm/test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll b/llvm/test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll index 530cab6..a48198b 100644 --- a/llvm/test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll +++ b/llvm/test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll @@ -102,6 +102,22 @@ define i1 @c0(i8 %bits) { ret i1 %r } +; What if we have the same pattern on both sides? +define i1 @both(i8 %bits0, i8 %bits1) { +; CHECK-LABEL: @both( +; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[BITS0:%.*]] +; CHECK-NEXT: [[T2:%.*]] = shl i8 -1, [[BITS1:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp uge i8 [[T2]], [[T0]] +; CHECK-NEXT: ret i1 [[R]] +; + %t0 = shl i8 -1, %bits0 + %t1 = xor i8 %t0, -1 + %t2 = shl i8 -1, %bits1 + %t3 = xor i8 %t2, -1 + %r = icmp uge i8 %t1, %t3 + ret i1 %r +} + ; ============================================================================ ; ; One-use tests. ; ============================================================================ ; diff --git a/llvm/test/Transforms/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll b/llvm/test/Transforms/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll index 6c447a7..0757667 100644 --- a/llvm/test/Transforms/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll +++ b/llvm/test/Transforms/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll @@ -68,6 +68,20 @@ define i1 @c0(i8 %bits) { ret i1 %r } +; What if we have the same pattern on both sides? +define i1 @both(i8 %bits0, i8 %bits1) { +; CHECK-LABEL: @both( +; CHECK-NEXT: [[T1:%.*]] = shl i8 1, [[BITS1:%.*]] +; CHECK-NEXT: [[T1_HIGHBITS:%.*]] = lshr i8 [[T1]], [[BITS0:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[T1_HIGHBITS]], 0 +; CHECK-NEXT: ret i1 [[R]] +; + %t0 = shl i8 1, %bits0 + %t1 = shl i8 1, %bits1 + %r = icmp ugt i8 %t0, %t1 + ret i1 %r +} + ; ============================================================================ ; ; One-use tests. ; ============================================================================ ; diff --git a/llvm/test/Transforms/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll b/llvm/test/Transforms/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll index 4b57c5b..b9d0339 100644 --- a/llvm/test/Transforms/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll +++ b/llvm/test/Transforms/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll @@ -68,6 +68,20 @@ define i1 @c0(i8 %bits) { ret i1 %r } +; What if we have the same pattern on both sides? +define i1 @both(i8 %bits0, i8 %bits1) { +; CHECK-LABEL: @both( +; CHECK-NEXT: [[T1:%.*]] = shl i8 1, [[BITS1:%.*]] +; CHECK-NEXT: [[T1_HIGHBITS:%.*]] = lshr i8 [[T1]], [[BITS0:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[T1_HIGHBITS]], 0 +; CHECK-NEXT: ret i1 [[R]] +; + %t0 = shl i8 1, %bits0 + %t1 = shl i8 1, %bits1 + %r = icmp ule i8 %t0, %t1 + ret i1 %r +} + ; ============================================================================ ; ; One-use tests. ; ============================================================================ ; diff --git a/llvm/test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll b/llvm/test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll index d6d7cce..d81d69e 100644 --- a/llvm/test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll +++ b/llvm/test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll @@ -102,6 +102,22 @@ define i1 @c0(i8 %bits) { ret i1 %r } +; What if we have the same pattern on both sides? +define i1 @both(i8 %bits0, i8 %bits1) { +; CHECK-LABEL: @both( +; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[BITS0:%.*]] +; CHECK-NEXT: [[T2:%.*]] = shl i8 -1, [[BITS1:%.*]] +; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T2]], [[T0]] +; CHECK-NEXT: ret i1 [[R]] +; + %t0 = shl i8 -1, %bits0 + %t1 = xor i8 %t0, -1 + %t2 = shl i8 -1, %bits1 + %t3 = xor i8 %t2, -1 + %r = icmp ult i8 %t1, %t3 + ret i1 %r +} + ; ============================================================================ ; ; One-use tests. ; ============================================================================ ;