[LLVMbugs] [Bug 1757] New: Missed optimization: any number greater than two is not equal to two

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Oct 29 22:31:41 PDT 2007


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

           Summary: Missed optimization: any number greater than two is not
                    equal to two
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


declare i32 @asdf();
declare i32 @asdf2();
declare i32 @asdf3();

define i32 @myfunc(i32) {
EntryBlock:
  %.demorgan = icmp sgt i32 %0, 2       
  br i1 %.demorgan, label %GreaterThanTwo, label %LessThanOrEqualToTwo

GreaterThanTwo:
  icmp eq i32 %0, 2
  br i1 %1, label %Impossible, label %NotTwoAndGreaterThanTwo

NotTwoAndGreaterThanTwo:
  call i32 @asdf()
  ret i32 2

Impossible:
  call i32 @asdf2()
  ret i32 1

LessThanOrEqualToTwo:
  call i32 @asdf3()
  ret i32 0
}

"opt -std-compile-opts" leaves this untransformed; the obvious optimization is
to replace the second icmp with a constant zero and simplify the code
appropriately.

It seems like the assembly-level optimization passes should be able to catch
this, although I'm not sure how LLVM deals with this kind of optimization.


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