<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/129516>129516</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
MachineCSE may not eliminate subexpression compeletely, result in more register using。
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
emelliu
</td>
</tr>
</table>
<pre>
The case is complicate, after simplifying mir like this.
```
bb.0:
def %a
def %b
bb.1:
successors: %bb.2, %bb.3
...
%cmp = cmp xxx
branch %bb.3, %cmp
jmp %bb.2
bb.2:
%1 = MUL_F32 %a, %b
%2 = MUL_F32 %1, %c
%3 = FSUB %1, %2
%4 = MAX %3, %d
...
jmp %bb.4
bb.3:
%4 = MUL_F32 %a, %b
%5 = MUL_F32 %4, %c
%6 = FSUB %4, %5
%7 = FSUB %6, %c
...
bb.4:
...
```
The expectation is machinecse can hoist common expression <%1,%2,%3> and <%4, %5,%6>
but the reality is that after running machine-cse two times, it hoists <%1,%2> and <%4, %5> , so need more register to store temp value %4 and %5, if I run machine-cse once again, the %3 and %6 can be hoisted.
So I think machine cse has some problem。
I create new issue with new git account, please close the https://github.com/llvm/llvm-project/issues/128862。
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyklFGPpCgUhX8NvtyMUVDLevChpqcq6WTnqXeSfdsAXpUZBCPY3fXvN6BVdk1nk002qUQKDvd-HI9w51RvEBtSfiXlt4QvfrBzgyNqrZZE2Pba_DkgSO4QlANpx0kryT0S-gS88ziDU2GuuyrTw6hm0OoXgh-US0l2IlW2_bKTEGlG2IlkJwCAFjsgtOSPf0XYE6X5XeoWKdE5OzvCTlEkUhr6r0O2qtI0XQeElnKcgLBvEJ7w_v6-9RAzN3KA-761hBynbf1n2LaVjwx0xyW0zGPN7z_--PvCKKzwG8Uuop9E-a3PLmJRdHn58fVBQXdFsZY5_bXqN0G7Ce5n_YBcrMjsAbn4L8jlJ1HxGbl6RL4pyl1x2BVBfysBD8wrZLFDbtMfYhLyhu8TSs-9sibEbuRyUAalC0k0MFjlfMjiaE2QzuhcUBL2tLkZzYwPRtgZuGm3xZ07rlaEnQPS4sEPCDNyrfw1tPQD91vA58WYGO6V4kvA8G8WvBrRhXqg_Mrkfkf4l97sDGHsLBjEFkY7h969cqGdt-B8mPE4TvDK9YLrq4yVVnRQHTwHsAcoayQC77kyQRIOFLO27auidwJXVGy31_Fi4Tl8rubXrRaEWgN34OyIMM1WaBzJmZE6IzVddz2DnJF7BINvoJxbEN6UH-LfXnngUtrF-OjOpDFcH1LbYNyAMHg_hW-Z0Auhl175YRGptCOhF61fb48v02x_ovSEXmIDR-glp3Vd0Y8sSduw9siOPMEmPxR5luW0PiZDw2TB27bIeZVXByF4VyF2TLAuq4tW1F2iGprRMmMZy3NaZ8dUcHGsJJMHrA5YHmpSZDhypdNAk9q5TyJHk9NjmVeJ5gK1izcnpXcbCKXhIp2beASx9I4UmQ7Z2Mt45TU231e3n17OMPIrGOsBtRqVCba6RXwIdrh2UaNHfQ2OzugW7UGZ35KzOGX6uznJMuvm_1gdT_na0H8CAAD__-Szv3M">