LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1296 - poor codegen for code size
Summary: poor codegen for code size
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: 1.0
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: code-quality
Depends on:
Blocks:
 
Reported: 2007-03-30 20:18 PDT by Chris Lattner
Modified: 2010-02-22 12:48 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2007-03-30 20:18:19 PDT
This contrived testcase:

int foo(int A, int B, int C) {
  int i;
  int result = 0;

  if (A == 1)  {
    for (i = 0; i < 1000; ++i) {
      if (i & B) {result = 1; break; }
    }
  } else if (A == 0) {
    for (i = 0; i < 1000; ++i) {
      if (i & C) {result = 1; break; }
   }
  } else if (A == 2) {
    for (i = 0; i < 1000; ++i) {
      if (i & C) {result = 1; break; }
    }
  }

out:
  return result;
}

Produces silly code like this:

LBB1_19:        #bb13.out.loopexit1_crit_edge
        movl $1, %eax
        jmp LBB1_15     #out
LBB1_20:        #bb.out.loopexit_crit_edge
        movl $1, %eax
        jmp LBB1_15     #out
LBB1_21:        #bb27.out.loopexit3_crit_edge
        movl $1, %eax
        jmp LBB1_15     #out
Comment 1 Chris Lattner 2007-03-30 20:21:37 PDT
mine
Comment 2 Chris Lattner 2007-04-01 20:36:35 PDT
Implemented.  Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070326/046639.html

Testcase here: CodeGen/Generic/phi-immediate-factoring.ll

-Chris