[LLVMbugs] [Bug 537] NEW: [instcombine] ptrdiff_t not optimized as well as it could be

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Mar 11 07:46:34 PST 2005


           Summary: [instcombine] ptrdiff_t not optimized as well as it
                    could be
           Product: libraries
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org

Markus Oberhumer writes:

In the example below llvm is only able to optimize
away the subtraction in test1, but not in test2/3.

#include <stddef.h>

int test1(int a, int b) {
    int d = b - a;
    a = b - d;          // no-op
    return a;

char* test2(char* a, char* b) {
    ptrdiff_t d = b - a;
    a = b - d;          // no-op on all llvm-supported machines
    return a;

int test3(char* a, char* b, char* c) {
    ptrdiff_t d = b - a;
    return (d == 8) || ((a = b - d) < c);    // a = ... is a no-op

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list