[LLVMbugs] [Bug 23827] New: bad code generated code for branches (&, &&)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 12 01:33:26 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23827

            Bug ID: 23827
           Summary: bad code generated code for branches (&, &&)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fkastrati at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

consider the following code snippet (c++):

void ampamp(int x, int y) {
  if (x < 3 && y > 10 ) 
    printf("%d%d", x, y);
}

void amp(int x, int y) {
  if ((x < 3) & (y > 10) ) 
    printf("%d%d", x, y);
}


the assembly code generated by clang++ (all versions I tested), is not optimal.
Basically, for both methods the assembly code is identical. For the method
"amp" (with single `&') there should be generated only one jump, as branch
misprediction penalty is very high otherwise

As a side note: the code by intel's  compiler (ICC) is however generating
optimal code for such scenarios, at least for versions icc13, and icc15 that
I've tested.

See: http://goo.gl/oiTPX5

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150612/89b85742/attachment.html>


More information about the llvm-bugs mailing list