Commit Graph

1520 Commits

Author SHA1 Message Date
Chris Lattner
b1919e2f08 Privatize StructLayout::MemberOffsets, adding an accessor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34156 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-10 19:55:17 +00:00
Reid Spencer
9133fe2895 Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in
the Transforms library. This reduces debug library size by 132 KB, debug
binary size by 376 KB, and reduces link time for llvm tools slightly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33939 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 23:32:05 +00:00
Reid Spencer
688b0490e2 For PR411:
Adjust to changes in Module interface:
getMainFunction() -> getFunction("main")
getNamedFunction(X) -> getFunction(X)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33922 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 21:19:13 +00:00
Chris Lattner
b0b991a2c8 Fix miscompilations of consumer-typeset, telecomm-gsm, and 176.gcc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33902 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 05:57:49 +00:00
Chris Lattner
4f3ebab172 fix a miscompilation of 176.gcc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33900 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 04:09:35 +00:00
Chris Lattner
b87056f111 rewrite shift/shift folding, now that types are not signed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33892 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-05 00:57:54 +00:00
Nick Lewycky
4535175328 Fix indenting, remove tabs.
Learn from sext and zext. The destination value falls within the range of the
source type.

Generalize properties regarding constant ints.

Get smarter about marking blocks as unreachable. If 1 >= 2 in order for this
block to execute, then it isn't reachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33889 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 23:43:05 +00:00
Reid Spencer
6734b57d1b For PR1163:
Make the Module's dependent library use a std::vector instead of SetVector
adjust #includes in .cpp files because SetVector.h is no longer included.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33855 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-04 00:40:42 +00:00
Chris Lattner
7f3da2dd13 remove some dead code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33845 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-03 23:28:07 +00:00
Chris Lattner
5e665f5594 Switch inliner over to use DenseMap instead of std::map for ValueMap. This
speeds up the inliner 16%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33801 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-03 00:08:31 +00:00
Chris Lattner
c1ec780d1e Switch this back to using an std::map. DenseMap entries are getting invalidated
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33799 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 22:36:16 +00:00
Chris Lattner
1c1f112f74 Remove more malloc thrashing, this speeds up IPSCCP on kimwitu another 6.7%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33796 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 21:15:06 +00:00
Chris Lattner
cc56aad06d Convert an std::set to SmallSet, this speeds up IPSCCP 17% on kimwitu.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33794 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 20:57:39 +00:00
Chris Lattner
e777ff21b0 eliminate a malloc/free for (almost) every GEP processed. This speeds up
IPSCCP 3.3% on kimwitu.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33793 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 20:51:48 +00:00
Chris Lattner
b59673e650 switch hash_map's over to DenseMap in SCCP. This speeds up SCCP by 30% in
a release-assert build on kimwitu++.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33792 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 20:38:30 +00:00
Reid Spencer
a07cb7def5 Remove dead code and fix indentation per Chris' review comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33785 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 14:41:37 +00:00
Reid Spencer
cc46cdb47c Use short form of binary operator create functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33783 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 14:08:20 +00:00
Chris Lattner
0737c24053 bugfix for reid's shift patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33779 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 05:29:55 +00:00
Reid Spencer
832254e1c2 Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33776 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-02 02:16:23 +00:00
Chris Lattner
fd905caa77 Fix Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll, a serious code
pessimization where instcombine can sink a load (good for code size) that
prevents an alloca from being promoted by mem2reg (bad for everything).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33771 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-01 22:30:07 +00:00
Chris Lattner
fbbe92f5fd remove temporary vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33715 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 20:08:52 +00:00
Chris Lattner
a88d6ca6f9 Revert another incorrectly applied chunk, which fixes InstCombine/vec_insert_to_shuffle.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33705 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 18:09:17 +00:00
Chris Lattner
55eb1c47de eliminate temporary vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33693 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 04:40:53 +00:00
Chris Lattner
a4f4659865 Move symbolic constant folding code to libanalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33688 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-31 00:53:10 +00:00
Chris Lattner
79066fa6ac Adjust #includes to match movement of constant folding code from transformutils to libanalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33680 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 23:46:24 +00:00
Chris Lattner
0a19ffaf58 pass TD to constant folding apis
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33674 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 23:16:15 +00:00
Chris Lattner
cd2492e6ff use smallvector instead of vector to make constant folding a bit more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33672 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 23:15:19 +00:00
Chris Lattner
db43c63389 remove some bits that are not yet meant to land.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33666 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 22:50:32 +00:00
Chris Lattner
c5eff4488b Symbolically evaluate constant expressions like &A[123] - &A[4].f.
This occurs in C++ code like:

