<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/149853>149853</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[VectorCombine] Don't use Builder.Create* methods when replacing flags
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm::vectorcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
As detailed here: https://github.com/llvm/llvm-project/pull/148350#discussion_r2217774107
> Since we use IRBuilder<InstSimplifyFolder> in VectorCombine, the result may point to an existing cast instruction instead of CastOp (NewOp). Therefore, it may propagate flags into an incorrect instruction. I recommend using CastInst::Create instead of Builder.CreateCast.
Technically we only need to update the instructions where we're replacing the flags, but probably we want to be consistent at least per-fold if not everywhere.
CC @rhyadav @dtcxzyw
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU01r8zgQ_jXyZXiNLdlxfPAhTRsoC1toy14XWZrEWmTJSOOk3l-_SGnZ9viCwcIWz9c8I2M0F4c4sPaBtY-FXGnyYXj9483M3hWj19twiKCRpLGoYcKATBxgIloiEwfGT4yfLoamdSyVnxk_WXv9ev1agv8HFTF-WlZrGT_VzV60FeNCm6jWGI13fwfO667rmrrqWHVIj3iCN-MUwg1hjQjPrw-rsRoDE8dnF-nNzIs15-3k7x-fwDj4CxX5cPTzaBwyfgSaEALG1RLMcoPFG0dAHqQD_DCRjLuAkpHAuEhhVWS8y2eUGvwZjjLSywKM7__E28vCeF_Cewrg7EMmMJ_AwS_yIgnhbOUlgnF3EuOUDwHVD4ISniGg8vOMTsMak4hElGylPMXhGDBhfRPyab68_0m3y3tQ76gmZ5S0dktReWc3cIg6uVwXnWBSCN_oI9ySA7gh411I-SxWqiQiXcz6k7NxpWRrlOMd-Sbv0Y0IyrtoIqEjkAQWU4ALhl9nbzWYMzhPgFcMWyb6FHo8AmuqMG1Sy2s6alIf_243KPQgdC96WeBQd62o627f7opp6Fsumr7XTYf7vejqqpFqVH2l-B53oukKM_CKt1XH67qrq3ZXcil3ApWqzrreaS1ZU-EsjS1TE0sfLoWJccWhbvp9KworR7Qx957z3Nmc_jW3SH21iKelCEMu87heImsqayLF_0HJkM3r87N_7SM8esd4R7nBP0fI-AFmpMnrPA_3bQx5BMUa7PDbK5btxbxk2eF14P8FAAD__-WXTUk">