<div dir="ltr"><div><div><div><div>Hi,<br><br></div>AFAICT there are two places where zext instructions may get folded into PHI nodes. One is FoldPHIArgZextsIntoPHI and the other is the more generic FoldPHIArgOpIntoPHI. Now, the former only handles PHIs with more than 2 incoming values, while the latter only handles casts where the source type is legal.<br><br>This means that for an PHI node with two incoming i8 values, both resulting from `zext i1 * to i8` instructions, both of these functions will refuse to actually fold the zext into the PHI, while the same operation would be performed if there were three or more arms. We noticed this because we saw a optimization regression when a function got specialized and the PHI node only had two incoming values left.<br><br></div>Since I'm not fully aware of any implications this might have, I wonder what is the right way to fix this? Looking at FoldPHIArgZextsIntoPHI, it seems that making the check for `ShouldChangeType` in FoldPHIArgOpIntoPHI conditional on the cast instruction not being a zext instruction. Does that sound right, or am I missing something here?<br><br></div>Thanks<br></div>Björn<br></div>