#include <iostream>
#include <iterator>
int a[] = { 1, 2, 3, 4, 5 };
int main() {
  using namespace std;
  copy(a, a + sizeof(a)/sizeof(a[0]), ostream_iterator<int>(cout, "\n"));
  return 0;
}

Before we would decide the loop trip count is:
sdiv (i32 sub (i32 ptrtoint (i32* getelementptr ([5 x i32]* @a, i32 0, i32 5) to i32), i32 ptrtoint ([5 x i32]* @a to i32)), i32 4)

Now we decide it is "5".  Amazing.

This code will need to be refactored, but I'm doing that as a separate
commit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33665 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 22:32:46 +00:00
Reid Spencer
5cbf985dcb For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoid
confusion with external linkage types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33663 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-30 20:08:39 +00:00
Nick Lewycky
6a08f918b6 Simplify names of lattice values. SGTUNE becomes SGT, for example.
Fix initializeConstant, now initializeInt. Fixes major performance
bottleneck.

X == Y || X->DominatedBy(Y) is redundant. Remove the X == Y part.

Fix crasher in makeEqual where getOrInsertNode would add a new constant,
producing an NE relationship between the two members we're trying to make
equal. This now allows us to mark more BBs as unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33612 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-29 02:56:54 +00:00
Chris Lattner
424db0209c Fix test/Transforms/InstCombine/2007-01-27-AndICmp.ll, a miscompilation of
Mozilla that Anton tracked down.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33591 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-27 23:08:34 +00:00
Devang Patel
4d447f5121 Inherit BasicBlockPass directly from Pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33511 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-25 23:23:25 +00:00
Reid Spencer
4223016d02 Cleanup checks in the load and store of casted pointer transforms. Two
changes: (1) don't special case for i1 any more, (2) use the new
TargetData::getTypeSizeInBits method to ensure source and dest are the
same bit width.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33427 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-22 05:51:25 +00:00
Reid Spencer
24d6da5fed For PR970:
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33415 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-21 00:29:26 +00:00
Reid Spencer
67f827ce5b Revise the store V, (cast P) -> store (cast V) -> P transform.
We only want to do this if the src and destination types have the same
bit width. This patch uses TargetData::getTypeSizeInBits() instead of
making a special case for integer types and avoiding the transform if
they don't match.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33414 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-20 23:35:48 +00:00
Chris Lattner
58092e35a3 Teach TargetData to handle 'preferred' alignment for each target, and use
these alignment amounts to align scalars when we can.  Patch by Scott Michel!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33409 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-20 22:35:55 +00:00
Reid Spencer
55af2b59bb For this transform: store V, (cast P) -> store (cast V), P
don't allow the transform if V and the pointer's element type are different
width integer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33371 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-19 21:20:31 +00:00
Reid Spencer
c10305743c For PR1043:
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*

