[llvm-dev] How can I tell llvm, that a branch is preferred ?

Nat! via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 27 10:55:19 PDT 2015


If I read the llvm language correctly, it doesn't have a way to specify 
the preferred branch, correct ? I see nothing in the specs for "branch" 
or "switch". And __buildin_expect does nothing, that I am sure of.

Unfortunately llvm has this knack for ordering my one most crucial part 
of code exactly the opposite I want to, it does: (x86_64)

	cmpq	%r15, (%rax,%rdx)
	jne	LBB0_3
Ltmp18:
	leaq	8(%rax,%rdx), %rcx
	jmp	LBB0_4
LBB0_3:
	addq	$8, %rcx
LBB0_4:



when I want,

	cmpq	%r15, (%rax,%rdx)
	jeq	LBB0_3

	addq	$8, %rcx
	jmp	LBB0_4
LBB0_3:
	leaq	8(%rax,%rdx), %rcx
LBB0_4:

since that saves me executing a jump 99.9% of the time. Is there 
anything I can do ?

Ciao
    Nat!


More information about the llvm-dev mailing list