1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @G = external global i32
9 define void @test0(ptr %arg) {
10 ; CHECK-LABEL: @test0(
12 ; CHECK-NEXT: br label [[BB2:%.*]]
14 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ [[TMP7:%.*]], [[BB2]] ]
15 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @wobble(ptr nonnull [[TMP]], ptr null)
16 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr null, align 8
17 ; CHECK-NEXT: [[TMP7]] = load ptr, ptr undef, align 8
18 ; CHECK-NEXT: br label [[BB2]]
24 %tmp = phi ptr [%arg, %bb ], [ %tmp7, %bb2 ]
25 %tmp4 = call ptr @wobble(ptr nonnull %tmp, ptr null)
26 %tmp5 = load i32, ptr %tmp4, align 8
27 %tmp7 = load ptr, ptr undef, align 8
31 define void @test1(ptr %arg) {
32 ; CHECK-LABEL: @test1(
34 ; CHECK-NEXT: br label [[BB2:%.*]]
36 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ [[TMP7:%.*]], [[BB2]] ]
37 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @wobble(ptr nonnull [[TMP]], ptr inttoptr (i64 4 to ptr))
38 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr inttoptr (i64 4 to ptr), align 4
39 ; CHECK-NEXT: [[TMP7]] = load ptr, ptr undef, align 8
40 ; CHECK-NEXT: br label [[BB2]]
46 %tmp = phi ptr [%arg, %bb ], [ %tmp7, %bb2 ]
47 %tmp4 = call ptr @wobble(ptr nonnull %tmp, ptr inttoptr (i64 4 to ptr))
48 %tmp5 = load i32, ptr %tmp4
49 %tmp7 = load ptr, ptr undef, align 8
53 define void @test2(ptr %arg) {
54 ; CHECK-LABEL: @test2(
56 ; CHECK-NEXT: br label [[BB2:%.*]]
58 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ [[TMP7:%.*]], [[BB2]] ]
59 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @wobble(ptr nonnull [[TMP]], ptr @G)
60 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr @G, align 4
61 ; CHECK-NEXT: [[TMP7]] = load ptr, ptr undef, align 8
62 ; CHECK-NEXT: br label [[BB2]]
68 %tmp = phi ptr [%arg, %bb ], [ %tmp7, %bb2 ]
69 %tmp4 = call ptr @wobble(ptr nonnull %tmp, ptr @G)
70 %tmp5 = load i32, ptr %tmp4
71 %tmp7 = load ptr, ptr undef, align 8
75 define void @test3(ptr %arg, ptr %loop.invariant) {
76 ; CHECK-LABEL: @test3(
78 ; CHECK-NEXT: br label [[BB2:%.*]]
80 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ [[TMP7:%.*]], [[BB2]] ]
81 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @wobble(ptr nonnull [[TMP]], ptr [[LOOP_INVARIANT:%.*]])
82 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[LOOP_INVARIANT]], align 4
83 ; CHECK-NEXT: [[TMP7]] = load ptr, ptr undef, align 8
84 ; CHECK-NEXT: br label [[BB2]]
90 %tmp = phi ptr [%arg, %bb ], [ %tmp7, %bb2 ]
91 %tmp4 = call ptr @wobble(ptr nonnull %tmp, ptr %loop.invariant)
92 %tmp5 = load i32, ptr %tmp4
93 %tmp7 = load ptr, ptr undef, align 8
97 define void @test4(ptr %arg, ptr %loop.invariant, i64 %N) {
98 ; CHECK-LABEL: @test4(
100 ; CHECK-NEXT: [[TMP0:%.*]] = shl i64 [[N:%.*]], 8
101 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[LOOP_INVARIANT:%.*]], i64 [[TMP0]]
102 ; CHECK-NEXT: br label [[BB2:%.*]]
104 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ [[TMP7:%.*]], [[BB2]] ]
105 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i64 [[N]], 64
106 ; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds i32, ptr [[LOOP_INVARIANT]], i64 [[MUL]]
107 ; CHECK-NEXT: [[TMP4:%.*]] = call ptr @wobble(ptr nonnull [[TMP]], ptr [[PTR]])
108 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[UGLYGEP]], align 4
109 ; CHECK-NEXT: [[TMP7]] = load ptr, ptr undef, align 8
110 ; CHECK-NEXT: br label [[BB2]]
116 %tmp = phi ptr [%arg, %bb ], [ %tmp7, %bb2 ]
117 %mul = mul nsw i64 %N, 64
118 %ptr = getelementptr inbounds i32, ptr %loop.invariant, i64 %mul
119 %tmp4 = call ptr @wobble(ptr nonnull %tmp, ptr %ptr)
120 %tmp5 = load i32, ptr %tmp4
121 %tmp7 = load ptr, ptr undef, align 8
125 declare ptr @wobble(ptr, ptr returned)