Commit Graph

181 Commits

Author SHA1 Message Date
Jay Foad d1b7849d49 Convert GetElementPtrInst to use ArrayRef.
llvm-svn: 135904
2011-07-25 09:48:08 +00:00
Jay Foad 2f5fc8c67d Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.
llvm-svn: 135676
2011-07-21 15:15:37 +00:00
Jay Foad ed8db7d9df Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.

llvm-svn: 135673
2011-07-21 14:31:17 +00:00
Jay Foad ca3fc38839 Convert ConstantFoldGetElementPtr to use ArrayRef.
llvm-svn: 135483
2011-07-19 15:30:30 +00:00
Jeffrey Yasskin 7a16288157 Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity
errors like the one corrected by r135261.  Migrate all LLVM callers of the old
constructor to the new one.

llvm-svn: 135431
2011-07-18 21:45:40 +00:00
Chris Lattner 229907cd11 land David Blaikie's patch to de-constify Type, with a few tweaks.
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jay Foad 57aa636794 Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
llvm-svn: 135040
2011-07-13 10:26:04 +00:00
Chris Lattner 822d96bb83 don't load element before checking to see if it is valid.
llvm-svn: 134836
2011-07-09 18:23:26 +00:00
Chris Lattner b1ed91f397 Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM.  One way to look at it
is through diffstat:
 109 files changed, 3005 insertions(+), 5906 deletions(-)

Removing almost 3K lines of code is a good thing.  Other advantages
include:

1. Value::getType() is a simple load that can be CSE'd, not a mutating
   union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
   uniques them.  This means that the compiler doesn't merge them structurally
   which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
   struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
   in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead 
   "const Type *" everywhere.

Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.  
"LLVM 3.0" is the right time to do this.

There are still some cleanups pending after this, this patch is large enough
as-is.

llvm-svn: 134829
2011-07-09 17:41:24 +00:00
Dan Gohman 54664ed714 Improve constant folding of undef for cmp and select operators.
llvm-svn: 134223
2011-07-01 01:03:43 +00:00
Dan Gohman ca8d9e1341 Improve constant folding of undef for binary operators.
llvm-svn: 134221
2011-07-01 00:42:17 +00:00
Jay Foad b8a8bed301 Make ConstantVector::get() always take an ArrayRef, never a std::vector.
llvm-svn: 133614
2011-06-22 09:10:19 +00:00
Chris Lattner cc19efaa97 Revamp the "ConstantStruct::get" methods. Previously, these were scattered
all over the place in different styles and variants.  Standardize on two
preferred entrypoints: one that takes a StructType and ArrayRef, and one that
takes StructType and varargs.

In cases where there isn't a struct type convenient, we now add a
ConstantStruct::getAnon method (whose name will make more sense after a few
more patches land).  

It would be "really really nice" if the ConstantStruct::get and 
ConstantVector::get methods didn't make temporary std::vectors.

llvm-svn: 133412
2011-06-20 04:01:31 +00:00
Chris Lattner 0ab5e2cded Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Jay Foad 7c14a558fe Don't include Operator.h from InstrTypes.h.
llvm-svn: 129271
2011-04-11 09:35:34 +00:00
Nadav Rotem 7cc6d12ad0 Enhance constant folding of bitcast operations on vectors of floats.
Add getAllOnesValue of FP numbers to Constants and APFloat.
Add more tests.

llvm-svn: 125776
2011-02-17 21:22:27 +00:00
Chris Lattner 69229316aa convert ConstantVector::get to use ArrayRef.
llvm-svn: 125537
2011-02-15 00:14:00 +00:00
Chris Lattner 34442e6ebf revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125504
2011-02-14 18:15:46 +00:00
Chris Lattner d9f5b88548 Switch ConstantVector::get to use ArrayRef instead of a pointer+size
idiom.  Change various clients to simplify their code.

llvm-svn: 125487
2011-02-14 07:55:32 +00:00
Nadav Rotem 27b848afb0 Fix a regression from r125393;
It caused a crash in MultiSource/Benchmarks/Bullet.
Opt hit an assertion with "opt -std-compile-opts" because
Constant::getAllOnesValue doesn't know how to handle floats.

This patch added a test to reproduce the problem and a check that the
destination vector is of integer type.

Thank you Benjamin!

llvm-svn: 125459
2011-02-13 15:45:34 +00:00
Nadav Rotem 10134c33f2 Fix 9173.
Add more folding patterns to constant expressions of vector selects and vector
bitcasts.

llvm-svn: 125393
2011-02-11 19:37:55 +00:00
Nick Lewycky c15dd6f07c Fix 'fcmp one' constant folding. Noticed by inspection.
llvm-svn: 124557
2011-01-30 01:49:58 +00:00
Nick Lewycky 7c75f0c031 Fix some formatting and upgrade comments from llvm 1.x to 2.x syntax.
llvm-svn: 124556
2011-01-30 01:48:50 +00:00
Nick Lewycky 97a2895e73 Add the select optimization recently added to instcombine to constant folding.
This is the one where one of the branches of the select is another select on
the same condition.

llvm-svn: 124547
2011-01-29 20:35:06 +00:00
Nick Lewycky 39b12c059d Add a constant folding of casts from zero to zero. Fixes PR9011!
While here, I'd like to complain about how vector is not an aggregate type
according to llvm::Type::isAggregateType(), but they're listed under aggregate
types in the LangRef and zero vectors are stored as ConstantAggregateZero.

