[PATCH] Don't pretend to have probability information if the result of a bitwise and is compared against 0

Daniel Jasper djasper at google.com
Mon Mar 9 06:28:55 PDT 2015


Hi chandlerc,

The code that originally made me discover this is:

  if ((a & 0x1) == 0x1) {
    ..
  }

In this case we don't actually have any branch probability information and should not assume to have any. LLVM transforms this into:

   %and = and i32 %a, 1
   %tobool = icmp eq i32 %and, 0

So, in this case, the result of a bitwise and is compared against 0. Again, we don't really have information. We could make this check more narrow, e.g. by testing whether the other and-operand is 1 or whether it has a single bit set.

I don't know whether all of the changes to tests here are correct and there is still one that is failing (CodeGen/ARM/2013-10-11-select-stalls.ll), which says "3 post-RA-sched  - Number of pipeline stalls". Not sure whether the latter means that this change is breaking the test or whether it was passing for the wrong reason. Any help here would be appreciated.

http://reviews.llvm.org/D8165

Files:
  lib/Analysis/BranchProbabilityInfo.cpp
  test/CodeGen/AArch64/arm64-call-tailcalls.ll
  test/CodeGen/Mips/octeon.ll
  test/CodeGen/X86/atom-bypass-slow-division-64.ll
  test/CodeGen/X86/atom-bypass-slow-division.ll
  test/CodeGen/X86/peep-test-4.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8165.21481.patch
Type: text/x-patch
Size: 5164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150309/df52b59d/attachment.bin>


More information about the llvm-commits mailing list