1 ; RUN: opt < %s -indvars -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 @G = external global i32
8 define void @test0(i64* %arg) {
13 %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
14 %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* null)
15 %tmp5 = load i32, i32* %tmp4, align 8
16 %tmp7 = load i64*, i64** undef, align 8
20 ; CHECK-LABEL: void @test0
21 ; CHECK: load i32, i32* null
23 define void @test1(i64* %arg) {
28 %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
29 %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* inttoptr (i64 4 to i32*))
30 %tmp5 = load i32, i32* %tmp4
31 %tmp7 = load i64*, i64** undef, align 8
35 ; CHECK-LABEL: void @test1
36 ; CHECK: load i32, i32* inttoptr (i64 4 to i32*)
38 define void @test2(i64* %arg) {
43 %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
44 %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* @G)
45 %tmp5 = load i32, i32* %tmp4
46 %tmp7 = load i64*, i64** undef, align 8
50 ; CHECK-LABEL: void @test2
51 ; CHECK: load i32, i32* @G
54 define void @test3(i64* %arg, i32* %loop.invariant) {
59 %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
60 %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* %loop.invariant)
61 %tmp5 = load i32, i32* %tmp4
62 %tmp7 = load i64*, i64** undef, align 8
66 ; CHECK-LABEL: void @test3
67 ; CHECK: load i32, i32* %loop.invariant
69 define void @test4(i64* %arg, i32* %loop.invariant, i64 %N) {
74 %tmp = phi i64* [%arg, %bb ], [ %tmp7, %bb2 ]
75 %mul = mul nsw i64 %N, 64
76 %ptr = getelementptr inbounds i32, i32* %loop.invariant, i64 %mul
77 %tmp4 = call i32* @wobble(i64* nonnull %tmp, i32* %ptr)
78 %tmp5 = load i32, i32* %tmp4
79 %tmp7 = load i64*, i64** undef, align 8
83 ; CHECK-LABEL: void @test4
84 ; CHECK: [[P:%[a-zA-Z$._0-9]+]] = getelementptr i32, i32* %loop.invariant
86 ; CHECK: load i32, i32* [[P]]
88 declare i32* @wobble(i64*, i32* returned)