1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
6 ; Make sure that we do not insert trunc in the loop.
7 define i32 @test_01(double* %p, double %x, i32* %np, i32* %mp, i32 %k) {
8 ; CHECK-LABEL: @test_01(
10 ; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[K:%.*]] to i64
11 ; CHECK-NEXT: br label [[LOOP:%.*]]
13 ; CHECK-NEXT: [[IV_WIDE:%.*]] = phi i64 [ [[CANONICAL_IV_NEXT_I:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
14 ; CHECK-NEXT: [[CANONICAL_IV_NEXT_I]] = add nuw nsw i64 [[IV_WIDE]], 1
15 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds double, double* [[P:%.*]], i64 [[IV_WIDE]]
16 ; CHECK-NEXT: [[LOAD:%.*]] = load atomic double, double* [[GEP]] unordered, align 8
17 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], [[LOAD]]
18 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds double, double* [[P]], i64 [[IV_WIDE]]
19 ; CHECK-NEXT: store atomic double [[MUL]], double* [[GEP2]] unordered, align 8
20 ; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp slt i64 [[CANONICAL_IV_NEXT_I]], [[TMP0]]
21 ; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
23 ; CHECK-NEXT: ret i32 0
29 %iv.wide = phi i64 [ %canonical.iv.next.i, %loop ], [ 0, %entry ]
30 %iv.narrow = phi i32 [ %iv.narrow.next, %loop ], [ 0, %entry ]
31 %canonical.iv.next.i = add nuw nsw i64 %iv.wide, 1
32 %zext = zext i32 %iv.narrow to i64
33 %gep = getelementptr inbounds double, double* %p, i64 %zext
34 %load = load atomic double, double* %gep unordered, align 8
35 %mul = fmul double %x, %load
36 %gep2 = getelementptr inbounds double, double* %p, i64 %zext
37 store atomic double %mul, double* %gep2 unordered, align 8
38 %iv.narrow.next = add nuw nsw i32 %iv.narrow, 1
39 %loop.cond = icmp slt i32 %iv.narrow.next, %k
40 br i1 %loop.cond, label %loop, label %exit