This also fixes PR1120.

Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33370 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-19 21:13:56 +00:00
Chris Lattner
696ee0ab15 Fix InstCombine/2007-01-18-VectorInfLoop.ll, a case where instcombine
infinitely loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33343 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-18 22:16:33 +00:00
Reid Spencer
7515396096 Clean up some code around the store V, (cast P) -> store (cast V), P
transform. Change some variable names so it is clear what is source and
what is dest of the cast. Also, add an assert to ensure that the integer
to integer case is asserting if the bitwidths are different. This prevents
illegal casts from being formed and catches bitwidth bugs sooner.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33337 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-18 18:54:33 +00:00
Reid Spencer
7af9a13f3a For PR1094:
Adjust the use of SetVector for changes in SetVector's interface.
Patch by Gordon Henriksen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33280 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-17 02:23:37 +00:00
Chris Lattner
0d880c38ce Fix a regression in my isIntegral patch that broke 471.omnetpp. This is
because TargetData::getTypeSize() returns the same for i1 and i8.  This fix
is not right for the full generality of bitwise types, but it fixes the
regression.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33237 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 17:55:20 +00:00
Nick Lewycky
dd402588b5 Don't print address of ETNode. Print the DFSNumIn which uniquely identifies
the basic block and is stable across runs in gdb or valgrind.

Make Node::update handle edges which dominate and are tighter than
existing edges.

Replace makeEqual's "squeeze theorem" code. Fixes miscompilation.

Gate the calls to defToOps and opsToDef. Before this, we were getting IG
edges about values which weren't even defined in the dominated area. This
reduces the size of the IG by about half.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33236 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 14:30:07 +00:00
Chris Lattner
ff9f13a4b2 Implement InstCombine/phi.ll:test7, deletion of trivial value loops for
induction variables.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33234 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 07:30:06 +00:00
Chris Lattner
76b7a06a75 simplify some code now that types are signless
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33232 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 07:02:54 +00:00
Chris Lattner
836692dd8a delete stores to allocas with one use. This is a trivial form of DSE which
often kicks in for ?: expressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33231 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 06:51:56 +00:00
Chris Lattner
42a7551725 rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent.  For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33225 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 02:27:26 +00:00
Chris Lattner
4d5f508318 Eliminate calls to isInteger, generalizing code and tightening checks as needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33218 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-15 01:55:30 +00:00
Chris Lattner
58e9746ef3 instcombine has always been miscompiling fcmp x, x, disregarding possible
NANs.  This fixes PR1111 and Transforms/InstCombine/2007-01-14-FcmpSelf.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33208 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-14 19:42:17 +00:00
Chris Lattner
a5c5e7715c Fix Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll, which is part
of PR1107


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-13 23:11:38 +00:00
Reid Spencer
ac3e76ca8f Fix indentation to prior level for easier diffs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33184 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-13 05:10:53 +00:00
Nick Lewycky
0be7f47735 "Default context" blocks can occur after a non-default one. This meant
that properties were being applied where they didn't belong. Fixes crash
in new MiBench testcase.

Also mark debugging code as such in #ifdef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33177 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-13 02:05:28 +00:00
Chris Lattner
54a525d7ae Fix a minor bug handling constant exprs, introduced by a recent patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33175 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-13 00:42:58 +00:00
Chris Lattner
c08b56f6a0 fix a bug in a recent patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33164 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-13 00:02:49 +00:00
Chris Lattner
ef60b2c4ed simplify some code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33150 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 22:51:20 +00:00
Chris Lattner
e9d4fa7a92 eliminate redundant check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33132 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 18:35:11 +00:00
Reid Spencer
a54b7cbd45 For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8,
16, 32, and 64 bit integers.

This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
   bits in an integer. The Type classes SubclassData field is used to
   store the number of bits. This allows 2^23 bits in an integer type.
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
   64-bit integers. These are replaced with just IntegerType which is not
   a primitive any more.
