+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=indvars -S %s -o - | FileCheck %s
; When bailing out in rewriteLoopExitValues() you would be left with a PHI node
; that was not deleted, and the IndVar pass would return an incorrect modified
; status. This was caught by the expensive check introduced in D86589.
-; CHECK-LABEL: header:
-; CHECK-NEXT: %idx = phi i64 [ %idx.next, %latch ], [ undef, %entry ]
-; CHECK-NEXT: %cond = icmp sgt i64 %n, %idx
-; CHECK-NEXT: br i1 %cond, label %end, label %inner.preheader
-
-; CHECK-LABEL: latch:
-; CHECK-NEXT: %idx.next = add nsw i64 %idx, -1
-; CHECK-NEXT: br label %header
-
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ptr = external global i64
define dso_local void @hoge() local_unnamed_addr {
+; CHECK-LABEL: @hoge(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[N:%.*]] = sdiv exact i64 undef, 40
+; CHECK-NEXT: br label [[HEADER:%.*]]
+; CHECK: header:
+; CHECK-NEXT: [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH:%.*]] ], [ undef, [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[COND:%.*]] = icmp sgt i64 [[N]], [[IDX]]
+; CHECK-NEXT: br i1 [[COND]], label [[END:%.*]], label [[INNER_PREHEADER:%.*]]
+; CHECK: inner.preheader:
+; CHECK-NEXT: br label [[INNER:%.*]]
+; CHECK: inner:
+; CHECK-NEXT: [[I:%.*]] = phi i64 [ [[I_NEXT:%.*]], [[INNER]] ], [ 0, [[INNER_PREHEADER]] ]
+; CHECK-NEXT: [[J:%.*]] = phi i64 [ [[J_NEXT:%.*]], [[INNER]] ], [ [[N]], [[INNER_PREHEADER]] ]
+; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i64 [[I]], 1
+; CHECK-NEXT: [[J_NEXT]] = add nsw i64 [[J]], 1
+; CHECK-NEXT: store i64 undef, i64* @ptr, align 8
+; CHECK-NEXT: [[COND1:%.*]] = icmp slt i64 [[J]], [[IDX]]
+; CHECK-NEXT: br i1 [[COND1]], label [[INNER]], label [[INNER_EXIT:%.*]]
+; CHECK: inner_exit:
+; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[I_NEXT]], [[INNER]] ]
+; CHECK-NEXT: [[INDVAR_USE:%.*]] = add i64 [[INDVAR]], 1
+; CHECK-NEXT: br label [[LATCH]]
+; CHECK: latch:
+; CHECK-NEXT: [[IDX_NEXT]] = add nsw i64 [[IDX]], -1
+; CHECK-NEXT: br label [[HEADER]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
entry: ; preds = %entry
%n = sdiv exact i64 undef, 40
br label %header
; RUN: opt -mtriple=x86_64-unknown-linux-gnu -passes='loop-unroll' -unroll-runtime -S < %s 2>&1 | FileCheck %s
define void @mask-high(i64 %arg, ptr dereferenceable(4) %arg1) {
-; CHECK-LABEL: define {{[^@]+}}@mask-high(
+; CHECK-LABEL: @mask-high(
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARG1:%.*]], align 4
; CHECK-NEXT: [[I2:%.*]] = sext i32 [[I]] to i64
define void @mask-low(i64 %arg, ptr dereferenceable(4) %arg1) {
-; CHECK-LABEL: define {{[^@]+}}@mask-low(
+; CHECK-LABEL: @mask-low(
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARG1:%.*]], align 4
; CHECK-NEXT: [[I2:%.*]] = sext i32 [[I]] to i64