llvm-project/llvm/test/Analysis/BranchProbabilityInfo
John Brawn da4a68a1d2 [BPI] Don't assume that strcmp returning >0 is more likely than <0
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.

Differential Revision: https://reviews.llvm.org/D33934

llvm-svn: 304970
2017-06-08 09:44:40 +00:00
..
basic.ll [BPI] Reduce the probability of unreachable edge to minimal value greater than 0 2017-05-18 06:11:56 +00:00
deopt-intrinsic.ll [BPI] Reduce the probability of unreachable edge to minimal value greater than 0 2017-05-18 06:11:56 +00:00
libfunc_call.ll [BPI] Don't assume that strcmp returning >0 is more likely than <0 2017-06-08 09:44:40 +00:00
loop.ll [PM] Port Branch Probability Analysis pass to the new pass manager. 2016-05-05 02:59:57 +00:00
noreturn.ll [BPI] Reduce the probability of unreachable edge to minimal value greater than 0 2017-05-18 06:11:56 +00:00
pr18705.ll [PM] Port Branch Probability Analysis pass to the new pass manager. 2016-05-05 02:59:57 +00:00
pr22718.ll [PM] Port Branch Probability Analysis pass to the new pass manager. 2016-05-05 02:59:57 +00:00