3. Adjust the rest of LLVM to account for this change.

Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with
them in any significant way. Most optimization passes, for example, will
still only deal with the byte-width integer types.  Future increments
will rectify this situation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 07:05:14 +00:00
Reid Spencer
579dca12c2 Implement review feedback for the ConstantBool->ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33110 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 04:24:46 +00:00
Nick Lewycky
28c5b1544a If we know that it's a constant being casted, propagate through the cast
instruction. Doesn't work the other way though (can't recover bits that
have been truncated).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33104 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 01:23:53 +00:00
Nick Lewycky
c2a7d097f9 Clean up logic after ConstantBool removal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33096 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-12 00:02:12 +00:00
Reid Spencer
4fe16d607d Rename BoolTy as Int1Ty. Patch by Sheng Zhou.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33076 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 18:21:29 +00:00
Zhou Sheng
34dceb4757 Remove unnecessary boolean type check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33075 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 14:38:17 +00:00
Zhou Sheng
6b6b6ef167 For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 12:24:14 +00:00
Zhou Sheng
057809ac1c Fixed indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33072 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 10:33:26 +00:00
Nick Lewycky
bc00fec835 Quiet compiler warning. The only reason the function is marked virtual
is so that it can be called from inside a debugger.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33067 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 02:38:21 +00:00
Nick Lewycky
419c6f5ac8 New predicate simplifier!
Please do not enable, there is still some known miscompile problem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33066 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-11 02:32:38 +00:00
Jeff Cohen
dfc12993b9 Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33021 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-08 20:17:17 +00:00
Reid Spencer
abaa8ca433 Comparison of primitive type sizes should now be done in bits, not bytes.
This patch converts getPrimitiveSize to getPrimitiveSizeInBits where it is
appropriate to do so (comparison of integer primitive types).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33012 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-08 16:32:00 +00:00
Reid Spencer
ac8cdf79e7 For PR1097:
Enable complex addressing modes on 64-bit platforms involving two induction
variables by keeping a size and scale in 64-bits not 32.
Patch by Dan Gohman.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33011 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-08 16:17:51 +00:00
Chris Lattner
92141968cb relax some types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32980 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-07 06:58:05 +00:00
Chris Lattner
ee4f13a904 add -debug output for -indvars.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32971 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-07 01:14:12 +00:00
Chris Lattner
46013f4044 Fix regressions in InstCombine/call-cast-target.ll and InstCombine/2003-11-13-ConstExprCastCall.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32959 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06 19:53:32 +00:00
Chris Lattner
80c6c3bbff this final call to canLosslesslyBitCastTo is dead, because ValueRequiresCast
is only called on integers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32949 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06 02:11:56 +00:00
Chris Lattner
ec47992f5c simplify some more code now that there are not multiple different integer
types of the same size


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32948 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06 02:09:32 +00:00
Chris Lattner
57d8637468 eliminate some uses of canLosslesslyBitCastTo, this actually makes the code stronger, by nuking
relational pointer comparisons with casts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32947 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06 01:45:59 +00:00
Chris Lattner
d5dc0fb011 no need to worry about int vs uint any more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32946 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06 01:37:35 +00:00
Chris Lattner
e4929dd0cc Implement InstCombine/vec_shuffle.ll:%test7, simplifying shuffles with
undef operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32899 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-05 07:36:08 +00:00
Chris Lattner
4f0e33d145 fold things like a^b != c^a -> b != c. This implements InstCombine/xor.ll:test27
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32893 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-05 03:04:57 +00:00
Chris Lattner
e617c9ed5d Compile X + ~X to -1. This implements Instcombine/add.ll:test34
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32890 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-05 02:17:46 +00:00
Reid Spencer
8c5a53a603 Death to useless bitcast instructions!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32866 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-04 05:23:51 +00:00
Chris Lattner
7ce2f8b265 Enable a couple xforms for packed vectors (undef | v) -> -1 for packed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32858 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-04 02:12:40 +00:00
Jim Laskey
52ab904ee5 Vectors are not supported by ConstantInt::getAllOnesValue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32827 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-03 00:11:03 +00:00
Reid Spencer
ee5d25e5cc Fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32803 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-31 22:26:06 +00:00
Reid Spencer
c5b206b6be For PR950:
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int   -> Int32
4. [U]Long  -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
   and other methods related to signedness. In a few places this warranted
   identifying the signedness information from other sources.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32785 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-31 05:48:39 +00:00
