1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-reduce -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.15.0"
7 declare void @use(double) readnone
9 ; Make sure re-used instructions do not impact the insertion points for SCEV
11 define void @test(double* %ioptr, i32 %X, double* %start, double* %end) {
14 ; CHECK-NEXT: [[IDX_EXT32:%.*]] = sext i32 [[X:%.*]] to i64
15 ; CHECK-NEXT: [[TMP0:%.*]] = shl nsw i64 [[IDX_EXT32]], 3
16 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i64 [[TMP0]], 8
17 ; CHECK-NEXT: br label [[FOR_BODY15:%.*]]
19 ; CHECK-NEXT: br label [[FOR_BODY37:%.*]]
21 ; CHECK-NEXT: [[P0R_0335:%.*]] = phi double* [ [[ADD_PTR94:%.*]], [[FOR_BODY37]] ], [ [[START:%.*]], [[FOR_BODY15]] ]
22 ; CHECK-NEXT: [[ADD_PTR94]] = getelementptr inbounds double, double* [[P0R_0335]], i64 1
23 ; CHECK-NEXT: [[P0R_03351:%.*]] = bitcast double* [[P0R_0335]] to i8*
24 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, i8* [[P0R_03351]], i64 [[TMP1]]
25 ; CHECK-NEXT: [[UGLYGEP2:%.*]] = bitcast i8* [[UGLYGEP]] to double*
26 ; CHECK-NEXT: [[F1I_0:%.*]] = load double, double* [[UGLYGEP2]], align 8
27 ; CHECK-NEXT: call void @use(double [[F1I_0]])
28 ; CHECK-NEXT: [[EC0:%.*]] = icmp eq double* [[ADD_PTR94]], [[END:%.*]]
29 ; CHECK-NEXT: br i1 [[EC0]], label [[FOR_BODY37]], label [[FOR_END_LOOPEXIT:%.*]]
30 ; CHECK: for.end.loopexit:
31 ; CHECK-NEXT: br label [[FOR_END:%.*]]
33 ; CHECK-NEXT: [[P0R_0_LCSSA:%.*]] = phi double* [ [[ADD_PTR94]], [[FOR_END_LOOPEXIT]] ]
34 ; CHECK-NEXT: [[EC1:%.*]] = icmp eq double* [[P0R_0_LCSSA]], [[END]]
35 ; CHECK-NEXT: br i1 [[EC1]], label [[FOR_BODY15]], label [[FOR_INC133:%.*]]
37 ; CHECK-NEXT: ret void
40 %idx.ext32 = sext i32 %X to i64
43 for.body15: ; preds = %for.end, %for.body15.lr.ph
46 for.body37: ; preds = %for.body37, %for.body37.preheader
47 %p0r.0335 = phi double* [ %add.ptr94, %for.body37 ], [ %start, %for.body15 ]
48 %add.ptr94 = getelementptr inbounds double, double* %p0r.0335, i64 1
49 %f1i.0.in = getelementptr inbounds double, double* %add.ptr94, i64 %idx.ext32
50 %f1i.0 = load double, double* %f1i.0.in, align 8
51 call void @use(double %f1i.0)
52 %ec0 = icmp eq double* %add.ptr94, %end
53 br i1 %ec0, label %for.body37, label %for.end.loopexit
55 for.end.loopexit: ; preds = %for.body37
58 for.end: ; preds = %for.end.loopexit, %for.body15
59 %p0r.0.lcssa = phi double* [ %add.ptr94, %for.end.loopexit ]
60 %ec1 = icmp eq double* %p0r.0.lcssa, %end
61 br i1 %ec1, label %for.body15, label %for.inc133
63 for.inc133: ; preds = %for.end