1; RUN: opt %loadPolly -S -polly-use-llvm-names -polly-scops \ 2; RUN: -polly-acc-dump-code -analyze \ 3; RUN: -polly-invariant-load-hoisting < %s | FileCheck %s -check-prefix=SCOP 4 5; RUN: opt %loadPolly -S -polly-use-llvm-names -polly-codegen-ppcg \ 6; RUN: -polly-acc-dump-code -polly-stmt-granularity=bb \ 7; RUN: -polly-invariant-load-hoisting < %s | FileCheck %s -check-prefix=CODE 8 9; RUN: opt %loadPolly -S -polly-use-llvm-names -polly-codegen-ppcg \ 10; RUN: -polly-invariant-load-hoisting -polly-stmt-granularity=bb < %s \ 11; RUN: | FileCheck %s -check-prefix=HOST-IR 12 13; REQUIRES: pollyacc 14 15; SCOP: Invariant Accesses: { 16; SCOP-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 17; SCOP-NEXT: { Stmt_loop_a[i0] -> MemRef_p[0] }; 18; SCOP-NEXT: Execution Context: { : } 19; SCOP-NEXT: } 20 21; CODE: # kernel0 22; CODE-NEXT: { 23; CODE-NEXT: if (32 * b0 + t0 <= 1025) { 24; CODE-NEXT: Stmt_loop(32 * b0 + t0); 25; CODE-NEXT: write(0); 26; CODE-NEXT: } 27; CODE-NEXT: sync0(); 28; CODE-NEXT: } 29 30; Check that we generate a correct "always false" branch. 31; HOST-IR: br i1 false, label %polly.start, label %loop.pre_entry_bb 32 33; This test case checks that we generate correct code if PPCGCodeGeneration 34; decides a build is unsuccessful with invariant load hoisting enabled. 35; 36; There is a conditional branch which switches between the original code and 37; the new code. We try to set this conditional branch to branch on false. 38; However, invariant load hoisting changes the structure of the scop, so we 39; need to change the way we *locate* this instruction. 40 41target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128" 42target triple = "i386-apple-macosx10.12.0" 43 44define void @foo(float* %A, float* %p) { 45entry: 46 br label %loop 47 48loop: 49 %indvar = phi i64 [0, %entry], [%indvar.next, %loop] 50 %indvar.next = add i64 %indvar, 1 51 %invariant = load float, float* %p 52 %ptr = getelementptr float, float* %A, i64 %indvar 53 store float 42.0, float* %ptr 54 %cmp = icmp sle i64 %indvar, 1024 55 br i1 %cmp, label %loop, label %loop2 56 57loop2: 58 %indvar2 = phi i64 [0, %loop], [%indvar2.next, %loop2] 59 %indvar2f = phi float [%invariant, %loop], [%indvar2f, %loop2] 60 %indvar2.next = add i64 %indvar2, 1 61 store float %indvar2f, float* %A 62 %cmp2 = icmp sle i64 %indvar2, 1024 63 br i1 %cmp2, label %loop2, label %end 64 65end: 66 ret void 67} 68