From: Roman Lebedev Date: Wed, 11 Sep 2019 15:28:03 +0000 (+0000) Subject: [NFC][InstSimplify] Add extra test for D67411 with @llvm.assume X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=885030558ad8431655e5c9d127e6729ae73aa66b;p=llvm [NFC][InstSimplify] Add extra test for D67411 with @llvm.assume git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371629 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll b/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll index 5f59976db0e..8fb32e11513 100644 --- a/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll +++ b/test/Transforms/InstSimplify/redundant-null-check-in-uadd_with_overflow-of-nonnull-ptr.ll @@ -244,3 +244,24 @@ define i1 @t15(i8* nonnull %base, i64 %offset) { %res = and i1 %no_overflow_during_adjustment, %non_null_after_adjustment ; swapped ret i1 %res } + +declare void @llvm.assume(i1) +define i1 @t16(i64 %base, i64 %offset) { +; CHECK-LABEL: @t16( +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[BASE:%.*]], 0 +; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) +; CHECK-NEXT: [[ADJUSTED:%.*]] = add i64 [[BASE]], [[OFFSET:%.*]] +; CHECK-NEXT: [[NON_NULL_AFTER_ADJUSTMENT:%.*]] = icmp ne i64 [[ADJUSTED]], 0 +; CHECK-NEXT: [[NO_OVERFLOW_DURING_ADJUSTMENT:%.*]] = icmp uge i64 [[ADJUSTED]], [[BASE]] +; CHECK-NEXT: [[RES:%.*]] = and i1 [[NON_NULL_AFTER_ADJUSTMENT]], [[NO_OVERFLOW_DURING_ADJUSTMENT]] +; CHECK-NEXT: ret i1 [[RES]] +; + %cmp = icmp slt i64 %base, 0 + call void @llvm.assume(i1 %cmp) + + %adjusted = add i64 %base, %offset + %non_null_after_adjustment = icmp ne i64 %adjusted, 0 + %no_overflow_during_adjustment = icmp uge i64 %adjusted, %base + %res = and i1 %non_null_after_adjustment, %no_overflow_during_adjustment + ret i1 %res +}