63 lines · plain
1; RUN: opt -passes=called-value-propagation -S < %s | FileCheck %s2 3target triple = "aarch64"4 5@global_function = internal unnamed_addr global ptr null, align 86@global_array = common unnamed_addr global ptr null, align 87 8; This test checks that we propagate the functions through an internal global9; variable, and attach !callees metadata to the call. Such metadata can enable10; optimizations of this code sequence.11;12; For example, since both of the targeted functions have the "nounwind" and13; "readnone" function attributes, LICM can be made to move the call and the14; function pointer load outside the loop. This would then enable the loop15; vectorizer to vectorize the sum reduction.16;17; CHECK: call void %tmp0(), !callees ![[MD:[0-9]+]]18; CHECK: ![[MD]] = !{ptr @invariant_1, ptr @invariant_2}19;20define i64 @test_memory_entry(i64 %n, i1 %flag) {21entry:22 br i1 %flag, label %then, label %else23 24then:25 store ptr @invariant_1, ptr @global_function26 br label %merge27 28else:29 store ptr @invariant_2, ptr @global_function30 br label %merge31 32merge:33 %tmp1 = call i64 @test_memory(i64 %n)34 ret i64 %tmp135}36 37define internal i64 @test_memory(i64 %n) {38entry:39 %array = load ptr, ptr @global_array40 br label %for.body41 42for.body:43 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]44 %r = phi i64 [ 0, %entry ], [ %tmp3, %for.body ]45 %tmp0 = load ptr, ptr @global_function46 call void %tmp0()47 %tmp1 = getelementptr inbounds i64, ptr %array, i64 %i48 %tmp2 = load i64, ptr %tmp149 %tmp3 = add i64 %tmp2, %r50 %i.next = add nuw nsw i64 %i, 151 %cond = icmp slt i64 %i.next, %n52 br i1 %cond, label %for.body, label %for.end53 54for.end:55 %tmp4 = phi i64 [ %tmp3, %for.body ]56 ret i64 %tmp457}58 59declare void @invariant_1() #060declare void @invariant_2() #061 62attributes #0 = { nounwind readnone }63