<div dir="ltr"><div>On Sun, Jun 9, 2013 at 10:30 AM, Duncan Sands <span dir="ltr"><<a href="mailto:duncan.sands@gmail.com" target="_blank">duncan.sands@gmail.com</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi David,<div><div class="h5"><br>
<br>
On 09/06/13 12:22, David Majnemer wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Real world code [*] sometimes has the denominator of a 'udiv' be a 'select' but<br>
the select operands may not have the same structural form.<br>
<br>
The attached patch treats the true and false operands as right hand sides of a<br>
divide and feeds them into the same logical than simplified 'udiv' instructions.<br>
<br>
I wouldn't be surprised if there was a better/more systematic way of dealing<br>
with this problem, I'd be happy to implement suggestions.<br>
<br>
--<br>
David Majnemer<br>
<br>
[*] AddressSanitizerModule::<u></u>runOnModule<br>
</blockquote>
<br></div></div>
might this turn this:<br>
<br>
  %x_is_zero = icmp eq i32 %x, 0<br>
  %divisor = select i1 %x_is_zero, i32 1, x<br>
  %y = udiv i32 %z, %divisor<br>
<br>
into:<br>
<br>
  %x_is_zero = icmp eq i32 %x, 0<br>
  %y1 = udiv i32 %z, %x<br>
  %y = select i1 %x_is_zero, i32 %z, %y1<br>
<br>
?<br>
<br>
I.e. turning a safe division into one that map trap.</blockquote><div><br></div><div style>No, the optimization is only worth performing if I can prove that we don't need to perform division at all.</div><div style>This means that both arms of the select must be able to be simplified.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Ciao, Duncan.<br></blockquote><div><br></div><div><br class="">Thanks for looking at the patch!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">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/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>