[PATCH] [CodeGenPrepare.cpp] Feedback on changing logic when to convert select to branch

Gerolf Hoflehner ghoflehner at apple.com
Wed Nov 12 21:10:36 PST 2014


@hfinkel

The proposed change would make this very easy if it turns out to be necessary. In this case for architectures where the branch is *always* more expensive make sure
a) PredictableSelectIsExpensive=false (default for all arch)
b) add a target specific call in isFormingBranchFromSelectProfitable(SI) that overrides any heuristic by saying something like “select is always cheaper than branch”.

For which targets do you suggest adding b)? The only possible candidates are !Cortex, !"LikeA9", Atom:


./lib/CodeGen/TargetLoweringBase.cpp:  PredictableSelectIsExpensive = false; (default)
./lib/Target/AArch64/AArch64ISelLowering.cpp:   if (Subtarget->isCortexA57())  PredictableSelectIsExpensive = true;
./lib/Target/ARM/ARMISelLowering.cpp:  PredictableSelectIsExpensive = Subtarget->isLikeA9();
./lib/Target/R600/AMDGPUISelLowering.cpp:  PredictableSelectIsExpensive = false; (looks redundant)
./lib/Target/X86/X86ISelLowering.cpp:  PredictableSelectIsExpensive = !Subtarget->isAtom();

FWIW, I have not found a regression on x86 or ARM for the change.

http://reviews.llvm.org/D5998






More information about the llvm-commits mailing list