<div dir="ltr"><div class="gmail_extra">So I've been working on what amounts to peephole optimization because</div><div class="gmail_extra">my application is absolutely blowing up from poor instruction selection.</div><div class="gmail_extra"><br></div><div class="gmail_extra">For example, this is just wrong:
</div><div class="gmail_extra"><br></div><div class="gmail_extra"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">0000000000005df3<span style="white-space:pre-wrap">    </span>btq<span style="white-space:pre-wrap">     </span>$0x16, %rax<br></div><div class="gmail_extra"><br></div></blockquote></div><div class="gmail_extra">I thought that maybe there was a peephole optimizer which 'relaxed' this BTQ</div><div class="gmail_extra">into a normal BT $0x16,EAX but that line is the actual output from otool.</div><div class="gmail_extra">This should be handled in a peephole pass for X86 which doesn't currently exist.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">So I'm writing it.</div><div class="gmail_extra"><br></div><div class="gmail_extra">This pass obviates the patch I submitted for LowerToBT() which can be dropped.</div><div class="gmail_extra">I also think there's a lot of instruction selection gymnastics which would be</div><div class="gmail_extra">better postponed as well. Better to do that all in one pass and in one place.</div><div class="gmail_extra">But that's for later.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'm currently handling this BTQ REX problem as well as substituting in the smallest</div><div class="gmail_extra">and/or fastest BT or TEST instruction. I'll be adding support for accumulator</div><div class="gmail_extra">and short instruction forms. This could be merged with X86FixupLEAs</div><div class="gmail_extra">and perhaps X86CallFrameOptimization as they perform similar tasks.</div><div class="gmail_extra">At least they could be put in the same file if not the same pass.</div><div class="gmail_extra"><br></div><div class="gmail_extra">BTW, I still believe my Const Hoisting patch is very necessary.</div><div class="gmail_extra">This peephole optimizer doesn't change that at all.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Chris</div></div>