<div dir="ltr">It is not uncommon to see code like the following:<div><br></div><div>(x << n) | (x >> (-n & 31))<br></div><div><br></div><div>This is convenient because it properly handles the cases where n is zero whereas:</div>
<div><br></div><div>(x << n) | (x >> (32 - n))<br></div><div><br></div><div>suffers from undefined behavior in that case.</div><div><br></div><div>The attached patch teaches SelectionDAG's DAGCombiner how to fold the first pattern into a rotation.</div>
</div>