diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-11-01 14:03:22 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-01 14:03:22 +0000 |
| commit | 056807b01ec5c930b945a91984cb551fc8f6a6d1 (patch) | |
| tree | e660aec44e1fe88ae8b954d1b3ebe67f3959d51f /llvm/test/Transforms/InstSimplify | |
| parent | b9c840c9f0781fdfa92a5edbe33868e81464d557 (diff) | |
| download | bcm5719-llvm-056807b01ec5c930b945a91984cb551fc8f6a6d1.tar.gz bcm5719-llvm-056807b01ec5c930b945a91984cb551fc8f6a6d1.zip | |
[InstSimplify] add tests for icmp fold bug (PR39510); NFC
Verify that set intersection/subset are not confused.
llvm-svn: 345831
Diffstat (limited to 'llvm/test/Transforms/InstSimplify')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/icmp-abs-nabs.ll | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/icmp-abs-nabs.ll b/llvm/test/Transforms/InstSimplify/icmp-abs-nabs.ll index 1cb312bf0da..c2e24de885f 100644 --- a/llvm/test/Transforms/InstSimplify/icmp-abs-nabs.ll +++ b/llvm/test/Transforms/InstSimplify/icmp-abs-nabs.ll @@ -399,3 +399,38 @@ define <3 x i1> @nabs_is_not_over_0_sle_vec_splat(<3 x i33> %x) { ret <3 x i1> %r } +; Negative test - intersection does not equal absolute value range. +; PR39510 - https://bugs.llvm.org/show_bug.cgi?id=39510 + +define i1 @abs_no_intersection(i32 %a) { +; CHECK-LABEL: @abs_no_intersection( +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A:%.*]], 0 +; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[A]] +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[A]] +; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[COND]], 2 +; CHECK-NEXT: ret i1 [[R]] +; + %cmp = icmp slt i32 %a, 0 + %sub = sub nsw i32 0, %a + %cond = select i1 %cmp, i32 %sub, i32 %a + %r = icmp ne i32 %cond, 2 + ret i1 %r +} + +; Negative test - intersection does not equal absolute value range. + +define i1 @nabs_no_intersection(i32 %a) { +; CHECK-LABEL: @nabs_no_intersection( +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A:%.*]], 0 +; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A]] +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[A]] +; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[COND]], -2 +; CHECK-NEXT: ret i1 [[R]] +; + %cmp = icmp sgt i32 %a, 0 + %sub = sub i32 0, %a + %cond = select i1 %cmp, i32 %sub, i32 %a + %r = icmp ne i32 %cond, -2 + ret i1 %r +} + |

