Jeff Cohen
a97e8db835
Use ANSI-approved way of getting the value infinity (otherwise VC++ won't compile it)
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21662 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-03 03:13:01 +00:00
Andrew Lenharth
8b9e3e6511
fold fp div by 0 to inf, the way gcc does. This is legal according to the FP spec
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21655 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-02 21:25:47 +00:00
Reid Spencer
2b2a528374
Shut GCC 4.0 up about classes with virtual functions but no virtual
...
destructor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21510 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-24 22:27:20 +00:00
Misha Brukman
fd93908ae8
Remove trailing whitespace
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 23:48:37 +00:00
Chris Lattner
f4aa3351de
Fix a nasty thinko in my previous commit.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19881 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 23:17:27 +00:00
Chris Lattner
ce04a6d7f6
Fix ConstProp/2005-01-28-SetCCGEP.ll: indexing over zero sized elements does
...
not change the address.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19874 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 19:09:51 +00:00
Chris Lattner
488742a28e
No need to pessimize current code for future possibilities.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19311 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-06 16:26:38 +00:00
Chris Lattner
ddc4860c1d
Fix test/Regression/CFrontend/2003-11-01-EmptyStructCrash.c
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18115 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-22 19:15:27 +00:00
Chris Lattner
1b9fe1cbbe
Generalize this code to turn any cast-to-first-element-of into a gep constexpr
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17914 91177308-0d34-0410-b5e6-96231b3b80d8
2004-11-17 17:59:35 +00:00
Chris Lattner
cfbf9faaa4
fold gep undef, ... -> undef
...
This comes up many times in perlbmk and probably others.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17100 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 21:54:55 +00:00
Chris Lattner
35f92ae3af
Fix constant folding relational operators with undef operands.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17077 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-17 04:01:51 +00:00
Chris Lattner
71d3778c0b
Implement constant folding of undef values.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17070 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-16 23:31:32 +00:00
Chris Lattner
7fa6e666ec
Allow creation of GEP constantexprs with a vector of value* operands as
...
well as a vector of constant*'s. It turns out that this is more efficient
and all of the clients want to do that, so we should cater to them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16923 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-11 22:52:25 +00:00
Chris Lattner
f8d1097e9d
If we are trying to create a ConstantExpr cast that is really a GEP to the
...
first element of an array, return a GEP instead of a cast. This allows us
to transparently fold this:
int* getelementptr (int* cast ([100 x int]* %Gbody to int*), int 40)
into this:
int* getelementptr ([100 x int]* %Gbody, int 0, int 40)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16911 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-11 03:57:30 +00:00
Reid Spencer
7970396014
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14927 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-17 23:47:01 +00:00
Chris Lattner
dd68469382
Implement folding of expressions like 'uint cast (int* getelementptr (int*
...
null, uint 1) to uint)' to a constant integer. We can only do this with
primitive LLVM types, because other types have target-specific sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14837 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-15 01:16:59 +00:00
Chris Lattner
d340867964
When folding constant expr gep's, don't force the use of long indices.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14658 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-07 04:45:13 +00:00
Chris Lattner
f70c22b019
Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14201 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 18:19:28 +00:00
Reid Spencer
3ee239bd40
Fix a bug that Chris asserts emphatically is a bug. The changed clause
...
would always return false because the Type of a type value is always
Type::TypeTY and can never be a floating point type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13902 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-30 01:19:48 +00:00
Chris Lattner
a0ae8196a1
Add a missing break, which caused a crash in an obscure situation
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12825 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 01:29:30 +00:00
Chris Lattner
28977af72a
Support getelementptr instructions which use uint's to index into structure
...
types and can have arbitrary 32- and 64-bit integer types indexing into
sequential types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12653 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 01:30:19 +00:00
Chris Lattner
e97148628f
Teach the constant folder how to do select instructions
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12321 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:53:32 +00:00
Chris Lattner
802b5ab844
Implement test/Regression/Assembler/2004-03-07-FunctionAddressAlignment.llx
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12218 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-08 06:17:35 +00:00
Chris Lattner
b228f9c86b
Get all instruction definitions
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11706 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-22 06:25:38 +00:00
Chris Lattner
2e9bb1a88e
Move the folding of gep null, 0, 0, 0 to a place where it can be shared and
...
enjoyed by all, fixing a fixme. Add an assert
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11505 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 20:46:13 +00:00
Chris Lattner
b97e2788ff
Fix a crasher bug in my constant folding rewrite
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11044 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-01 01:23:19 +00:00
Chris Lattner
504e8fb74e
Implement a bunch of symbolic constant folding opportunities. This implements
...
testcase test/Regression/Assembler/ConstantExprFold.llx
Note that these kinds of things only rarely show up in source code, but are
exceedingly common in the intermediate stages of algorithms like SCCP. By
folding things (especially relational operators) that use symbolic constants,
we are able to speculatively fold more conditional branches, which can
lead to some big simplifications.
It would be easy to add a lot more special cases here, so if you notice
SCCP missing anything "obvious", you know what to make smarter. :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10812 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-13 05:51:55 +00:00
Chris Lattner
eab20b58b1
Rearrange and comment code better. No functionality changes
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10808 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 22:07:24 +00:00
Chris Lattner
cbfd406541
Rename ConstantHandling.* -> ConstantFolding.*
...
Move a bunch of (now) private stuff from ConstantFolding.h into
ConstantFolding.cpp.
This _finally_ gets us to a place where we have a sane constant folder. The
rules are:
1. LLVM clients now use ConstantExpr::get* methods to fold constants. If they
cannot be folded, a constantexpr is created, so these methods always return
valid Constant*'s.
2. The implementation of ConstantExpr::get* uses the functions exposed by
ConstantFolding.h to try to fold constants. If they cannot be folded,
they should return a null pointer.
3. The implementation of ConstantFolding can do whatever it wants, and only
has one client (Constants.cpp)
This cuts down on the wierd dependencies, and eliminates the two interfaces.
The old constanthandling interface was especially bad for clients to use
because almost none of them took the failure condition into consideration,
thus leading to obscure problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10807 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 21:13:12 +00:00
Chris Lattner
8b0f0cb908
Remove a whole bunch more ugliness. This is actually getting to the point of
...
this whole refactoring: allow constant folding methods to return something
other than predefined classes, allow them to return generic Constant*'s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10806 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 21:02:29 +00:00
Chris Lattner
6b7b91ab03
Move ConstantHandling.h into lib/VMCore and out of include/llvm
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10805 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 20:48:11 +00:00
Chris Lattner
4a0ecc8c0c
Eliminate usage of the wierd overloaded operator constant folders
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10802 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 20:41:05 +00:00
Chris Lattner
28aabc34f7
Move llvm::ConstantFoldInstruction from here to Transforms/Utils
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10784 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-12 18:25:03 +00:00
Chris Lattner
952454dbff
Implement: Assembler/2004-01-11-getelementptrfolding.llx
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10759 91177308-0d34-0410-b5e6-96231b3b80d8
2004-01-11 23:56:33 +00:00
Chris Lattner
b9da9c137d
Relax constrains on GEP type indexes
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10228 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-25 21:21:46 +00:00
Chris Lattner
5d5a714b24
Implement == and != correctly. Before they would incorrectly return !=
...
for some constant exprs when they could really be the same value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10058 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-17 20:19:35 +00:00
Chris Lattner
a83a6e4276
No REALLY, get rid of ConstantPointer references
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10054 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-17 19:21:04 +00:00
Chris Lattner
cf09f51bb9
Eliminate use of the ConstantPointer class
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10053 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-17 19:19:32 +00:00
Chris Lattner
0dc396909e
Constant folding shalt not be built on annotations
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10052 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-17 19:05:17 +00:00
Brian Gaeke
d0fde30ce8
Put all LLVM code into the llvm namespace, as per bug 109.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9903 91177308-0d34-0410-b5e6-96231b3b80d8
2003-11-11 22:41:34 +00:00
John Criswell
b576c94c15
Added LLVM project notice to the top of every C++ source file.
...
Header files will be on the way.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9298 91177308-0d34-0410-b5e6-96231b3b80d8
2003-10-20 19:43:21 +00:00
Chris Lattner
0425a87a62
Implement Assembler/2003-08-21-ConstantExprCast-Fold.llx
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8015 91177308-0d34-0410-b5e6-96231b3b80d8
2003-08-21 19:45:55 +00:00
Chris Lattner
4b517a4654
Implement testcase: Assembler/2003-08-20-ConstantExprGEP-Fold.llx
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7983 91177308-0d34-0410-b5e6-96231b3b80d8
2003-08-20 16:11:27 +00:00
Chris Lattner
3ccd0fd756
Implement constant folding of casts from boolean constants to other values
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7812 91177308-0d34-0410-b5e6-96231b3b80d8
2003-08-13 15:52:25 +00:00
Chris Lattner
6a2a60aaf3
Implement more aggressive folding of constant GEP instructions
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6913 91177308-0d34-0410-b5e6-96231b3b80d8
2003-06-26 05:22:45 +00:00
Chris Lattner
5c38e99c59
Fix constant folding to ALWAYS work.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6355 91177308-0d34-0410-b5e6-96231b3b80d8
2003-05-27 19:16:07 +00:00
Chris Lattner
3b9922f99c
Remove unnecessary casts
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6201 91177308-0d34-0410-b5e6-96231b3b80d8
2003-05-14 17:51:05 +00:00
Chris Lattner
e0c60038eb
Fix bug
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6184 91177308-0d34-0410-b5e6-96231b3b80d8
2003-05-14 02:47:13 +00:00
Chris Lattner
0ec3590664
Implement another getelementptr folding opportunity that arises when
...
linking stuff with appending linkage
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6180 91177308-0d34-0410-b5e6-96231b3b80d8
2003-05-13 21:50:52 +00:00
Chris Lattner
893af8c058
Fix Bug: ConstProp/2003-05-12-DivideError.ll
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6125 91177308-0d34-0410-b5e6-96231b3b80d8
2003-05-12 15:26:25 +00:00