Reid Spencer
0f9d82c5c4 For PR1066:
Fix this by ensuring that a bitcast is inserted to do sign switching. This
is only temporarily needed as the merging of signed and unsigned is next
on the SignlessTypes plate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32757 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-24 00:40:59 +00:00
Reid Spencer
b3307b232a Shut up some compilers that can't accurately analyze variable usage
correctly and emit "may be used uninitialized" warnings.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32756 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-23 19:17:57 +00:00
Reid Spencer
1b0d847874 For PR1065:
Don't allow CmpInst instances to be processed in FoldSelectOpOp because
you can't easily swap their operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32753 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-23 18:58:04 +00:00
Reid Spencer
e4d87aa2de For PR950:
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and
been replaced with ICmpInst and FCmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32751 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-23 06:05:41 +00:00
Chris Lattner
add2bd7f59 add a simple fast-path for dead allocas
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32750 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-22 23:14:42 +00:00
Chris Lattner
3bad2533bb handle undef values much more carefully: generalize the resolveundefbranches
code to handle instructions as well, so that we properly fold things like
X & undef -> 0.
This fixes Transforms/SCCP/2006-12-19-UndefBug.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32715 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-20 06:21:33 +00:00
Chris Lattner
438e08e357 Convert more Statistic's over to STATISTIC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32692 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-19 21:49:03 +00:00
Chris Lattner
0e5f499638 Switch over Transforms/Scalar to use the STATISTIC macro. For each statistic
converted, we lose a static initializer.  This also allows GCC to emit warnings
about unused statistics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32690 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-19 21:40:18 +00:00
Reid Spencer
8a903db499 Convert the last uses of CastInst::createInferredCast to a normal cast
creation. These changes are still temporary but at least this pushes
knowledge of signedness out closer to where it can be determined properly
and allows signedness to be removed from VMCore.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32654 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-18 08:47:13 +00:00
Chris Lattner
d22dbdf606 re-enable a temporarily-reverted patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32595 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-15 07:32:38 +00:00
Reid Spencer
c55b243bcd Fix a bug in EvaluateInDifferentType. The type of operand should not be
used to determine whether a ZExt or SExt cast is performed. Instead, pass
an "isSigned" bool to the function and determine its value from the opcode
of the cast involved.
Also, clean up some cruft from previous patches.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32548 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 18:21:21 +00:00
Reid Spencer
7eb7638276 Implement review feedback. Most of this has to do with removing unnecessary
cast instructions. A few are bug fixes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32544 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 17:19:09 +00:00
Reid Spencer
21a55c9f08 For mul transforms, when checking for a cast from bool as either operand,
make sure to also check that it is a zext from bool, not any other cast
operation type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32539 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 08:33:33 +00:00
Reid Spencer
5ae9cebef5 Fix and/or/xor (cast A), (cast B) --> cast (and/or/xor A, B)
The cast patch introduced the possibility that the wrong cast opcode
could be used and that this transform could trigger on different kinds
of cast operations. This patch rectifies that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32538 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 08:27:15 +00:00
Reid Spencer
3ba68b9eef Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller.
Adjust the callers to pass the expected opcode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32535 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 08:06:42 +00:00
Chris Lattner
21c362d324 revert my recent int<->fp and vector union promotion changes, they expose
obscure bugs affecting the X86 code generator.  I will reenable this
when fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32524 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 02:26:45 +00:00
Reid Spencer
7b06bd532d Replace CastInst::createInferredCast calls with more accurate cast
creation calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32521 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-13 00:50:17 +00:00
Reid Spencer
d977d8651a Replace inferred getCast(V,Ty) calls with more strict variants.
Rename getZeroExtend and getSignExtend to getZExt and getSExt to match
the the casting mnemonics in the rest of LLVM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32514 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 23:36:14 +00:00
Chris Lattner
bb4e7b2fa4 this can be trunc or bitcast, per line 3092.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32487 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 19:11:20 +00:00
Chris Lattner
078b631ff3 Fix regression on 400.perlbench last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32486 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 18:41:03 +00:00
Reid Spencer
17212df0ee Fix numerous inferred casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32479 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 09:18:51 +00:00
Reid Spencer
4da49122f3 Change inferred getCast into specific getCast. Passes all tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32469 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 05:05:00 +00:00
Chris Lattner
a30fc5ed04 Patch for PR1045 and Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32468 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-12 04:24:41 +00:00
Chris Lattner
509f85140c trunc to integer, not to FP.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32426 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-11 01:17:00 +00:00
Chris Lattner
1dbea1598c implement promotion of unions containing two packed types of the same width.
This implements Transforms/ScalarRepl/union-packed.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32422 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-11 00:35:08 +00:00
Chris Lattner
ae6a305094 * Eliminate calls to CastInst::createInferredCast.
* Add support for promoting unions with fp values in them.  This produces
   our new int<->fp bitcast instructions, implementing
   Transforms/ScalarRepl/union-fp-int.ll

