xref: /llvm-project/polly/test/CodeGen/MemAccess/invariant_base_ptr.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1*e1f056f6Srahulana-quic; RUN: opt %loadNPMPolly '-passes=polly-import-jscop,polly-codegen' \
2*e1f056f6Srahulana-quic; RUN:   -polly-invariant-load-hoisting -S \
335f70200SMichael Kruse; RUN:   2>&1 < %s | FileCheck %s
435f70200SMichael Kruse
535f70200SMichael Kruse; Setting new access functions where the base pointer of the array that is newly
635f70200SMichael Kruse; accessed is only loaded within the scop itself caused incorrect code to be
735f70200SMichael Kruse; generated when invariant load hoisting is disabled. This test case checks
835f70200SMichael Kruse; that in case invariant load hoisting is enabled, we generate correct code.
935f70200SMichael Kruse
1055cb5796SNikita Popov; CHECK: %polly.access.polly.access.X.load = getelementptr float, ptr %polly.access.X.load, i64 %polly.indvar
1135f70200SMichael Kruse
1255cb5796SNikita Popovdefine void @invariant_base_ptr(ptr noalias %Array, ptr noalias %X,
1355cb5796SNikita Popov                                ptr noalias %C) {
1435f70200SMichael Kruse
1535f70200SMichael Krusestart:
1635f70200SMichael Kruse  br label %loop
1735f70200SMichael Kruse
1835f70200SMichael Kruseloop:
1935f70200SMichael Kruse  %indvar = phi i64 [0, %start], [%indvar.next, %latch]
2035f70200SMichael Kruse  %indvar.next = add i64 %indvar, 1
2135f70200SMichael Kruse  %cmp = icmp slt i64 %indvar, 1024
2235f70200SMichael Kruse  br i1 %cmp, label %body, label %exit
2335f70200SMichael Kruse
2435f70200SMichael Krusebody:
2555cb5796SNikita Popov  %gep= getelementptr float, ptr %Array, i64 %indvar
2655cb5796SNikita Popov  store float 42.0, ptr %gep
2735f70200SMichael Kruse  br label %body2
2835f70200SMichael Kruse
2935f70200SMichael Krusebody2:
3055cb5796SNikita Popov  %Base = load ptr, ptr %X
3155cb5796SNikita Popov  %gep2 = getelementptr float, ptr %Base, i64 %indvar
3255cb5796SNikita Popov  %val2 = load float, ptr %gep2
3355cb5796SNikita Popov  store float %val2, ptr %C
3435f70200SMichael Kruse  br label %latch
3535f70200SMichael Kruse
3635f70200SMichael Kruselatch:
3735f70200SMichael Kruse  br label %loop
3835f70200SMichael Kruse
3935f70200SMichael Kruseexit:
4035f70200SMichael Kruse  ret void
4135f70200SMichael Kruse}
42