From fa7e96864682f6dc94849cac28e7f7db528413ae Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 7 Feb 2025 11:59:55 +0000 Subject: [PATCH] SCEV: re-org a test, regen via UTC --- .../ScalarEvolution/infer-via-ranges.ll | 19 +++++-- .../IndVarSimplify/infer-via-ranges.ll | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 llvm/test/Transforms/IndVarSimplify/infer-via-ranges.ll diff --git a/llvm/test/Analysis/ScalarEvolution/infer-via-ranges.ll b/llvm/test/Analysis/ScalarEvolution/infer-via-ranges.ll index 9aa096b952be5..9cf3e06d58a88 100644 --- a/llvm/test/Analysis/ScalarEvolution/infer-via-ranges.ll +++ b/llvm/test/Analysis/ScalarEvolution/infer-via-ranges.ll @@ -1,22 +1,31 @@ -; RUN: opt -passes=indvars -S < %s | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -passes='print' \ +; RUN: -scalar-evolution-classify-expressions=0 -disable-output %s 2>&1 | FileCheck %s define void @infer_via_ranges(ptr %arr, i32 %n) { -; CHECK-LABEL: @infer_via_ranges +; CHECK-LABEL: 'infer_via_ranges' +; CHECK-NEXT: Determining loop execution counts for: @infer_via_ranges +; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 + %n) umin %n) +; CHECK-NEXT: exit count for loop: %n +; CHECK-NEXT: exit count for in.bounds: (-1 + %n) +; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -2147483648 +; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-1 + %n) umin %n) +; CHECK-NEXT: symbolic max exit count for loop: %n +; CHECK-NEXT: symbolic max exit count for in.bounds: (-1 + %n) +; CHECK-NEXT: Loop %loop: Trip multiple is 1 +; entry: %first.itr.check = icmp sgt i32 %n, 0 %start = sub i32 %n, 1 br i1 %first.itr.check, label %loop, label %exit loop: -; CHECK-LABEL: loop: %idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ] %idx.dec = sub i32 %idx, 1 %abc = icmp sge i32 %idx, 0 -; CHECK: br i1 true, label %in.bounds, label %out.of.bounds br i1 %abc, label %in.bounds, label %out.of.bounds in.bounds: -; CHECK-LABEL: in.bounds: %addr = getelementptr i32, ptr %arr, i32 %idx store i32 0, ptr %addr %next = icmp sgt i32 %idx.dec, -1 diff --git a/llvm/test/Transforms/IndVarSimplify/infer-via-ranges.ll b/llvm/test/Transforms/IndVarSimplify/infer-via-ranges.ll new file mode 100644 index 0000000000000..effae2322dba3 --- /dev/null +++ b/llvm/test/Transforms/IndVarSimplify/infer-via-ranges.ll @@ -0,0 +1,51 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -passes=indvars -S < %s | FileCheck %s + +define void @infer_via_ranges(ptr %arr, i32 %n) { +; CHECK-LABEL: define void @infer_via_ranges( +; CHECK-SAME: ptr [[ARR:%.*]], i32 [[N:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT: [[FIRST_ITR_CHECK:%.*]] = icmp sgt i32 [[N]], 0 +; CHECK-NEXT: [[START:%.*]] = sub i32 [[N]], 1 +; CHECK-NEXT: br i1 [[FIRST_ITR_CHECK]], label %[[LOOP_PREHEADER:.*]], label %[[EXIT:.*]] +; CHECK: [[LOOP_PREHEADER]]: +; CHECK-NEXT: br label %[[LOOP:.*]] +; CHECK: [[LOOP]]: +; CHECK-NEXT: [[IDX:%.*]] = phi i32 [ [[IDX_DEC:%.*]], %[[IN_BOUNDS:.*]] ], [ [[START]], %[[LOOP_PREHEADER]] ] +; CHECK-NEXT: [[IDX_DEC]] = sub nsw i32 [[IDX]], 1 +; CHECK-NEXT: br i1 true, label %[[IN_BOUNDS]], label %[[OUT_OF_BOUNDS:.*]] +; CHECK: [[IN_BOUNDS]]: +; CHECK-NEXT: [[ADDR:%.*]] = getelementptr i32, ptr [[ARR]], i32 [[IDX]] +; CHECK-NEXT: store i32 0, ptr [[ADDR]], align 4 +; CHECK-NEXT: [[NEXT:%.*]] = icmp sgt i32 [[IDX_DEC]], -1 +; CHECK-NEXT: br i1 [[NEXT]], label %[[LOOP]], label %[[EXIT_LOOPEXIT:.*]] +; CHECK: [[OUT_OF_BOUNDS]]: +; CHECK-NEXT: ret void +; CHECK: [[EXIT_LOOPEXIT]]: +; CHECK-NEXT: br label %[[EXIT]] +; CHECK: [[EXIT]]: +; CHECK-NEXT: ret void +; + entry: + %first.itr.check = icmp sgt i32 %n, 0 + %start = sub i32 %n, 1 + br i1 %first.itr.check, label %loop, label %exit + + loop: + %idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ] + %idx.dec = sub i32 %idx, 1 + %abc = icmp sge i32 %idx, 0 + br i1 %abc, label %in.bounds, label %out.of.bounds + + in.bounds: + %addr = getelementptr i32, ptr %arr, i32 %idx + store i32 0, ptr %addr + %next = icmp sgt i32 %idx.dec, -1 + br i1 %next, label %loop, label %exit + + out.of.bounds: + ret void + + exit: + ret void +}