reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
; RUN: opt -mtriple=amdgcn-amd-amdhsa -basicaa -load-store-vectorizer -S -o - %s | FileCheck %s
; RUN: opt -mtriple=amdgcn-amd-amdhsa -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' -S -o - %s | FileCheck %s

target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"

; Check position of the inserted vector load/store.  Vectorized loads should be
; inserted at the position of the first load in the chain, and stores should be
; inserted at the position of the last store.

; CHECK-LABEL: @insert_load_point(
; CHECK: %z = add i32 %x, 4
; CHECK: load <2 x float>
; CHECK: %w = add i32 %y, 9
; CHECK: %foo = add i32 %z, %w
define amdgpu_kernel void @insert_load_point(float addrspace(1)* nocapture %a, float addrspace(1)* nocapture %b, float addrspace(1)* nocapture readonly %c, i64 %idx, i32 %x, i32 %y) #0 {
entry:
  %a.idx.x = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx
  %c.idx.x = getelementptr inbounds float, float addrspace(1)* %c, i64 %idx
  %a.idx.x.1 = getelementptr inbounds float, float addrspace(1)* %a.idx.x, i64 1
  %c.idx.x.1 = getelementptr inbounds float, float addrspace(1)* %c.idx.x, i64 1

  %z = add i32 %x, 4
  %ld.c = load float, float addrspace(1)* %c.idx.x, align 4
  %w = add i32 %y, 9
  %ld.c.idx.1 = load float, float addrspace(1)* %c.idx.x.1, align 4
  %foo = add i32 %z, %w

  store float 0.0, float addrspace(1)* %a.idx.x, align 4
  store float 0.0, float addrspace(1)* %a.idx.x.1, align 4

  %add = fadd float %ld.c, %ld.c.idx.1
  store float %add, float addrspace(1)* %b, align 4
  store i32 %foo, i32 addrspace(3)* null, align 4
  ret void
}

; CHECK-LABEL: @insert_store_point(
; CHECK: %z = add i32 %x, 4
; CHECK: %w = add i32 %y, 9
; CHECK: store <2 x float>
; CHECK: %foo = add i32 %z, %w
define amdgpu_kernel void @insert_store_point(float addrspace(1)* nocapture %a, float addrspace(1)* nocapture %b, float addrspace(1)* nocapture readonly %c, i64 %idx, i32 %x, i32 %y) #0 {
entry:
  %a.idx.x = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx
  %c.idx.x = getelementptr inbounds float, float addrspace(1)* %c, i64 %idx
  %a.idx.x.1 = getelementptr inbounds float, float addrspace(1)* %a.idx.x, i64 1
  %c.idx.x.1 = getelementptr inbounds float, float addrspace(1)* %c.idx.x, i64 1

  %ld.c = load float, float addrspace(1)* %c.idx.x, align 4
  %ld.c.idx.1 = load float, float addrspace(1)* %c.idx.x.1, align 4

  %z = add i32 %x, 4
  store float 0.0, float addrspace(1)* %a.idx.x, align 4
  %w = add i32 %y, 9
  store float 0.0, float addrspace(1)* %a.idx.x.1, align 4
  %foo = add i32 %z, %w

  %add = fadd float %ld.c, %ld.c.idx.1
  store float %add, float addrspace(1)* %b, align 4
  store i32 %foo, i32 addrspace(3)* null, align 4
  ret void
}

; Here we have four stores, with an aliasing load before the last one.  We can
; vectorize the first three stores as <3 x float>, but this vectorized store must
; be inserted at the location of the third scalar store, not the fourth one.
;
; CHECK-LABEL: @insert_store_point_alias
; CHECK: store <3 x float>
; CHECK: load float, float addrspace(1)* %a.idx.2
; CHECK: store float
; CHECK-SAME: %a.idx.3
define float @insert_store_point_alias(float addrspace(1)* nocapture %a, i64 %idx) {
  %a.idx = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx
  %a.idx.1 = getelementptr inbounds float, float addrspace(1)* %a.idx, i64 1
  %a.idx.2 = getelementptr inbounds float, float addrspace(1)* %a.idx.1, i64 1
  %a.idx.3 = getelementptr inbounds float, float addrspace(1)* %a.idx.2, i64 1

  store float 0.0, float addrspace(1)* %a.idx, align 4
  store float 0.0, float addrspace(1)* %a.idx.1, align 4
  store float 0.0, float addrspace(1)* %a.idx.2, align 4
  %x = load float, float addrspace(1)* %a.idx.2, align 4
  store float 0.0, float addrspace(1)* %a.idx.3, align 4

  ret float %x
}

; Here we have four stores, with an aliasing load before the last one.  We
; could vectorize two of the stores before the load (although we currently
; don't), but the important thing is that we *don't* sink the store to
; a[idx + 1] below the load.
;
; CHECK-LABEL: @insert_store_point_alias_ooo
; CHECK: store float
; CHECK-SAME: %a.idx.3
; CHECK: store float
; CHECK-SAME: %a.idx.1
; CHECK: store float
; CHECK-SAME: %a.idx.2
; CHECK: load float, float addrspace(1)* %a.idx.2
; CHECK: store float
; CHECK-SAME: %a.idx
define float @insert_store_point_alias_ooo(float addrspace(1)* nocapture %a, i64 %idx) {
  %a.idx = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx
  %a.idx.1 = getelementptr inbounds float, float addrspace(1)* %a.idx, i64 1
  %a.idx.2 = getelementptr inbounds float, float addrspace(1)* %a.idx.1, i64 1
  %a.idx.3 = getelementptr inbounds float, float addrspace(1)* %a.idx.2, i64 1

  store float 0.0, float addrspace(1)* %a.idx.3, align 4
  store float 0.0, float addrspace(1)* %a.idx.1, align 4
  store float 0.0, float addrspace(1)* %a.idx.2, align 4
  %x = load float, float addrspace(1)* %a.idx.2, align 4
  store float 0.0, float addrspace(1)* %a.idx, align 4

  ret float %x
}

attributes #0 = { nounwind }