-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a constant in a phi node, we don't want to create a gep before it. Instead create a gep in the basicblock of the incoming value of the PHI node. Ref #1208
- Loading branch information
Showing
3 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; RUN: clspv-opt %s -o %t.ll --passes=cluster-constants | ||
; RUN: FileCheck %s < %t.ll | ||
|
||
; CHECK: entry: | ||
; CHECK: [[gep_entry:%[^ ]+]] = getelementptr inbounds { <{ [4 x i32] }> }, ptr addrspace(2) @clspv.clustered_constants, i32 0, i32 0 | ||
; CHECK: br i1 %test, label %true, label %false | ||
; CHECK: true: | ||
; CHECK: [[gep_true:%[^ ]+]] = getelementptr inbounds { <{ [4 x i32] }> }, ptr addrspace(2) @clspv.clustered_constants, i32 0, i32 0 | ||
; CHECK: br i1 %test2, label %exit, label %false | ||
; CHECK: false: | ||
; CHECK: %phi = phi ptr addrspace(2) [ [[gep_entry]], %entry ], [ [[gep_true]], %true ] | ||
|
||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir-unknown-unknown" | ||
|
||
@data = addrspace(2) constant <{ [4 x i32] }> <{ [ 4 x i32 ] zeroinitializer }>, align 4 | ||
|
||
; Function Attrs: convergent nounwind | ||
define spir_kernel void @foo(i1 %test, i1 %test2) { | ||
entry: | ||
br i1 %test, label %true, label %false | ||
true: | ||
br i1 %test2, label %exit, label %false | ||
false: | ||
%phi = phi ptr addrspace(2) [ @data, %entry ], [ @data, %true] | ||
br label %exit | ||
exit: | ||
ret void | ||
} |
38 changes: 38 additions & 0 deletions
38
test/NormalizeGlobalVariables/cluster_constants_phi_physical_storage_buffers.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; RUN: clspv-opt %s -o %t.ll --passes=cluster-constants --physical-storage-buffers | ||
; RUN: FileCheck %s < %t.ll | ||
|
||
; CHECK: entry: | ||
; CHECK: [[load:%[^ ]+]] = load i64, ptr addrspace(9) @__push_constants, align 8 | ||
; CHECK: [[ptr:%[^ ]+]] = inttoptr i64 [[load]] to ptr addrspace(2) | ||
; CHECK: [[gep_entry:%[^ ]+]] = getelementptr inbounds { <{ [4 x i32] }> }, ptr addrspace(2) [[ptr]], i32 0, i32 0 | ||
; CHECK: br i1 %test, label %true, label %false | ||
; CHECK: true: | ||
; CHECK: [[load:%[^ ]+]] = load i64, ptr addrspace(9) @__push_constants, align 8 | ||
; CHECK: [[ptr:%[^ ]+]] = inttoptr i64 [[load]] to ptr addrspace(2) | ||
; CHECK: [[gep_true:%[^ ]+]] = getelementptr inbounds { <{ [4 x i32] }> }, ptr addrspace(2) [[ptr]], i32 0, i32 0 | ||
; CHECK: br i1 %test2, label %exit, label %false | ||
; CHECK: false: | ||
; CHECK: %phi = phi ptr addrspace(2) [ [[gep_entry]], %entry ], [ [[gep_true]], %true ] | ||
|
||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%0 = type { i64 } | ||
@data = addrspace(2) constant <{ [4 x i32] }> <{ [ 4 x i32 ] zeroinitializer }>, align 4 | ||
@__push_constants = addrspace(9) global %0 zeroinitializer, !push_constants !0 | ||
|
||
; Function Attrs: convergent nounwind | ||
define spir_kernel void @foo(i1 %test, i1 %test2) { | ||
entry: | ||
br i1 %test, label %true, label %false | ||
true: | ||
br i1 %test2, label %exit, label %false | ||
false: | ||
%phi = phi ptr addrspace(2) [ @data, %entry ], [ @data, %true] | ||
br label %exit | ||
exit: | ||
ret void | ||
} | ||
|
||
!0 = !{i32 9} |