<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65183>65183</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DirectX backend] redundant bitcast generated in DXILPrepareModule
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:DirectX
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
python3kgae
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
python3kgae
</td>
</tr>
</table>
<pre>
For ir like this.
```
; RUN: opt -S -dxil-prepare < %s | FileCheck %s
target triple = "dxil-unknown-unknown"
; Make sure not crash when has typed ptr.
; CHECK:define i64 @test(ptr %p)
; Make sure no bitcast generated.
; CHECK-NOT:bitcast
@gs = external addrspace(3) global [20 x [6 x float]], align 4
define i64 @test(i64* %p) {
%base = getelementptr inbounds [20 x [6 x float]], ptr addrspace(3) @gs, i64 0, i64 3
%addr = getelementptr inbounds [6 x float], ptr addrspace(3) %base, i64 0, i64 2
store float 1.000000e+00, ptr addrspace(3) %addr, align 4
%v = load i64, i64* %p
ret i64 %v
}
```
Redundant bitcast like
bitcast ptr addrspace(3) @gs to ptr addrspace(3)
will be generated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVF-PozYQ_zTDyyiRsQMJDzwkoVGr9q7VtZXu1eBZcOO1kW32z7evDGRvr7vXjVCcjGd-fwZ7ZAi6t0Q1FCfgfHyOg7Pi2ksCzqFoMjnFwfn61UbWOvVcX5xH7dHoK2EcdNgCa4AdoWTrs_wVJ_zy92cQR3RjxM2fuFFP2mxGT6P0hCDOCLwICPszXrSh80DddQ4tAFH6niJGr0eT0hsEzmeIyV6te7S3NcldKF-IP8krYZg8oXUROy_DgI8DWRxkwPg8ksIx-u23gvPPP51_BXFUdKctoS53CDsWKUTghzH6pGsEXr1Pga2OnQwRe7LkZST1X-jN59__AnFc876Tu2N9mO3RUyRvpUGplA-j7Aj4QQCvsDeulQahOHGGT2kt8QnvjJMRiiY9_IzS6N7i7jX2u250uQN-vBlC2J-W5BRpZVha3VMkQ_dkYzKvbesmq8IHClLqG-2zv7SbVLDbD7FyJtJU8gHpd2Q_ZFr0v-HiN64QnacFB_Mtmz8E_MTY_2Gm2Jv-zsIfZtXGSYVzU8_4urdrnqe4vABePKzvZt-8f2Pm7y-kJqukjS-HKl20Fe0W-nGnMbp3dxeAR20MtvTqnGaqFqoSlcyozstKFFWZlywb6kLkqmL7qmDFQYkir9qcdV17KEuVCynKTNecccEqlucV5zu2lQfGOONlK_d3gok72DG6l9psjXm43zrfZzqEieqyyA8iM7IlE9bh08ruSlaBODbaUxe_riPI16l20059gB0zOsTwDS3qaObptdbgDaVo0L_p4otl1Babr7_89scyiD45NRnKJm_qIcYxgDgCvwC_9DoOU7vt3D3wSyJdl83o3T_UReCX2U8Afpkt_RsAAP__cy2SUA">