[PATCH] D33934: [BPI] Don't assume that strcmp returning >0 is more likely than <0
John Brawn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 04:57:45 PDT 2017
john.brawn created this revision.
The zero heuristic assumes that integers are more likely positive than negative, but this also has the effect of assuming that strcmp return values are more likely positive than negative. Given that for nonzero strcmp return values it's the ordering of arguments that determines the sign of the result there's no reason to assume that's true.
Fix this by inspecting the LHS of the compare and using TargetLibraryInfo to decide if it's strcmp-like, and if so only assume that nonzero is more likely than zero i.e. strings are more often different than the same. This causes a slight code generation change in the spec2006 benchmark 403.gcc, but with no noticeable performance impact. The intent of this patch is to allow better optimisation of dhrystone on Cortex-M cpus, but currently it won't as there are also some changes that need to be made to if-conversion.
Repository:
rL LLVM
https://reviews.llvm.org/D33934
Files:
include/llvm/Analysis/BranchProbabilityInfo.h
include/llvm/Analysis/LazyBranchProbabilityInfo.h
lib/Analysis/BranchProbabilityInfo.cpp
lib/Analysis/LazyBranchProbabilityInfo.cpp
lib/Transforms/Scalar/JumpThreading.cpp
test/Analysis/BranchProbabilityInfo/call.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33934.101542.patch
Type: text/x-patch
Size: 17610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170606/5886c8e3/attachment.bin>
More information about the llvm-commits
mailing list