From e2796a6d063d3c16db1892ae2a7d803e90779151 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 8 Oct 2019 20:29:36 +0000 Subject: [PATCH] [CVP][NFC] Revisit sext vs. zext test git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374111 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../CorrelatedValuePropagation/sext.ll | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/test/Transforms/CorrelatedValuePropagation/sext.ll b/test/Transforms/CorrelatedValuePropagation/sext.ll index 57227a0cb93..4df52b28b0d 100644 --- a/test/Transforms/CorrelatedValuePropagation/sext.ll +++ b/test/Transforms/CorrelatedValuePropagation/sext.ll @@ -15,7 +15,7 @@ define void @test1(i32 %n) { ; CHECK-NEXT: br label [[FOR_COND:%.*]] ; CHECK: for.cond: ; CHECK-NEXT: [[A:%.*]] = phi i32 [ [[N:%.*]], [[ENTRY:%.*]] ], [ [[EXT:%.*]], [[FOR_BODY:%.*]] ] -; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A]], 1 +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A]], -1 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]] ; CHECK: for.body: ; CHECK-NEXT: [[EXT_WIDE:%.*]] = sext i32 [[A]] to i64 @@ -30,7 +30,7 @@ entry: for.cond: ; preds = %for.body, %entry %a = phi i32 [ %n, %entry ], [ %ext, %for.body ] - %cmp = icmp sgt i32 %a, 1 + %cmp = icmp sgt i32 %a, -1 br i1 %cmp, label %for.body, label %for.end for.body: ; preds = %for.cond @@ -43,7 +43,7 @@ for.end: ; preds = %for.cond ret void } -;; Negative test to show transform doesn't happen unless n > 0. +;; Negative test to show transform doesn't happen unless n >= 0. define void @test2(i32 %n) { ; CHECK-LABEL: @test2( ; CHECK-NEXT: entry: @@ -82,7 +82,7 @@ for.end: ; preds = %for.cond define void @test3(i32 %n) { ; CHECK-LABEL: @test3( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], 0 +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -1 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]] ; CHECK: bb: ; CHECK-NEXT: [[EXT_WIDE:%.*]] = sext i32 [[N]] to i64 @@ -93,7 +93,35 @@ define void @test3(i32 %n) { ; CHECK-NEXT: ret void ; entry: - %cmp = icmp sgt i32 %n, 0 + %cmp = icmp sgt i32 %n, -1 + br i1 %cmp, label %bb, label %exit + +bb: + %ext.wide = sext i32 %n to i64 + call void @use64(i64 %ext.wide) + %ext = trunc i64 %ext.wide to i32 + br label %exit + +exit: + ret void +} + +;; Non looping negative test case. +define void @test4(i32 %n) { +; CHECK-LABEL: @test4( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -2 +; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]] +; CHECK: bb: +; CHECK-NEXT: [[EXT_WIDE:%.*]] = sext i32 [[N]] to i64 +; CHECK-NEXT: call void @use64(i64 [[EXT_WIDE]]) +; CHECK-NEXT: [[EXT:%.*]] = trunc i64 [[EXT_WIDE]] to i32 +; CHECK-NEXT: br label [[EXIT]] +; CHECK: exit: +; CHECK-NEXT: ret void +; +entry: + %cmp = icmp sgt i32 %n, -2 br i1 %cmp, label %bb, label %exit bb: -- 2.40.0