[LLVMbugs] [Bug 12382] New: Missed jump threading opportunity.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 28 02:48:53 PDT 2012


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

             Bug #: 12382
           Summary: Missed jump threading opportunity.
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Testcase reduced from GCC PR21417:

---->8---

typedef union tree_node {
  int code;
} *tree;

extern tree foo(void);

tree test (tree expr, int t, int D17630) {
  do {
    if (expr->code != 142)
      return expr;

    if (D17630 == t)
      __builtin_abort();

    expr = foo();
  } while (expr->code == 142);

  return expr;
}

----8<---

For the loop clang -O3 generates
LBB0_3:                                 ## %do.body
                                        ## =>This Inner Loop Header: Depth=1
    cmpl    $142, %ecx
    jne    LBB0_5
## BB#4:                                ## %if.end3
                                        ##   in Loop: Header=BB0_3 Depth=1
    callq    _foo
    movl    $142, %ecx
    cmpl    $142, (%rax)
    je    LBB0_3

GCC is more clever and skips the useless compare:
L5:
    call    _foo
    cmpl    $142, (%rax)
    je    L5

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list