[polly] r250517 - Avoid unnecessay .s2a write access when used only in PHIs

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 14:35:35 PDT 2015


On 10/16/2015 05:14 PM, Michael Kruse via llvm-commits wrote:
> Author: meinersbur
> Date: Fri Oct 16 10:14:40 2015
> New Revision: 250517
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250517&view=rev
> Log:
> Avoid unnecessay .s2a write access when used only in PHIs
>
> PHI accesses will be handled separately by buildPHIAccesses,
> buildScalarDependences does not need to create additional accesses.

Hi Michael,

thanks for finding this redundancy. Just a couple of hours ago I looked 
at a case where I had the feeling certain accesses could be eliminated. 
Unfortunately, it seems the change as it is is not fully correct. I now 
get a crash when executing:

polly-opt -polly-scops 
test/ScopInfo/NonAffine/non-affine-loop-condition-dependent-access_2.ll 
-polly-process-unprofitable -analyze -polly-codegen

Also, in the attached test case I would expect us to model the
edge to the PHI node. Scalar dependences to PHI nodes can probably only 
be ignored if the PHI node itself is within the scop.

Best,
Tobias
-------------- next part --------------
; RUN: opt %loadPolly -analyze -polly-scops %s | FileCheck %s

; Check that PHI nodes only create PHI access and nothing else (e.g. unnecessary
; SCALAR accesses)In this case, for a PHI in the exit node, hence there is no
; PHI ReadAccess.

; CHECK-LABEL: Function: foo
; CHECK:       Statements {
; CHECK-NEXT:      Stmt_header
; CHECK-NEXT:          Domain :=
; CHECK-NEXT:              { Stmt_header[] };
; CHECK-NEXT:          Schedule :=
; CHECK-NEXT:              { Stmt_header[] -> [0, 0] };
; CHECK-NEXT:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
; CHECK-NEXT:              { Stmt_header[] -> MemRef_phi[] };
; CHECK-NEXT:      Stmt_body
; CHECK-NEXT:          Domain :=
; CHECK-NEXT:              { Stmt_body[i0] : i0 <= 100 and i0 >= 0 };
; CHECK-NEXT:          Schedule :=
; CHECK-NEXT:              { Stmt_body[i0] -> [1, i0] };
; CHECK-NEXT:          MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
; CHECK-NEXT:              { Stmt_body[i0] -> MemRef_phi[] };
; CHECK-NEXT:   }

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

define float @foo(float* %A) {
entry:
  br label %header

header:
  fence seq_cst
  br i1 true, label %body, label %exit

body:
  %i = phi i64 [ 0, %header ], [ %next, %body ]
  %sum = phi float [ 0.0, %header ], [ %sum.next, %body ]
  %arrayidx = getelementptr float, float* %A, i64 %i
  %scalar = fadd float 0.0, 0.0
  %next = add nuw nsw i64 %i, 1
  %val = load float, float* %arrayidx
  %sum.next = fadd float %sum, %val
  %cond = icmp ne i64 %i, 100
  br i1 %cond, label %body, label %after

after:
  br label %exit

exit:
  %phi = phi float [%sum.next, %after], [0.0, %header]
  ret float %phi
}


More information about the llvm-commits mailing list