1target datalayout = 2"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-S128" 3 4; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s 5 6; ptr_phi and ptr2_phi do not alias. 7; CHECK: test_noalias_1 8; CHECK: NoAlias: i32* %ptr2_phi, i32* %ptr_phi 9define i32 @test_noalias_1(i32* %ptr2, i32 %count, i32* %coeff) { 10entry: 11 %ptr = getelementptr inbounds i32, i32* %ptr2, i64 1 12 br label %while.body 13 14while.body: 15 %num = phi i32 [ %count, %entry ], [ %dec, %while.body ] 16 %ptr_phi = phi i32* [ %ptr, %entry ], [ %ptr_inc, %while.body ] 17 %ptr2_phi = phi i32* [ %ptr2, %entry ], [ %ptr2_inc, %while.body ] 18 %result.09 = phi i32 [ 0 , %entry ], [ %add, %while.body ] 19 %dec = add nsw i32 %num, -1 20 %0 = load i32, i32* %ptr_phi, align 4 21 store i32 %0, i32* %ptr2_phi, align 4 22 %1 = load i32, i32* %coeff, align 4 23 %2 = load i32, i32* %ptr_phi, align 4 24 %mul = mul nsw i32 %1, %2 25 %add = add nsw i32 %mul, %result.09 26 %tobool = icmp eq i32 %dec, 0 27 %ptr_inc = getelementptr inbounds i32, i32* %ptr_phi, i64 1 28 %ptr2_inc = getelementptr inbounds i32, i32* %ptr2_phi, i64 1 29 br i1 %tobool, label %the_exit, label %while.body 30 31the_exit: 32 ret i32 %add 33} 34 35; CHECK: test_noalias_2 36; CHECK: NoAlias: i32* %ptr_outer_phi, i32* %ptr_outer_phi2 37; CHECK: NoAlias: i32* %ptr2_phi, i32* %ptr_phi 38define i32 @test_noalias_2(i32* %ptr2, i32 %count, i32* %coeff) { 39entry: 40 %ptr = getelementptr inbounds i32, i32* %ptr2, i64 1 41 br label %outer.while.header 42 43outer.while.header: 44 %ptr_outer_phi = phi i32* [%ptr_inc_outer, %outer.while.backedge], [ %ptr, %entry] 45 %ptr_outer_phi2 = phi i32* [%ptr2_inc_outer, %outer.while.backedge], [ %ptr2, %entry] 46 %num.outer = phi i32 [ %count, %entry ], [ %dec.outer, %outer.while.backedge ] 47 br label %while.body 48 49while.body: 50 %num = phi i32 [ %count, %outer.while.header ], [ %dec, %while.body ] 51 %ptr_phi = phi i32* [ %ptr_outer_phi, %outer.while.header ], [ %ptr_inc, %while.body ] 52 %ptr2_phi = phi i32* [ %ptr_outer_phi2, %outer.while.header ], [ %ptr2_inc, %while.body ] 53 %result.09 = phi i32 [ 0 , %outer.while.header ], [ %add, %while.body ] 54 %dec = add nsw i32 %num, -1 55 %0 = load i32, i32* %ptr_phi, align 4 56 store i32 %0, i32* %ptr2_phi, align 4 57 %1 = load i32, i32* %coeff, align 4 58 %2 = load i32, i32* %ptr_phi, align 4 59 %mul = mul nsw i32 %1, %2 60 %add = add nsw i32 %mul, %result.09 61 %tobool = icmp eq i32 %dec, 0 62 %ptr_inc = getelementptr inbounds i32, i32* %ptr_phi, i64 1 63 %ptr2_inc = getelementptr inbounds i32, i32* %ptr2_phi, i64 1 64 br i1 %tobool, label %outer.while.backedge, label %while.body 65 66outer.while.backedge: 67 %ptr_inc_outer = getelementptr inbounds i32, i32* %ptr_phi, i64 1 68 %ptr2_inc_outer = getelementptr inbounds i32, i32* %ptr2_phi, i64 1 69 %dec.outer = add nsw i32 %num.outer, -1 70 %br.cond = icmp eq i32 %dec.outer, 0 71 br i1 %br.cond, label %the_exit, label %outer.while.header 72 73the_exit: 74 ret i32 %add 75} 76 77; CHECK: test_noalias_3 78; CHECK: MayAlias: i8* %ptr2_phi, i8* %ptr_phi 79define i32 @test_noalias_3(i8* noalias %x, i8* noalias %y, i8* noalias %z, 80 i32 %count) { 81entry: 82 br label %while.body 83 84while.body: 85 %num = phi i32 [ %count, %entry ], [ %dec, %while.body ] 86 %ptr_phi = phi i8* [ %x, %entry ], [ %z, %while.body ] 87 %ptr2_phi = phi i8* [ %y, %entry ], [ %ptr_phi, %while.body ] 88 %dec = add nsw i32 %num, -1 89 %tobool = icmp eq i32 %dec, 0 90 br i1 %tobool, label %the_exit, label %while.body 91 92the_exit: 93 ret i32 1 94} 95