[llvm-dev] Loop branching inefficiencies in Backend output

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 10 13:01:29 PDT 2017

On 7/9/2017 4:36 PM, Dilan Manatunga via llvm-dev wrote:
> When I looked at the debug output for the x86 backend though, I can't 
> figure out how they realize to get rid of that branch. Up to the last 
> point that MachineInstrs are printed (the rewrite virtual registers 
> pass), the MachineInstrs still show the two jump paradigm. But in the 
> final output, it somehow becomes one branch case.

The "-print-after-all" flag is often useful to figure out what various 
passes do.

> I know one solution is for me to add a pass after basic block 
> placement to change these instructions, but I am wondering if there is 
> a recommended way to do this. Especially as this seems like a common 
> problem, where an existing generic pass would have some interface a 
> backend should support to allow branch re-writes to create the single 
> branch case.

This transform already exists as target-independent code in 
BranchFolding.cpp.  Is TargetInstrInfo::reverseBranchCondition 
implemented for your target?


Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

More information about the llvm-dev mailing list