<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 7, 2014 at 9:46 AM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>(B ^ A) | ((B ^ C) ^ A) -> (A ^ B) | C<br><br></span></div><div><span>Both the patterns above are same, since ^ is commutative in Op0. <br>

<br></span></div><div><span>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<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><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></font></span></div>
</blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">It seems to me that we could rejigger Reassociate to reduce the number of possibilities that InstCombine could expect.</div></div>