<div dir="ltr"><div class="gmail_quote">On Thu, May 14, 2015 at 12:17 PM Paweł Bylica <<a href="mailto:chfast@gmail.com">chfast@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi LLVM,<div><br></div><div>I think the potential of divq instruction is not fully exploited by X86 target.</div><div><br></div><div>The following IR can be lowered to one divq instruction:</div><div><div>define i64 @div128by64lo(i128 %d, i64 %n) nounwind readnone {</div><div>  %m = zext i64 %n to i128</div><div>  %q = udiv i128 %d, %m</div><div>  %q.l = trunc i128 %q to i64</div><div>  ret i64 %q.l</div><div>}</div></div><div><br></div><div>And that one can be 2 divq instructions:</div><div><div>define i128 @div128by64full(i128 %d, i64 %n) nounwind readnone {</div><div>  %m = zext i64 %n to i128</div><div>  %q = udiv i128 %d, %m</div><div>  ret i128 %q</div><div>}</div></div><div><br></div><div>In current implementation, everywhere where i128 type shows up codegen generates a call to  __udivti3 builtin function.</div><div><br></div><div>Am I missing something?</div></div><div dir="ltr"><div>- Paweł</div></div></blockquote><div><br></div><div>I also found a GCC bug report about that:</div><div><a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58897">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58897</a> </div></div></div>