Commit Graph

3532 Commits

Author SHA1 Message Date
Nick Lewycky
4a134afaef Remove ICmpInst::isSignedPredicate which was a reimplementation
CmpInst::isSigned.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85037 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 05:20:17 +00:00
Dan Gohman
32663b719b Rename isLoopExit to isLoopExiting, for consistency with the wording
used elsewhere - an exit block is a block outside the loop branched to
from within the loop. An exiting block is a block inside the loop that
branches out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85019 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 23:34:26 +00:00
Dan Gohman
e6e37b94e8 Rewrite LoopRotation's SSA updating code using SSAUpdater.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 23:19:52 +00:00
Victor Hernandez
66284e063a Auto-upgrade free instructions to calls to the builtin free function.
Update all analysis passes and transforms to treat free calls just like FreeInst.
Remove RaiseAllocations and all its tests since FreeInst no longer needs to be raised.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 04:23:03 +00:00
Victor Hernandez
7b929dad59 Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:09:37 +00:00
Dan Gohman
934af9cfe0 Make LoopDeletion check the maximum backedge taken count, rather than the
exact backedge taken count, when checking for infinite loops. This allows
it to delete loops with multiple exit conditions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 17:10:01 +00:00
Chris Lattner
e00c43fc35 move another load optimization from instcombine -> libanalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84841 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:44:07 +00:00
Chris Lattner
62d327e241 move 'loading i32 from string' optimization from instcombine
to libanalysis.  Instcombine shrinking... does this even 
make sense???


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84840 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:38:35 +00:00
Chris Lattner
878e494670 Move some constant folding logic for loads out of instcombine into
Analysis/ConstantFolding.cpp.  This doesn't change the behavior of
instcombine but makes other clients of ConstantFoldInstruction
able to handle loads.  This was partially extracted from Eli's patch
in PR3152.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84836 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 06:25:11 +00:00
Chris Lattner
7f23958aa4 fix PR5262.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84810 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 00:17:26 +00:00
Chris Lattner
857eb5793e revert r84754, it isn't the right approach. Edwin, please propose
patches for fixes like this instead of committing them directly.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84799 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 23:41:58 +00:00
Victor Hernandez
68afa54033 Make changes to rev 84292 as requested by Chris Lattner.
Most changes are cleanup, but there is 1 correctness fix:
I fixed InstCombine so that the icmp is removed only if the malloc call is removed (which requires explicit removal because the Worklist won't DCE any calls since they can have side-effects).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84772 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 19:11:40 +00:00
Torok Edwin
0739bd0ab2 Fix PR5262: when folding select into PHI, make sure all operands are available
in the PHI's Basic Block. This uses a conservative approach, because we don't
have dominator info in instcombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84754 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 10:49:00 +00:00
Chris Lattner
a52fce49eb make GVN work better when TD is not around:
"In the existing code, if the load and the value to replace it with are
of different types *and* target data is available, it tries to use the
target data to coerce the replacement value to the type of the load.
Otherwise, it skips all effort to handle the type mismatch and just
feeds the wrongly-typed replacement value to replaceAllUsesWith, which
triggers an assertion.

The patch replaces it with an outer if checking for type mismatch, and
an inner if-else that checks whether target data is available and, if
not, returns false rather than trying to replace the load."

Patch by Kenneth Uildriks!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 04:11:19 +00:00
Dan Gohman
cd53f64367 Restore LoopUnswitch's block-oriented threshold. LoopUnswitch now checks both
the estimated code size and the number of blocks when deciding whether to
do a non-trivial unswitch. This protects it from some very undesirable
worst-case behavior on large numbers of loop-unswitchable conditions, such
as in the testcase in PR5259.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 20:06:09 +00:00
Torok Edwin
2b6183d254 Fix PR4313: IPSCCP was not setting the lattice value for the invoke instruction
when the invoke had multiple return values: it set the lattice value only on the
extractvalue.
This caused the invoke's lattice value to remain the default (undefined), and
later propagated to extractvalue's operand, which incorrectly introduces
undefined behavior.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84637 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 15:15:09 +00:00
Owen Anderson
d41ed4e2c4 Refactor lookup_or_add to contain _MUCH_ less duplicated code. Add support for
numbering first class aggregate instructions while we're at it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 22:14:22 +00:00
Owen Anderson
158d86e5b0 Simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 21:14:57 +00:00
Victor Hernandez
a276c603b8 Remove MallocInst from LLVM Instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 01:18:07 +00:00
Victor Hernandez
13ad5aaaff Autoupgrade malloc insts to malloc calls.
Update testcases that rely on malloc insts being present.

Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84292 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 00:00:19 +00:00
Dan Gohman
b00f236b03 Move zext and sext casts fed by loads into the same block as the
load, to help SelectionDAG fold them into the loads, unless
conditions are unfavorable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84271 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 20:59:35 +00:00
Chris Lattner
2ee743b53b only try to fold constantexpr operands when the worklist is first populated,
don't bother every time going around the main worklist.  This speeds up a 
release-asserts opt -std-compile-opts on 403.gcc by about 4% (1.5s).  It
seems to speed up the most expensive instances of instcombine by ~10%.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84171 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 04:59:28 +00:00
Chris Lattner
e2cc1ad230 don't bother calling ConstantFoldInstruction unless there is a use of the
instruction (which disqualifies stores, unreachable, etc) and at least the
first operand is a constant.  This filters out a lot of obvious cases that
can't be folded.  Also, switch the IRBuilder to a TargetFolder, which tries
harder.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84170 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 04:13:44 +00:00
Devang Patel
9674d15120 Use isVoidTy()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84118 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 17:29:00 +00:00
Chris Lattner
8db2cd1fc7 make instcombine's instruction sinking more aggressive in the
presence of PHI nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84103 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-14 15:21:58 +00:00
Devang Patel
228ebd0f4c Check void type before using RAUWd.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84049 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 22:56:32 +00:00
Devang Patel
1bf5ebc7be Do not check use_empty() before replaceAllUsesWith(). This gives ValueHandles a chance to get properly updated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 21:41:20 +00:00
Dan Gohman
597c5e2d32 Use the new CodeMetrics class to compute code size instead of
manually counting instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 20:12:23 +00:00
Dan Gohman
b24f6c7495 Make LoopUnswitch's cost estimation count Instructions, rather than
BasicBlocks, so that it doesn't blindly procede in the presence of
large individual BasicBlocks. This addresses a class of code-size
expansion problems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83992 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 17:50:43 +00:00
Evan Cheng
67d1d1f832 Make licm debug message readable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83908 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-12 22:25:23 +00:00
Dale Johannesen
c1deda50ca Fix warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83870 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-12 18:45:32 +00:00
Chris Lattner
67f7d549db populate instcombine's initial worklist more carefully, causing
it to visit instructions from the start of the function to the
end of the function in the first path.  This greatly speeds up
some pathological cases (e.g. PR5150).

Try #3, this time with some unneeded debug info stuff removed
which was causing dead pointers to be added to the worklist.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83818 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-12 03:58:40 +00:00
Chris Lattner
b152a87b10 revert r83814 for now, it is making the llvm-gcc bootstrap unhappy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83817 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 23:56:08 +00:00
Chris Lattner
6d0111f6c7 populate instcombine's initial worklist more carefully, causing
it to visit instructions from the start of the function to the
end of the function in the first path.  This greatly speeds up
some pathological cases (e.g. PR5150). 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83814 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 23:17:43 +00:00
Chris Lattner
2ad8cf5555 remove some harmful code that would turn an insertelement on an undef
into a shuffle even if it was used by another insertelement.  If the
visitation order of instcombine was wrong, this would turn a chain of
insertelements into a chain of shufflevectors, which was quite painful.

Since CollectShuffleElements handles these cases, the code can just
be nuked.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83810 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 23:02:46 +00:00
Chris Lattner
d088314998 teach instcombine to simplify xor's harder, catching the
new testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83799 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 22:22:13 +00:00
Chris Lattner
7acdf1de06 cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 22:00:32 +00:00
Chris Lattner
a249847008 cleanup, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83795 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:36:10 +00:00
Chris Lattner
d2c58366d8 generalize a transformation even more: we don't care whether the
input the the mul is a zext from bool, just that it is all zeros
other than the low bit.  This fixes some phase ordering issues
that would cause us to miss some xforms in mul.ll when the worklist
is visited differently.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83794 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:29:45 +00:00
Chris Lattner
0036e3a469 simplify a transformation by making it more general.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:22:21 +00:00
Chris Lattner
61488a3310 temporarily revert previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83791 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:05:34 +00:00
Chris Lattner
9a12a786b0 populate instcombine's initial worklist more carefully, causing
it to visit instructions from the start of the function to the
end of the function in the first path.  This greatly speeds up
some pathological cases (e.g. PR5150). 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83790 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 21:04:37 +00:00
Torok Edwin
849a639e17 Remove CleanupDbgInfo, instcombine does this and its not worth duplicating it
here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83789 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 19:58:35 +00:00
Torok Edwin
9289ae85b4 LICM shouldn't sink/delete debug information. Fix this and add a testcase.
For now the metadata of sinked/hoisted instructions is still wrong, but that'll
be fixed when instructions will have debug metadata directly attached.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83786 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 19:15:54 +00:00
Chris Lattner
5a06cf644f when folding duplicate conditions, delete the
now-probably-dead instruction tree feeding it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83778 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 18:39:58 +00:00
Chris Lattner
8af304ab3b implement rdar://7293527, a trivial instcombine that llvm-gcc
gets but clang doesn't, because it is implemented in GCC's
fold routine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83761 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:53:15 +00:00
Chris Lattner
78c552ef30 implement a transformation in jump threading that is currently
done by condprop, but do it in a much more general form.  The
basic idea is that we can do a limited form of tail duplication
in the case when we have a branch on a phi.  Moving the branch
up in to the predecessor block makes instruction selection
much easier and encourages chained jump threadings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 07:24:57 +00:00
Chris Lattner
6b65f47ad5 restructure some code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83756 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 04:40:21 +00:00
Chris Lattner
bdbf1a177d factor some code better and move a function, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83755 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 04:33:43 +00:00
Chris Lattner
e33583b7c2 make jump threading on a phi with undef inputs happen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83754 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 04:18:15 +00:00