<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109401>109401</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPIR-V] Backend emits invalid types in OpPhi
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
VyacheslavLevytskyy
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
VyacheslavLevytskyy
</td>
</tr>
</table>
<pre>
SPIR-V Backend emits invalid types in OpPhi in the following reproducer:
```
define ptr @foo(i1 %arg) {
entry:
br i1 %arg, label %if.then.i, label %if.end.i
if.then.i:
%r1 = tail call ptr @f1()
br label %exit
if.end.i:
%r2 = tail call ptr @f2()
br label %exit
exit:
%ret = phi ptr [ %r1, %if.then.i ], [ %r2, %if.end.i ]
ret ptr %ret
}
define ptr @f1() {
entry:
%p = alloca i8
store i8 8, ptr %p
ret ptr %p
}
define ptr @f2() {
entry:
%p = alloca i32
store i32 32, ptr %p
ret ptr %p
}
```
spirv-val output:
```
$ spirv-val 1.spv
error: line 41: OpPhi's result type <id> '4[%_ptr_Function_uchar]' does not match incoming value <id> '15[%r2]' type <id> '8[%_ptr_Function_uint]'.
%ret = OpPhi %_ptr_Function_uchar %r1 %22 %r2 %23
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlFtvqzgQgH_N8DIKguH-wMOm2UgrrbTVrtTXyoAJ3joY2Yae_PsjDGkuJz1qpYhgPP78-TLDjBGHnvMSki0QvZxY3XEj2fQ3n07WvJ1OQATJzmOj7ZQuHwR4lWpO5X_Pf_27ecEtq9943yA_CmtQ9BOTokF7Gvjcwn-G507ML7bj2Cop1bvoD6j5oFUz1lxD9AcEOwjOzzRYf67Z8Fb0HAerEeKgVQooFyECJUwfgAqEbLtE8t7q0wcMsdJ4FfiEklVczm3R-rbjvS_uv_K-8cW1yyXyggVKdIgQ7dAyIbFmUn7YhUA5UHFl8IHnP4S9Qy_T3ZLpEzJ9nezat1RuHXboxAJMtssy5g243hCEZOe-rQF0CXCyrn_lzlAHc_xVINtdm9yd3bo7n58YUDI4USalqhmK_NxjrNIcRY75bLROOzxQGb4iQt8WiejOJCKM6Lsutzd7eZpB6GkzMYlqtMNof58NQDFeRoS-GaZ1BVqrOZNQzguNw_nVZR5QZlBzM0rrchIhehINRH8iUBa7EpC8Dla_7se-tkL1r2PdMe0uQoaN4gZ7ZfHIbN2h6Gt1nLN3YnK8RYXJwtK0Dv1lsvzhZKK3ywD_wYVdasdjw3MiUkJ0Th1KKLrbN68po6aICubxMswozaOgSGOvK5s2zeKoido2C-u4rrIiCzhRkdd1UlGaeqKkgOKgoCAMwzSI_SLNeJI3FaMiTKu2hTjgRyakL-V09JU-eMKYkZdhUMRB6LkENWuV7fk7ut61tupyHrSpxoOBOJDCWHPBWGGlK89LhYVk96Ui641alp21g5kvEe2B9gdhu7Hya3UE2s_89W8zaPU_ry3Q3lkZoP2qPZX0MwAA__-pFL9K">