[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-commits
Subject:    [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
From:       Chris Lattner <lattner () cs ! uiuc ! edu>
Date:       2004-04-29 23:38:01
Message-ID: 200404300438.XAA31214 () zion ! cs ! uiuc ! edu
[Download RAW message or body]


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.194 -> 1.195

---
Log message:

Fix a major pessimization in the instcombiner.  If an allocation instruction
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.

Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function.  This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.

This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)



---
Diffs of the changes:  (+1 -1)

Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.194 \
                llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.195
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.194	Tue Apr 27 10:12:23 \
                2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Apr 29 23:37:52 2004
@@ -2035,7 +2035,7 @@
             New = new MallocInst(CastElTy, Amt, Name);
           else
             New = new AllocaInst(CastElTy, Amt, Name);
-          InsertNewInstBefore(New, CI);
+          InsertNewInstBefore(New, *AI);
           return ReplaceInstUsesWith(CI, New);
         }
       }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic