diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -8068,7 +8068,6 @@ if (LoopUsersItr != LoopUsers.end()) { ToForget.insert(ToForget.end(), LoopUsersItr->second.begin(), LoopUsersItr->second.end()); - LoopUsers.erase(LoopUsersItr); } // Drop information about expressions based on loop-header PHIs. diff --git a/llvm/test/Transforms/LoopDeletion/pr53969.ll b/llvm/test/Transforms/LoopDeletion/pr53969.ll --- a/llvm/test/Transforms/LoopDeletion/pr53969.ll +++ b/llvm/test/Transforms/LoopDeletion/pr53969.ll @@ -1,13 +1,69 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -passes="loop(indvars,loop-deletion)" -S < %s | FileCheck %s -; XFAIL: * -; REQUIRES: asserts target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2" target triple = "x86_64-unknown-linux-gnu" ; Make sure we don't crash. define void @test() { -; CHECK-LABEL: test +; CHECK-LABEL: @test( +; CHECK-NEXT: bb: +; CHECK-NEXT: br label [[BB1:%.*]] +; CHECK: bb1: +; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ 11, [[BB:%.*]] ] +; CHECK-NEXT: [[TMP3:%.*]] = add nsw i32 112, -1 +; CHECK-NEXT: [[TMP4:%.*]] = add nuw nsw i32 [[TMP2]], 1 +; CHECK-NEXT: [[TMP5:%.*]] = mul i32 [[TMP3]], [[TMP3]] +; CHECK-NEXT: [[TMP6:%.*]] = mul nsw i32 [[TMP2]], -6 +; CHECK-NEXT: [[TMP7:%.*]] = mul nsw i32 [[TMP6]], [[TMP5]] +; CHECK-NEXT: [[TMP8:%.*]] = add nuw nsw i32 [[TMP7]], [[TMP2]] +; CHECK-NEXT: [[TMP9:%.*]] = and i32 undef, 1 +; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i32 [[TMP9]], 0 +; CHECK-NEXT: br i1 [[TMP10]], label [[BB33_LOOPEXIT1:%.*]], label [[BB34_PREHEADER:%.*]] +; CHECK: bb34.preheader: +; CHECK-NEXT: br label [[BB34:%.*]] +; CHECK: bb11: +; CHECK-NEXT: [[TMP2_LCSSA12:%.*]] = phi i32 [ 11, [[BB34]] ] +; CHECK-NEXT: br label [[BB33_LOOPEXIT:%.*]] +; CHECK: bb12: +; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[TMP40:%.*]], 0 +; CHECK-NEXT: br label [[BB14:%.*]] +; CHECK: bb14: +; CHECK-NEXT: br i1 true, label [[BB32:%.*]], label [[BB22:%.*]] +; CHECK: bb22: +; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 4 to i32 +; CHECK-NEXT: [[TMP23:%.*]] = or i32 [[TMP1]], undef +; CHECK-NEXT: [[TMP24:%.*]] = add i32 [[TMP23]], undef +; CHECK-NEXT: br i1 false, label [[BB42:%.*]], label [[BB25:%.*]] +; CHECK: bb25: +; CHECK-NEXT: br label [[BB31:%.*]] +; CHECK: bb31: +; CHECK-NEXT: unreachable +; CHECK: bb32: +; CHECK-NEXT: ret void +; CHECK: bb33.loopexit: +; CHECK-NEXT: [[TMP2_LCSSA9:%.*]] = phi i32 [ [[TMP2_LCSSA12]], [[BB11:%.*]] ] +; CHECK-NEXT: br label [[BB33:%.*]] +; CHECK: bb33.loopexit1: +; CHECK-NEXT: [[TMP2_LCSSA:%.*]] = phi i32 [ [[TMP2]], [[BB1]] ] +; CHECK-NEXT: br label [[BB33]] +; CHECK: bb33: +; CHECK-NEXT: [[TMP210:%.*]] = phi i32 [ [[TMP2_LCSSA]], [[BB33_LOOPEXIT1]] ], [ [[TMP2_LCSSA9]], [[BB33_LOOPEXIT]] ] +; CHECK-NEXT: call void @use(i32 [[TMP210]]) +; CHECK-NEXT: ret void +; CHECK: bb34: +; CHECK-NEXT: [[TMP36:%.*]] = xor i32 0, [[TMP8]] +; CHECK-NEXT: [[TMP38:%.*]] = add i32 [[TMP36]], undef +; CHECK-NEXT: [[TMP39:%.*]] = add i32 [[TMP38]], undef +; CHECK-NEXT: [[TMP40]] = sext i32 [[TMP39]] to i64 +; CHECK-NEXT: br i1 false, label [[BB11]], label [[BB12:%.*]] +; CHECK: bb42: +; CHECK-NEXT: [[TMP24_LCSSA:%.*]] = phi i32 [ [[TMP24]], [[BB22]] ] +; CHECK-NEXT: [[TMP18_LCSSA4:%.*]] = phi i64 [ [[TMP0]], [[BB22]] ] +; CHECK-NEXT: store atomic i64 [[TMP18_LCSSA4]], i64 addrspace(1)* undef unordered, align 8 +; CHECK-NEXT: call void @use(i32 [[TMP24_LCSSA]]) +; CHECK-NEXT: ret void +; bb: br label %bb1