1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
3 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
9 ; CHECK-LABEL: define void @test() {
11 ; CHECK-NEXT: br label [[BB3:%.*]]
13 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i32 [ [[LSR_IV_NEXT:%.*]], [[BB3]] ], [ 159, [[BB:%.*]] ]
14 ; CHECK-NEXT: [[PHI:%.*]] = phi i64 [ 158, [[BB]] ], [ [[ADD5:%.*]], [[BB3]] ]
15 ; CHECK-NEXT: [[PHI4:%.*]] = phi i32 [ 0, [[BB]] ], [ [[ADD6:%.*]], [[BB3]] ]
16 ; CHECK-NEXT: [[ADD5]] = add i64 [[PHI]], -4
17 ; CHECK-NEXT: [[ADD6]] = add i32 [[PHI4]], 4
18 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add nsw i32 [[LSR_IV]], -4
19 ; CHECK-NEXT: [[ICMP:%.*]] = icmp ult i64 [[ADD5]], 7
20 ; CHECK-NEXT: br i1 [[ICMP]], label [[BB7:%.*]], label [[BB3]]
22 ; CHECK-NEXT: [[UMAX7:%.*]] = call i32 @llvm.umax.i32(i32 [[LSR_IV_NEXT]], i32 10)
23 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[UMAX7]], [[ADD6]]
24 ; CHECK-NEXT: [[UMIN6:%.*]] = call i32 @llvm.umin.i32(i32 [[LSR_IV_NEXT]], i32 11)
25 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[UMIN6]], [[ADD6]]
26 ; CHECK-NEXT: [[SMAX5:%.*]] = call i32 @llvm.smax.i32(i32 [[LSR_IV_NEXT]], i32 10)
27 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[SMAX5]], [[ADD6]]
28 ; CHECK-NEXT: [[SMIN4:%.*]] = call i32 @llvm.smin.i32(i32 [[LSR_IV_NEXT]], i32 10)
29 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[SMIN4]], [[ADD6]]
30 ; CHECK-NEXT: call void @use.umax.res(i32 [[TMP0]])
31 ; CHECK-NEXT: call void @use.umin.res(i32 [[TMP1]])
32 ; CHECK-NEXT: call void @use.smax.res(i32 [[TMP2]])
33 ; CHECK-NEXT: call void @use.smin.res(i32 [[TMP3]])
34 ; CHECK-NEXT: ret void
39 bb3: ; preds = %bb3, %bb
40 %phi = phi i64 [ 158, %bb ], [ %add5, %bb3 ]
41 %phi4 = phi i32 [ 0, %bb ], [ %add6, %bb3 ]
42 %add = add i64 %phi, -3
43 %trunc = trunc i64 %add to i32
44 %umax = call i32 @llvm.umax.i32(i32 %trunc, i32 10)
45 %umin = call i32 @llvm.umin.i32(i32 %trunc, i32 11)
46 %smax = call i32 @llvm.smax.i32(i32 %trunc, i32 10)
47 %smin = call i32 @llvm.smin.i32(i32 %trunc, i32 10)
48 %add5 = add i64 %phi, -4
49 %add6 = add i32 %phi4, 4
50 %icmp = icmp ult i64 %add5, 7
51 br i1 %icmp, label %bb7, label %bb3
54 %umax.res = add i32 %add6, %umax
55 %umin.res = add i32 %add6, %umin
56 %smax.res = add i32 %add6, %smax
57 %smin.res = add i32 %add6, %smin
58 call void @use.umax.res(i32 %umax.res)
59 call void @use.umin.res(i32 %umin.res)
60 call void @use.smax.res(i32 %smax.res)
61 call void @use.smin.res(i32 %smin.res)
65 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
66 declare i32 @llvm.umax.i32(i32, i32) #0
67 declare i32 @llvm.umin.i32(i32, i32) #0
68 declare i32 @llvm.smax.i32(i32, i32) #0
69 declare i32 @llvm.smin.i32(i32, i32) #0
71 declare void @use.umax.res(i32)
72 declare void @use.umin.res(i32)
73 declare void @use.smax.res(i32)
74 declare void @use.smin.res(i32)
76 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }