[LLVMbugs] [Bug 3921] New: dominator optimizer/gvn fails to recognize identical tests

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Mar 31 14:41:41 PDT 2009


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

           Summary: dominator optimizer/gvn fails to recognize identical
                    tests
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: opt
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: echristo at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Here's a simple testcase that shows the problem:

extern int a;

int foo (void)
{
  if (a == 4) { return 5; }
  if (a == 5) { return 4; }
  if (a == 4) { return 5 + a; }
  if (a == 5) { return 4 + a; }

  return a;
}

and the corresponding llvm code (from llvm-gcc -O2):

define i32 @foo() nounwind readonly ssp {
entry:
        %0 = load i32* @a, align 4              ; <i32> [#uses=5]
        %1 = icmp eq i32 %0, 4          ; <i1> [#uses=2]
        br i1 %1, label %bb8, label %bb1

bb1:            ; preds = %entry
        %2 = icmp eq i32 %0, 5          ; <i1> [#uses=2]
        br i1 %2, label %bb8, label %bb3

bb3:            ; preds = %bb1
        br i1 %1, label %bb4, label %bb5

bb4:            ; preds = %bb3
        %3 = add i32 %0, 5              ; <i32> [#uses=1]
        ret i32 %3

bb5:            ; preds = %bb3
        br i1 %2, label %bb6, label %bb8

bb6:            ; preds = %bb5
        %4 = add i32 %0, 4              ; <i32> [#uses=1]
        ret i32 %4

bb8:            ; preds = %bb5, %bb1, %entry
        %.0 = phi i32 [ 5, %entry ], [ 4, %bb1 ], [ %0, %bb5 ]          ; <i32>
[#uses=1]
        ret i32 %.0
}


-- 
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