Hm. I wish m_Power2 did this internally, but I can also see that this is following a pattern like m_One and friends that only match constants.<div><br></div><div>One other question though, why not transform shl+zext into zext+shl? Casts should be at the outside as much as possible -- functions should have expansions first, then math in the expanded bitwidths, then truncates -- so that we don't have these operations in the middle of expressions because they cause problems, just like the one symptom you're seeing here.</div>

<div><br></div><div>Nick</div><div><div><br><div class="gmail_quote">On 1 October 2012 13:27, Michael Gottesman <span dir="ltr"><<a href="mailto:mgottesman@apple.com" target="_blank">mgottesman@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently LLVM optimizes urem appropriately for power of two quotients if<br>
the numerator and quotient are the same size. On the other hand if the<br>
quotient is a power of two which is zero extended, pattern matching fails<br>
resulting in no optimizations occuring. This patch adds code to InstCombine<br>
to properly match and handle this case.<br>
<br>
Patch by David Majnemer. Test Case by me.<br>
<br>
Please review,<br>
<br>
<br><br>
<br>
Michael<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>