[PATCH] D34769: [X86] X86::CMOV to Branch heuristic based optimization

Amjad Aboud via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 11:40:38 PDT 2017


aaboud created this revision.
Herald added a subscriber: mgorny.

LLVM compiler recognizes opportunities to transform a branch into IR select instruction(s) - later it will be lowered into X86::CMOV instruction, assuming no other optimization eliminated the SelectInst.
However, it is not always profitable to emit X86::CMOV instruction. For example, branch is preferable over an X86::CMOV instruction when:

- Branch is well predicted
- Condition operand is expensive, compared to True-value and the False-value operands

In CodeGenPrepare pass there is a shallow optimization that tries to convert SelectInst into branch, but it is not enough.
This patch, implements machine optimization pass that converts X86::CMOV instruction(s) into branch, based on a conservative heuristic.


https://reviews.llvm.org/D34769

Files:
  lib/Target/X86/CMakeLists.txt
  lib/Target/X86/X86.h
  lib/Target/X86/X86CmovConversion.cpp
  lib/Target/X86/X86TargetMachine.cpp
  test/CodeGen/X86/2008-01-08-SchedulerCrash.ll
  test/CodeGen/X86/atomic-minmax-i6432.ll
  test/CodeGen/X86/atomic128.ll
  test/CodeGen/X86/x86-cmov-converter.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34769.104480.patch
Type: text/x-patch
Size: 45108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/51b6a310/attachment.bin>


More information about the llvm-commits mailing list