[LLVMbugs] [Bug 16380] New: Missed optimization opportunities for pointer comparisons

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 19 12:19:27 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16380

            Bug ID: 16380
           Summary: Missed optimization opportunities for pointer
                    comparisons
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthew at dempsky.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Given "p" as an object of type pointer-to-T and "x" as a complete object of
type T, the C++ standard defines the following expressions must either yield
"false" or an unspecified result:

    p < nullptr
    nullptr < p
    p < &x
    &x+1 < p

Thus, the compiler is free to constant fold these expressions to just "false",
and should do so.  Similarly, if "a < b" folds to "false" by matching a pattern
above, "b > a" should also fold to "false", and "a >= b" and "b <= a" should
fold to "true".

Currently, Clang only constant folds the first pattern.

-- 
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/20130619/5e20746e/attachment.html>


More information about the llvm-bugs mailing list