Issue 152863
Summary [SPIR-V] Invalid OpPhi lowering
Labels new issue
Assignees
Reporter simeonschaub
    `phi_node_issue.ll`:

```llvm
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
target triple = "spirv64-unknown-unknown-unknown"

declare i64 @_Z14atomic_cmpxchgPU8CLglobalVlll(ptr addrspace(1), i64, i64)

define spir_kernel void @_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE(ptr addrspace(1) %0) {
conversion:
  br label %L6

L6: ; preds = %L6, %conversion
  %value_phi = phi i64 [ 0, %conversion ], [ %1, %L6 ]
  %1 = call i64 @_Z14atomic_cmpxchgPU8CLglobalVlll(ptr addrspace(1) %0, i64 %value_phi, i64 0)
  br label %L6
}
```

Compiling with `llc -filetype=obj phi_node_issue.ll -o phi_node_issue.spv, I get the following SPIR-V:

```llvm
; SPIR-V
; Version: 1.4
; Generator: LLVM LLVM SPIR-V Backend; 20
; Bound: 34
; Schema: 0
 OpCapability Kernel
               OpCapability Addresses
 OpCapability Int64
          %1 = OpExtInstImport "OpenCL.std"
 OpMemoryModel Physical64 OpenCL
               OpEntryPoint Kernel %_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE "_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE"
               OpExecutionMode %_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE ContractionOff
 OpSource OpenCL_CPP 100000
               OpName %_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE "_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE"
               OpName %conversion "conversion"
               OpName %value_phi "value_phi"
 OpName %L6 "L6"
      %ulong = OpTypeInt 64 0
%_ptr_CrossWorkgroup_ulong = OpTypePointer CrossWorkgroup %ulong
       %void = OpTypeVoid
 %uint = OpTypeInt 32 0
          %8 = OpConstantNull %ulong
          %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_ulong
     %uint_0 = OpConstant %uint 0
     %uint_2 = OpConstant %uint 2
%_Z3foo13CLDeviceArrayI5Int64Li0ELi1EE = OpFunction %void None %9
 %13 = OpFunctionParameter %_ptr_CrossWorkgroup_ulong
 %conversion = OpLabel
               OpBranch %L6
         %L6 = OpLabel
  %value_phi = OpPhi %ulong %8 %conversion %15 %L6
         %15 = OpAtomicCompareExchange %uint %13 %uint_2 %uint_0 %uint_0 %8 %value_phi
               OpBranch %L6
               OpFunctionEnd
```

Running `spirv-val phi_node_issue.spv` then errors with:

```
error: line 26: OpPhi's result type <id> '4[%ulong]' does not match incoming value <id> '15[%15]' type <id> '7[%uint]'.
  %value_phi = OpPhi %ulong %8 %conversion %15 %L6
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to