As an example, this allows us to compile this:

union intfloat { int i; float f; };
float invsqrt(const float arg_x) {
    union intfloat x = { .f = arg_x };
    const float xhalf = arg_x * 0.5f;
    x.i = 0x5f3759df - (x.i >> 1);
    return x.f * (1.5f - xhalf * x.f * x.f);
}

into:

_invsqrt:
        movss 4(%esp), %xmm0
        movd %xmm0, %eax
        sarl %eax
        movl $1597463007, %ecx
        subl %eax, %ecx
        movd %ecx, %xmm1
        mulss LCPI1_0, %xmm0
        mulss %xmm1, %xmm0
        movss LCPI1_1, %xmm2
        mulss %xmm1, %xmm0
        subss %xmm0, %xmm2
        movl 8(%esp), %eax
        mulss %xmm2, %xmm1
        movss %xmm1, (%eax)
        ret

instead of:

_invsqrt:
        subl $4, %esp
        movss 8(%esp), %xmm0
        movss %xmm0, (%esp)
        movl (%esp), %eax
        movl $1597463007, %ecx
        sarl %eax
        subl %eax, %ecx
        movl %ecx, (%esp)
        mulss LCPI1_0, %xmm0
        movss (%esp), %xmm1
        mulss %xmm1, %xmm0
        mulss %xmm1, %xmm0
        movss LCPI1_1, %xmm2
        subss %xmm0, %xmm2
        mulss %xmm2, %xmm1
        movl 12(%esp), %eax
        movss %xmm1, (%eax)
        addl $4, %esp
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32418 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-10 23:56:50 +00:00
Reid Spencer
f7761e5c39 Incorporate any changes in the successor blocks into the result of
MarkAliveBlocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32375 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-08 21:52:01 +00:00
Bill Wendling
832171cb97 Removing even more <iostream> includes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32320 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-07 20:04:42 +00:00
Bill Wendling
e81561909d Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-07 01:30:32 +00:00
Reid Spencer
62700f250f Update ConstantIntegral Max/Min tests for new interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32288 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-06 20:39:57 +00:00
Chris Lattner
02fc40ebd3 add missing #include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32280 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-06 18:14:47 +00:00
Chris Lattner
ac0b6ae358 Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32279 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-06 17:46:33 +00:00
Chris Lattner
3749c9cae4 Remove the 'printname' argument to WriteAsOperand. It is always true, and
passing false would make the asmprinter fail anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32264 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-06 06:16:21 +00:00
Chris Lattner
e13ab2a9a1 add an instcombine xform. This speeds up 462.libquantum from 9.78s to
7.48s.  This regression is due to unforseen consequences of the cast patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32209 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-05 01:26:29 +00:00
Devang Patel
67a821d9a3 SCCP does not handle Packed Type properly. Disable Packed Type handling
for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32208 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-04 23:54:59 +00:00
Reid Spencer
3b3844288b Update call to CastInst::getCastOpcode for its new signature.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32166 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-04 02:48:01 +00:00
Jeff Cohen
97af751deb Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32113 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-02 02:22:01 +00:00
Chris Lattner
9919e3df17 disable transformations that are invalid for fp vectors. This fixes
Transforms/InstCombine/2006-12-01-BadFPVectorXform.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32112 91177308-0d34-0410-b5e6-96231b3b80d8
2006-12-02 00:13:08 +00:00
Reid Spencer
44c030a7ee Remove 4 FIXMEs to hack around cast-to-bool problems which no longer exist.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32051 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-30 23:13:36 +00:00
Chris Lattner
46b96055cf implement cast.ll:test35. With this, we recognize:
unsigned short swp(unsigned short a) {
       return ((a & 0xff00) >> 8 | (a & 0x00ff) << 8);
}

