Files
clang-p2996/polly/test/Isl/CodeGen/invariant_load_canonicalize_array_baseptrs.ll
Tobias Grosser f3adab4c20 [Polly] Canonicalize arrays according to base-ptr equivalence class
Summary:
    In case two arrays share base pointers in the same invariant load equivalence
    class, we canonicalize all memory accesses to the first of these arrays
    (according to their order in the equivalence class).

    This enables us to optimize kernels such as boost::ublas by ensuring that
    different references to the C array are interpreted as accesses to the same
    array. Before this change the runtime alias check for ublas would fail, as it
    would assume models of the C array with differing (but identically valued) base
    pointers would reference distinct regions of memory whereas the referenced
    memory regions were indeed identical.

    As part of this change we remove most of the MemoryAccess::get*BaseAddr
    interface. We removed already all references to get*BaseAddr in previous
    commits to ensure that no code relies on matching base pointers between
    memory accesses and scop arrays -- except for three remaining uses where we
    need the original base pointer. We document for these situations that
    MemoryAccess::getOriginalBaseAddr may return a base pointer that is distinct
    to the base pointer of the scop array referenced by this memory access.

Reviewers: sebpop, Meinersbur, zinob, gareevroman, pollydev, huihuiz, efriedma, jdoerfert

Reviewed By: Meinersbur

Subscribers: etherzhhb

Tags: #polly

Differential Revision: https://reviews.llvm.org/D28518

llvm-svn: 302636
2017-05-10 10:59:58 +00:00

37 lines
852 B
LLVM

; RUN: opt %loadPolly -polly-codegen -S < %s \
; RUN: -polly-invariant-load-hoisting \
; RUN: | FileCheck %s
; CHECK: %polly.access.A = getelementptr float*, float** %A, i64 0
; CHECK: %polly.access.A.load = load float*, float** %polly.access.A
; CHECK: store float 4.200000e+01, float* %polly.access.A.load
; CHECK: store float 4.800000e+01, float* %polly.access.A.load
define void @foo(float** %A) {
start:
br label %loop
loop:
%indvar = phi i64 [0, %start], [%indvar.next, %latch]
%indvar.next = add nsw i64 %indvar, 1
%icmp = icmp slt i64 %indvar.next, 1024
br i1 %icmp, label %body1, label %exit
body1:
%baseA = load float*, float** %A
store float 42.0, float* %baseA
br label %body2
body2:
%baseB = load float*, float** %A
store float 48.0, float* %baseB
br label %latch
latch:
br label %loop
exit:
ret void
}