[LLVMbugs] [Bug 15584] New: Invalid optimization for 8-byte integers with -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 25 04:38:42 PDT 2013


            Bug ID: 15584
           Summary: Invalid optimization for 8-byte integers with -O2
           Product: new-bugs
           Version: 3.2
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: rybalkin at ggasoftware.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10237
  --> http://llvm.org/bugs/attachment.cgi?id=10237&action=edit
example source code

Provided source code gives incorrect result with -O2 optimization flags.

It reports that number of one bits in 0xFFFFFFFFFFFFFFFFULL 64 without
optimizations and less then 64 (random results like 58, 59, 60) with -O2 flags.

This code computes number of common 'one' bits in two binary arrays:

1. bitGetOnesCountByte is a simple table lookup function to get number of one
bits in a single byte.

2. bitGetOnesCount method counts number of one bits in a binary array

3. bitCommonOnes method counts common one bits in two qword-arrays. It perform
bit and operation and count number of one bits in the result via
bitGetOnesCount method.

Compile inlines bitGetOnesCount in bitCommonOnes method and unroll loop because
number of bytes in qword is 8. Probably the bug is due to this step.

Clang version: 
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix

Reproduced on Mac OS X 10.7 and Mac OS X 10.8.
Not reproduced on Debian with clang 3.0.

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/20130325/0b87edf9/attachment.html>

More information about the llvm-bugs mailing list