as an idiom for bswap.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32011 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-29 07:18:39 +00:00
Chris Lattner
6aa5eb19d5 Teach instcombine to turn trunc(srl x, c) -> srl (trunc(x), c) when safe.
This implements InstCombine/cast.ll:test34.  It fires hundreds of times on
176.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32009 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-29 07:04:07 +00:00
Chris Lattner
458cf462ef Implement Regression/Transforms/InstCombine/bswap-fold.ll,
folding   seteq (bswap(x)), c -> seteq(x,bswap(c))


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32006 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-29 05:02:16 +00:00
Reid Spencer
de33124aa3 Join a split line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31996 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-29 01:11:01 +00:00
Reid Spencer
d4d9ab80b7 Undo the last patch until 253.perlbmk passes with these changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31977 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-28 20:23:51 +00:00
Reid Spencer
5d4dbd1f60 Remove 4 FIXME's from the CAST patch now that the back end is correctly
producing code for "trunc to bool". This passes all tests on Linux.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31963 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-28 07:23:01 +00:00
Chris Lattner
f2f1643037 Fix PR1014 and InstCombine/2006-11-27-XorBug.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31941 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-27 19:55:07 +00:00
Reid Spencer
3da59db637 For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-27 01:05:10 +00:00
Bill Wendling
b742703137 Removed #include <iostream> and replaced with llvm_* streams.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31923 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-26 09:46:52 +00:00
Nick Lewycky
565706b93e Update to new predicate simplifier VRP design. Fixes PR966 and PR967.
Remove predicate simplifier from default gcc3 pipeline. New design is too
slow to enable by default.
Add new testcases for problems encountered in development.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31895 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-22 23:49:16 +00:00
Chris Lattner
13c654a42a This xform is handled by FoldOpIntoPhi in visitCastInst in a more elegant way.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31889 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-21 17:05:13 +00:00
Chris Lattner
020f714a93 If an indvar with a variable stride is used by the exit condition, go ahead
and handle it like constant stride vars.  This fixes some bad codegen in
variable stride cases.  For example, it compiles this:

void foo(int k, int i) {
  for (k=i+i; k <= 8192; k+=i)
    flags2[k] = 0;
}

to:

LBB1_1: #bb.preheader
        movl %eax, %ecx
        addl %ecx, %ecx
        movl L_flags2$non_lazy_ptr, %edx
