61 lines · plain
1; RUN: opt -S < %s -passes='loop-unroll,load-store-vectorizer' -unroll-count=128 --capture-tracking-max-uses-to-explore=1024 | FileCheck %s2 3; Without using batching alias analysis, this test takes 6 seconds to compile. With, less than a second.4; This is because the mechanism that proves NoAlias in this case is very expensive (CaptureTracking.cpp),5; and caching the result leads to 2 calls to that mechanism instead of ~300,000 (run with -stats to see the difference)6 7; This test only demonstrates the compile time issue if capture-tracking-max-uses-to-explore is set to at least 1024,8; because with the default value of 100, the CaptureTracking analysis is not run, NoAlias is not proven, and the vectorizer gives up early.9 10@global_mem = external global i8, align 411 12define void @compile-time-test() {13; CHECK-LABEL: define void @compile-time-test() {14; CHECK-COUNT-128: load <4 x i8>15entry:16 ; Create base pointer to a global variable with the inefficient pattern that Alias Analysis cannot easily traverse through.17 %global_base_loads = getelementptr i8, ptr inttoptr (i32 ptrtoint (ptr @global_mem to i32) to ptr), i64 018 19 ; Create another pointer for the stores.20 %local_base_stores = alloca <512 x i8>, align 421 22 ; 512 interwoven loads and stores in a loop that gets unrolled23 br label %loop24 25loop:26 %i = phi i64 [ 0, %entry ], [ %i_next, %loop ]27 28 %ptr_0 = getelementptr i8, ptr %global_base_loads, i64 %i29 %load_0 = load i8, ptr %ptr_0, align 430 %ptr2_0 = getelementptr i8, ptr %local_base_stores, i64 %i31 store i8 %load_0, ptr %ptr2_0, align 432 33 %i_1 = add i64 %i, 134 35 %ptr_1 = getelementptr i8, ptr %global_base_loads, i64 %i_136 %load_1 = load i8, ptr %ptr_1, align 137 %ptr2_1 = getelementptr i8, ptr %local_base_stores, i64 %i_138 store i8 %load_1, ptr %ptr2_1, align 139 40 %i_2 = add i64 %i, 241 42 %ptr_2 = getelementptr i8, ptr %global_base_loads, i64 %i_243 %load_2 = load i8, ptr %ptr_2, align 244 %ptr2_2 = getelementptr i8, ptr %local_base_stores, i64 %i_245 store i8 %load_2, ptr %ptr2_2, align 246 47 %i_3 = add i64 %i, 348 49 %ptr_3 = getelementptr i8, ptr %global_base_loads, i64 %i_350 %load_3 = load i8, ptr %ptr_3, align 151 %ptr2_3 = getelementptr i8, ptr %local_base_stores, i64 %i_352 store i8 %load_3, ptr %ptr2_3, align 153 54 %i_next = add i64 %i, 455 %cmp = icmp ult i64 %i_next, 51256 br i1 %cmp, label %loop, label %done57 58done:59 ret void60}61