llvm-svn: 123956
2011-01-21 01:12:09 +00:00
Jay Foad 1d4a8fe156 Remove casts between Value** and Constant**, which won't work if a
static_cast from Constant* to Value* has to adjust the "this" pointer.
This is groundwork for PR889.

llvm-svn: 123435
2011-01-14 08:07:43 +00:00
Duncan Sands 7f60dc1eb0 Move some shift transforms out of instcombine and into InstructionSimplify.
While there, I noticed that the transform "undef >>a X -> undef" was wrong.
For example if X is 2 then the top two bits must be equal, so the result can
not be anything.  I fixed this in the constant folder as well.  Also, I made
the transform for "X << undef" stronger: it now folds to undef always, even
though X might be zero.  This is in accordance with the LangRef, but I must
admit that it is fairly aggressive.  Also, I added "i32 X << 32 -> undef"
following the LangRef and the constant folder, likewise fairly aggressive.

llvm-svn: 123417
2011-01-14 00:37:45 +00:00
Chris Lattner 1be1fe033c fix PR8867: a crash handling fp128. Thanks to Nick for the testcase.
llvm-svn: 122613
2010-12-29 01:33:36 +00:00
Duncan Sands 70db5e7cb2 There is no need for isAssociative to take the type as an argument anymore.
llvm-svn: 122242
2010-12-20 13:10:23 +00:00
Jay Foad 583abbc4df PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

llvm-svn: 121120
2010-12-07 08:25:19 +00:00
Benjamin Kramer 31920b0a2a Remove unneeded zero arrays.
llvm-svn: 120910
2010-12-04 15:28:22 +00:00
Chris Lattner 13ee795c42 remove unions from LLVM IR. They are severely buggy and not
being actively maintained, improved, or extended.

llvm-svn: 112356
2010-08-28 04:09:24 +00:00
Dan Gohman e697a6f24f Constant fold x == undef to undef.
llvm-svn: 107074
2010-06-28 21:30:07 +00:00
Dan Gohman dd41bba517 Use A.append(...) instead of A.insert(A.end(), ...) when A is a
SmallVector, and other SmallVector simplifications.

llvm-svn: 106452
2010-06-21 19:47:52 +00:00
Dan Gohman 520913cf9e getFoldedOffsetOf no longer does anything special with vector types.
llvm-svn: 105514
2010-06-05 00:47:34 +00:00
Nick Lewycky 1a7ed5868b Make the 'icmp pred trunc(ext(X)), CST --> icmp pred X, ext(trunc(CST))'
transformation much more careful. Truncating binary '01' to '1' sounds like it's
safe until you realize that it switched from positive to negative under a signed
interpretation, and that depends on the icmp predicate.

Also a few miscellaneous cleanups.

llvm-svn: 97721
2010-03-04 06:54:10 +00:00
Chris Lattner 3afc0721c7 fix incorrect folding of icmp with undef, PR6481.
llvm-svn: 97659
2010-03-03 19:46:03 +00:00
Dan Gohman a2684dbff0 Teach the constant folder about union types.
llvm-svn: 97142
2010-02-25 16:45:19 +00:00
Dan Gohman 935faff0bd Remove code which assumes it knows how vectors are stored in memory.
llvm-svn: 97141
2010-02-25 16:05:33 +00:00
Dan Gohman 6c5ac6de5c Canonicalize ConstantInts to the right operand of commutative
operators.

The test difference is just due to the multiplication operands
being commuted (and thus requiring a more elaborate match). In
optimized code, that expression would be folded.

llvm-svn: 96816
2010-02-22 22:43:23 +00:00
Dan Gohman 6eeabaad2b Use Instruction::isCommutative instead of duplicating it.
llvm-svn: 96807
2010-02-22 22:05:18 +00:00
Duncan Sands cbd43f89ac Introduce isOpaqueTy and use it rather than isa<OpaqueType>. Also, move some
methods to try to have the type predicates be more logically positioned.

llvm-svn: 96349
2010-02-16 14:50:09 +00:00
Duncan Sands 19d0b47b1f There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy().  Convert most instances of the first form to the second form.
Requested by Chris.

llvm-svn: 96344
2010-02-16 11:11:14 +00:00
Duncan Sands 9dff9bec31 Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy.  Requested by Chris!

llvm-svn: 96223
2010-02-15 16:12:20 +00:00
Chris Lattner 392be58cad Add support for a union type in LLVM IR. Patch by Talin!
llvm-svn: 96011
2010-02-12 20:49:41 +00:00
Dan Gohman 183a423af9 Canonicalize sizeof and alignof on pointer types to a canonical
pointer type.

llvm-svn: 95769
2010-02-10 06:13:07 +00:00
Dan Gohman f644af8bbe Factor out alignof expression folding into a separate function and
generalize it to handle more cases.

llvm-svn: 95045
2010-02-02 01:41:39 +00:00
Chris Lattner f5edeebd8c eliminate a bunch of pointless LLVMContext arguments.
llvm-svn: 95001
2010-02-01 20:48:08 +00:00
Duncan Sands dddba06e9e Fix typo "of" -> "or" and change the way a line was formatted to fit
into 80 columns to match my artistic preferences.

llvm-svn: 95000
2010-02-01 20:42:02 +00:00
Chris Lattner 94eb4b285b fix PR6195, a bug constant folding scalar -> vector compares.
llvm-svn: 94997
2010-02-01 20:04:40 +00:00