<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>All, Duncan, Rafael, David, Nick.<br><br></div>This is regarding pattern matching in InstructionCombine pass.<br><br></div>We use 'match' functions many times, but it doesn't do the pattern matching<br>
</div>effectively.<br><br></div>e.x. Lets take pattern :<br><br>(A ^ B) | ((B ^ C) ^ A) -> (A ^ B) | C<br><br></div><span class="">(B ^ A) | ((B ^ C) ^ A) -> (A ^ B) | C<br><br></span></div><div><span class="">Both the patterns above are same, since ^ is commutative in Op0. <br>
<br></span></div><div><span class="">But, </span>'match' pattern has to be written for both the patterns separately<br></div><div>since 'match' identifies pattern as it (like regular expression) and doesn't <br>
</div><div>have the logic to determine that 'A^B' and 'B^A' are same.<br><br></div><div>I propose to improve 'match' functions where we can include the logic<br></div><div>to determine if an operation is commutative or not. If it is commutative,<br>
</div><div>then a single 'match' call should be able to detect both 'A^B' and 'B^A'.<br></div><div>So, basically we will modify the commutative 'match' functions.<br></div><div><br></div><div>
</div><div>There will be various permutations of it where one of the operand might be<br></div><div>a constant (I guess this is handled already as constant are re-associated to<br></div><div>RHS). <br><br></div><div>I will try to dig more on this.<br>
</div><div><br></div><div>Inputs/suggestions/comments on improving match functions are most awaited. :)<br><br></div><div>Regards,<br></div><div>Suyog<br></div><div><div><div><div><div><div><div><div><div><br>-- <br>With regards,<br>
Suyog Sarda<br>
</div></div></div></div></div></div></div></div></div></div>