[LLVMdev] X86 peephole optimization

Chris Sears chris.sears at gmail.com
Sun Feb 8 14:03:23 PST 2015


So I've been working on what amounts to peephole optimization because
my application is absolutely blowing up from poor instruction selection.

For example, this is just wrong:

0000000000005df3 btq $0x16, %rax

I thought that maybe there was a peephole optimizer which 'relaxed' this BTQ
into a normal BT $0x16,EAX but that line is the actual output from otool.
This should be handled in a peephole pass for X86 which doesn't currently
exist.

So I'm writing it.

This pass obviates the patch I submitted for LowerToBT() which can be
dropped.
I also think there's a lot of instruction selection gymnastics which would
be
better postponed as well. Better to do that all in one pass and in one
place.
But that's for later.

I'm currently handling this BTQ REX problem as well as substituting in the
smallest
and/or fastest BT or TEST instruction. I'll be adding support for
accumulator
and short instruction forms. This could be merged with X86FixupLEAs
and perhaps X86CallFrameOptimization as they perform similar tasks.
At least they could be put in the same file if not the same pass.

BTW, I still believe my Const Hoisting patch is very necessary.
This peephole optimizer doesn't change that at all.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150208/2b600a79/attachment.html>


More information about the llvm-dev mailing list