brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · d100b51 Raw
54 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s 2>&1 | FileCheck %s2;3; Verify we do hoist the invariant access to I with a execution context4; as the address computation might wrap in the original but not in our5; optimized version. For an input of c = 127 the original accessed address6; would be &I[-1] = &GI[128 -1] = &GI[127] but in our optimized version7; (due to the usage of i64 types) we would access8; &I[127 + 1] = &I[128] = &GI[256] which would here also be out-of-bounds.9;10; CHECK:        Invariant Accesses: {11; CHECK-NEXT:     ReadAccess := [Reduction Type: NONE] [Scalar: 0]12; CHECK-NEXT:       [c] -> { Stmt_for_body[i0] -> MemRef_GI[129 + c] };13; CHECK-NEXT:     Execution Context: [c] -> {  : c <= 126 }14; CHECK-NEXT:   }15;16;    int GI[256];17;    void f(int *A, unsigned char c) {18;      int *I = &GI[128];19;      for (int i = 0; i < 10; i++)20;        A[i] += I[(signed char)(c + (unsigned char)1)];21;    }22;23target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"24 25@GI = common global [256 x i32] zeroinitializer, align 1626 27define void @f(ptr %A, i8 zeroext %c) {28entry:29  br label %for.cond30 31for.cond:                                         ; preds = %for.inc, %entry32  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]33  %exitcond = icmp ne i64 %indvars.iv, 1034  br i1 %exitcond, label %for.body, label %for.end35 36for.body:                                         ; preds = %for.cond37  %add = add i8 %c, 138  %idxprom = sext i8 %add to i6439  %arrayidx = getelementptr inbounds i32, ptr getelementptr inbounds ([256 x i32], ptr @GI, i64 0, i64 128), i64 %idxprom40  %tmp = load i32, ptr %arrayidx, align 441  %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv42  %tmp1 = load i32, ptr %arrayidx3, align 443  %add4 = add nsw i32 %tmp1, %tmp44  store i32 %add4, ptr %arrayidx3, align 445  br label %for.inc46 47for.inc:                                          ; preds = %for.body48  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 149  br label %for.cond50 51for.end:                                          ; preds = %for.cond52  ret void53}54