LBB1_2: #bb
        movb $0, (%edx,%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB1_2      #bb
LBB1_5: #return
        ret

or (if the array is local and we are in dynamic-nonpic or static mode):

LBB3_2: #bb
        movb $0, _flags2(%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB3_2      #bb

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        slwi r3, r4, 1
LBB1_2: ;bb
        li r5, 0
        add r6, r4, r3
        stbx r5, r2, r3
        cmpwi cr0, r6, 8192
        bgt cr0, LBB1_5 ;return

instead of:

        leal (%eax,%eax,2), %ecx
        movl %eax, %edx
        addl %edx, %edx
        addl L_flags2$non_lazy_ptr, %edx
        xorl %esi, %esi
LBB1_2: #bb
        movb $0, (%edx,%esi)
        movl %eax, %edi
        addl %esi, %edi
        addl %ecx, %esi
        cmpl $8192, %esi
        jg LBB1_5       #return

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        mulli r3, r4, 3
        slwi r5, r4, 1
        li r6, 0
        add r2, r2, r5
LBB1_2: ;bb
        li r5, 0
        add r7, r3, r6
        stbx r5, r2, r6
        add r6, r4, r6
        cmpwi cr0, r7, 8192
        ble cr0, LBB1_2 ;bb

This speeds up Benchmarks/Shootout/sieve from 8.533s to 6.464s and
implements LoopStrengthReduce/var_stride_used_by_compare.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31809 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-17 06:17:33 +00:00
Chris Lattner
d23b5baf8a Fix a gcc 4.2 warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31751 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-15 04:53:24 +00:00
Chris Lattner
e511b74f4a implement InstCombine/shift-simplify.ll by transforming:
(X >> Z) op (Y >> Z)  -> (X op Y) >> Z

for all shifts and all ops={and/or/xor}.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31729 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-14 07:46:50 +00:00
Chris Lattner
9c2328e5a9 implement InstCombine/and-compare.ll:test1. This compiles:
typedef struct { unsigned prefix : 4; unsigned code : 4; unsigned unsigned_p : 4; } tree_common;
int foo(tree_common *a, tree_common *b) { return a->code == b->code; }

into:

_foo:
        movl 4(%esp), %eax
        movl 8(%esp), %ecx
        movl (%eax), %eax
        xorl (%ecx), %eax
        # TRUNCATE movb %al, %al
        shrb $4, %al
        testb %al, %al
        sete %al
        movzbl %al, %eax
        ret

instead of:

_foo:
        movl 8(%esp), %eax
        movb (%eax), %al
        shrb $4, %al
        movl 4(%esp), %ecx
        movb (%ecx), %cl
        shrb $4, %cl
        cmpb %al, %cl
        sete %al
        movzbl %al, %eax
        ret

saving one cycle by eliminating a shift.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31727 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-14 06:06:06 +00:00
Chris Lattner
de2b6605ba Fix InstCombine/2006-11-10-ashr-miscompile.ll a miscompilation introduced
by the shr -> [al]shr patch.  This was reduced from 176.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31653 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-10 23:38:52 +00:00
Chris Lattner
b4a2f059ad Teach ShrinkDemandedConstant how to handle X+C. This implements:
add.ll:test33, add.ll:test34, shift-sra.ll:test2


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31586 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-09 05:12:27 +00:00
Chris Lattner
53738a4dbf reenable factoring of GEP expressions, being more precise about the
case that it bad to do.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31563 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-08 19:42:28 +00:00
Chris Lattner
f6fd94d3fa make this code more efficient by not creating a phi node we are just going to
delete in the first place.  This also makes it simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31562 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-08 19:29:23 +00:00
Chris Lattner
f0cd7085c1 disable this factoring optzn for GEPs for now, this severely pessimizes some
loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31560 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-08 18:49:31 +00:00
Reid Spencer
3822ff5c71 For PR950:
This patch converts the old SHR instruction into two instructions,
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31542 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-08 06:47:33 +00:00
Chris Lattner
d92515034f scalarrepl should not split the two elements of the vsiidx array:
int func(vFloat v0, vFloat v1) {
        int ii;
        vSInt32 vsiidx[2];
        vsiidx[0] = _mm_cvttps_epi32(v0);
        vsiidx[1] = _mm_cvttps_epi32(v1);
        ii = ((int *) vsiidx)[4];
        return ii;
}

This fixes Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31524 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-07 22:42:47 +00:00
Jeff Cohen
d41b30def3 Unbreak VC++ build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31464 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-05 19:31:28 +00:00
Nick Lewycky
8b2989ae91 Remove commented line from earlier debugging.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31460 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-05 14:19:40 +00:00
Andrew Lenharth
8ed4c47d70 The wrong parameter was being tested to deturmine i32 vs i64
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31431 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-03 22:45:50 +00:00
Chris Lattner
ffa0a9b7ea remove dead code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31398 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-03 01:34:58 +00:00