Owen Anderson
b292b8ce70
Move more code back to 2.5 APIs.
...
llvm-svn: 77635
2009-07-30 23:03:37 +00:00
Owen Anderson
4056ca9568
Move types back to the 2.5 API.
...
llvm-svn: 77516
2009-07-29 22:17:13 +00:00
Owen Anderson
487375e9a2
Move ConstantExpr to 2.5 API.
...
llvm-svn: 77494
2009-07-29 18:55:55 +00:00
Owen Anderson
4aa3295a65
Return ConstantVector to 2.5 API.
...
llvm-svn: 77366
2009-07-28 21:19:26 +00:00
Owen Anderson
c2c7932c64
Change ConstantArray to 2.5 API.
...
llvm-svn: 77347
2009-07-28 18:32:17 +00:00
Owen Anderson
45308b578b
Move ConstantStruct back to 2.5 API.
...
llvm-svn: 77266
2009-07-27 22:29:26 +00:00
Owen Anderson
69c464dec4
Move ConstantFP construction back to the 2.5-ish API.
...
llvm-svn: 77247
2009-07-27 20:59:43 +00:00
Owen Anderson
edb4a70325
Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
...
llvm-svn: 77011
2009-07-24 23:12:02 +00:00
Owen Anderson
c37bc69e91
Rename getConstantInt{True|False} to get{True|False} at Chris' behest.
...
llvm-svn: 76598
2009-07-21 18:03:38 +00:00
Torok Edwin
fbcc663cbf
llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
...
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").
llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Owen Anderson
85f86dc058
Inline EvalVectorOp in order to get rid of passing-pointer-to-static-methods behavior.
...
llvm-svn: 75538
2009-07-13 22:41:06 +00:00
Owen Anderson
53a52215b5
Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
...
This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.
llvm-svn: 75445
2009-07-13 04:09:18 +00:00
Torok Edwin
56d0659726
assert(0) -> LLVM_UNREACHABLE.
...
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.
llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Nick Lewycky
a21d3daadc
Remove the vicmp and vfcmp instructions. Because we never had a release with
...
these instructions, no autoupgrade or backwards compatibility support is
provided.
llvm-svn: 74991
2009-07-08 03:04:38 +00:00
Nick Lewycky
6b8320fa5b
Expand this test to handle more cases (remainder and shifts) of zero.
...
llvm-svn: 73839
2009-06-21 01:56:41 +00:00
Chris Lattner
62fdd112fc
implement PR4424: 0/x is always 0 for integer division.
...
llvm-svn: 73835
2009-06-21 01:15:55 +00:00
Owen Anderson
0d2de8c35e
Revert r73790, and replace it with a significantly less ugly solution. Rather than trying to make the global reader-writer lock work,
...
create separate recursive mutexes for each value map. The recursive-ness fixes the double-acquiring issue, which having one per ValueMap
lets us continue to maintain some concurrency.
llvm-svn: 73801
2009-06-20 00:24:58 +00:00
Owen Anderson
b07dd959a4
Fix a serious bug that would cause deadlock during abstract type refinement. The constant creation
...
gets involved, and we end up trying to recursively acquire a writer lock. The fix for this is slightly horrible,
and involves passing a boolean "locked" parameter around in Constants.cpp, but it's better than having locked and
unlocked versions of most of the code.
llvm-svn: 73790
2009-06-19 23:16:19 +00:00
Dan Gohman
7ccc52f131
Support vector casts in more places, fixing a variety of assertion
...
failures.
To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.
Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.
llvm-svn: 73431
2009-06-15 22:12:54 +00:00
Dan Gohman
a5b9645c4b
Split the Add, Sub, and Mul instruction opcodes into separate
...
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.
For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.
This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt
llvm-svn: 72897
2009-06-04 22:49:04 +00:00
Dan Gohman
79975d5ffb
Apply a patch by Micah Villmow to fix AsmParser to accept vector
...
shift constant expressions, and add support for folding vector
shift constant expressions. This fixes PR3802.
llvm-svn: 67010
2009-03-14 17:09:17 +00:00
Daniel Dunbar
5bf00893b6
Extension of GEP in constant folder was broken (apparently this code
...
has never been run!).
- Sorry, don't know how to make an LLVM test case for this.
llvm-svn: 65383
2009-02-24 19:10:46 +00:00
Duncan Sands
e7d5479136
Allow the inverse transform x86_fp80 -> i80 (also
...
fires during the Ada build).
llvm-svn: 63731
2009-02-04 11:17:06 +00:00
Duncan Sands
1ea1173143
Fix PR3468: a crash when constant folding a bitcast of
...
i80 to x86 long double (this was presumably generated
by sroa).
llvm-svn: 63730
2009-02-04 10:17:14 +00:00
Dale Johannesen
b5721632ee
Make special cases (0 inf nan) work for frem.
...
Besides APFloat, this involved removing code
from two places that thought they knew the
result of frem(0., x) but were wrong.
llvm-svn: 62645
2009-01-21 00:35:19 +00:00
Chris Lattner
dd8ef1bf30
div/rem by zero and div/rem overflow are both undefined according to
...
langref. Constant fold them to undef instead of trying to preserve
the trap. This fixes PR3354.
llvm-svn: 62534
2009-01-19 21:55:26 +00:00
Mon P Wang
25f0106fd9
Added support for the following definition of shufflevector
...
<result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask>
llvm-svn: 58964
2008-11-10 04:46:22 +00:00
Devang Patel
d26344d252
Fix unused variable warnings.
...
llvm-svn: 58653
2008-11-03 23:20:04 +00:00
Chris Lattner
1baace07c4
apply Eli's patch for PR2165 and provide a testcase.
...
llvm-svn: 57625
2008-10-16 05:26:51 +00:00
Dale Johannesen
4f0bd68cfe
Add a "loses information" return value to APFloat::convert
...
and APFloat::convertToInteger. Restore return value to
IEEE754. Adjust all users accordingly.
llvm-svn: 57329
2008-10-09 23:00:39 +00:00
Dale Johannesen
54306fe499
Rename APFloat::convertToAPInt to bitcastToAPInt to
...
make it clearer what the function does. No functional
change.
llvm-svn: 57325
2008-10-09 18:53:47 +00:00
Nick Lewycky
ac5c7d514f
Try to fold each element of a vector. This is needed to maintain structural
...
equivalence.
llvm-svn: 55694
2008-09-03 06:48:55 +00:00
Nick Lewycky
f023db6444
Don't crash when trying to constant fold a vector with some elements that can't
...
be folded. Instead, fail to fold the entire vector.
We could also return a vector with some elements folded and some not. If anyone
thinks that's a better approach, please speak up!
llvm-svn: 55689
2008-09-03 05:54:33 +00:00
Chris Lattner
67136cff7b
Fix a case where vector comparison constant folding would cause an
...
infinite recursion. part of PR2529
llvm-svn: 53383
2008-07-10 00:29:28 +00:00
Chris Lattner
b69689e18b
elementwise comparison of vector constants was completely wrong. Fix
...
it for PR2529
llvm-svn: 53380
2008-07-10 00:08:17 +00:00
Chris Lattner
350e41760a
improve comment
...
llvm-svn: 53243
2008-07-08 18:47:38 +00:00
Chris Lattner
d137a08b0d
Fix three bugs:
...
1) evaluate [v]fcmp true/false with undefs to true or false instead
of undef.
2) fix vector comparisons with undef to return a vector result instead
of i1
3) fix vector comparisons with evaluatable results to return vector
true/false instead of i1 true/false (PR2529)
llvm-svn: 53220
2008-07-08 05:46:34 +00:00
Dan Gohman
3db11c2bd9
Constant folding for insertvalue and extractvalue.
...
llvm-svn: 51889
2008-06-03 00:15:20 +00:00
Nick Lewycky
eb185ca5e9
Revert constant-folding change that will miscompile in some cases.
...
llvm-svn: 51223
2008-05-17 19:00:05 +00:00
Nick Lewycky
79d681dddd
Unbreak the build.
...
llvm-svn: 51217
2008-05-17 09:05:22 +00:00
Nick Lewycky
1ba90bb69b
Constant fold inttoptr and ptrtoint.
...
llvm-svn: 51216
2008-05-17 09:03:26 +00:00
Dan Gohman
12fce7751b
IR support for extractvalue and insertvalue instructions. Also, begin
...
moving toward making structs and arrays first-class types.
llvm-svn: 51157
2008-05-15 19:50:34 +00:00
Gabor Greif
f6caff66a1
merge of use-diet branch to trunk
...
llvm-svn: 50943
2008-05-10 08:32:32 +00:00
Chris Lattner
912bec79ca
hopefully resolve PR2240
...
llvm-svn: 49999
2008-04-20 19:59:12 +00:00
Chris Lattner
6b05605829
rearrange some code, simplify handling of shifts.
...
llvm-svn: 49995
2008-04-20 18:24:14 +00:00
Chris Lattner
d3018e6a0e
Use simplified ConstantFP::get method, fix a bug handling frem x, 0 with long doubles.
...
llvm-svn: 49976
2008-04-20 00:26:06 +00:00
Chris Lattner
bc26e1bb8a
Implement PR2206.
...
llvm-svn: 49967
2008-04-19 22:17:26 +00:00
Chris Lattner
334d33cad1
refactor handling of symbolic constant folding, picking up
...
a few new cases( see Integer/a1.ll), but not anything that
would happen in practice.
llvm-svn: 49965
2008-04-19 21:58:19 +00:00
Chris Lattner
6072ead8e2
indentation fix.
...
llvm-svn: 49964
2008-04-19 21:13:00 +00:00
Nate Begeman
f2b0b0eb17
Don't eliminate bitcast instructions that change the type of a pointer
...
llvm-svn: 48971
2008-03-31 00:22:16 +00:00
Evan Cheng
df1690dc7c
Handle a special case xor undef, undef -> 0. Technically this should be transformed to undef. But this is such a common idiom (misuse) we are going to handle it.
...
llvm-svn: 48792
2008-03-25 20:08:07 +00:00
Dan Gohman
06c45d516d
Use the new convertFromAPInt instead of convertFromZeroExtendedInteger.
...
llvm-svn: 47744
2008-02-29 01:42:52 +00:00
Anton Korobeynikov
579f07135a
Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
...
llvm-svn: 47367
2008-02-20 11:08:44 +00:00
Chris Lattner
b4c6cc9587
Fix some minor issues folding undef, PR2052
...
llvm-svn: 47314
2008-02-19 06:22:12 +00:00
Chris Lattner
f3ebc3f3d2
Remove attribution from file headers, per discussion on llvmdev.
...
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Christopher Lamb
edf0788758
Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
...
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Chris Lattner
8e6a8f984c
Teach VMCore to constant fold shufflevectors with constant operands.
...
This allows us to compile:
#include <emmintrin.h>
typedef __m128i VSInt16;
typedef short vSInt16 __attribute__ ((__vector_size__ (16)));
VSInt16 t3() {
return (VSInt16)((vSInt16)_mm_set1_epi16(6518));
}
into:
_t3:
movaps LCPI1_0, %xmm0
ret
instead of:
_t3:
movl $6518, %eax
movd %eax, %xmm0
pextrw $0, %xmm0, %eax
xorps %xmm0, %xmm0
pinsrw $0, %eax, %xmm0
punpcklwd %xmm0, %xmm0
pshufd $0, %xmm0, %xmm0
ret
llvm-svn: 44856
2007-12-11 07:49:37 +00:00
Chris Lattner
5c6399eee6
significantly simplify some code, no functionality change.
...
llvm-svn: 44850
2007-12-11 06:07:39 +00:00
Chris Lattner
e8ea0374ac
refactor some code, no functionality change.
...
llvm-svn: 44849
2007-12-11 05:55:02 +00:00
Chris Lattner
d2265b45ae
Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
...
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe. While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".
llvm-svn: 44817
2007-12-10 22:53:04 +00:00
Nate Begeman
d4d45c268c
Add support for vectors to int <-> float casts.
...
llvm-svn: 44204
2007-11-17 03:58:34 +00:00
Dan Gohman
b43e020cdb
Fix a regression in test/CodeGen/X86/2007-04-24-VectorCrash.ll introduced
...
by r43510. Gracefully handle constants with vector type that aren't
ConstantVector or ConstantAggregateZero.
llvm-svn: 43579
2007-10-31 21:36:31 +00:00
Dan Gohman
9f39660c20
Add support for folding binary operators with vector zero operands.
...
llvm-svn: 43510
2007-10-30 19:00:49 +00:00
Dale Johannesen
e5facd51cb
Disable attempts to constant fold PPC f128.
...
Remove the assumption that this will happen from
various places.
llvm-svn: 43053
2007-10-16 23:38:29 +00:00
Chris Lattner
2b827fd70d
avoid an APFloat copy.
...
llvm-svn: 42979
2007-10-15 05:34:10 +00:00
Dale Johannesen
19db093b35
Disable some compile-time optimizations on PPC
...
long double.
llvm-svn: 42958
2007-10-14 01:56:47 +00:00
Neil Booth
5f00973393
convertFromInteger, as originally written, expected sign-extended
...
input. APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input. Make this
assumption explicit in the function name.
llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Dale Johannesen
9150652b21
Constant fold int-to-long-double conversions;
...
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).
llvm-svn: 42484
2007-09-30 18:19:03 +00:00
Dale Johannesen
17663f40b9
Remove no-longer-used variable.
...
llvm-svn: 42329
2007-09-25 23:32:20 +00:00
Dale Johannesen
e7439eff5a
Make APFloat->int conversions deterministic even in
...
cases with undefined behavior.
llvm-svn: 42328
2007-09-25 23:07:07 +00:00
Dale Johannesen
5026f4ba93
float->int conversion rounds toward 0. Duh.
...
Fixes PR1698.
llvm-svn: 42273
2007-09-24 21:06:09 +00:00
Dale Johannesen
acbb26f125
Just use APFloat for const / const. Fixes
...
-1. / -0.
llvm-svn: 42254
2007-09-24 00:32:45 +00:00
Dale Johannesen
cc7c475705
Fix dumb regression in constant folding (Regression/C/casts)
...
llvm-svn: 42165
2007-09-20 16:50:21 +00:00
Dale Johannesen
f4bad97ea0
Fix some long double issues.
...
llvm-svn: 42133
2007-09-19 14:22:58 +00:00
Duncan Sands
a38e527523
Partial fix for PR1678: correct some parts of constant
...
fold that were missed in the fix for PR1646. Probably
this null/not-null logic should be factorized somewhere.
llvm-svn: 42131
2007-09-19 10:16:17 +00:00
Dale Johannesen
028084efe5
Revise previous patch per review comments.
...
Next round of x87 long double stuff.
Getting close now, basically works.
llvm-svn: 41875
2007-09-12 03:30:33 +00:00
Dale Johannesen
245dceb06d
Add APInt interfaces to APFloat (allows directly
...
access to bits). Use them in place of float and
double interfaces where appropriate.
First bits of x86 long double constants handling
(untested, probably does not work).
llvm-svn: 41858
2007-09-11 18:32:33 +00:00
Chris Lattner
52fe869374
Fix a buggy constant folding transformation when handling aliases.
...
llvm-svn: 41818
2007-09-10 23:42:42 +00:00
Dale Johannesen
bed9dc423c
Next round of APFloat changes.
...
Use APFloat in UpgradeParser and AsmParser.
Change all references to ConstantFP to use the
APFloat interface rather than double. Remove
the ConstantFP double interfaces.
Use APFloat functions for constant folding arithmetic
and comparisons.
(There are still way too many places APFloat is
just a wrapper around host float/double, but we're
getting there.)
llvm-svn: 41747
2007-09-06 18:13:44 +00:00
David Greene
c656cbb8c2
Update GEP constructors to use an iterator interface to fix
...
GLIBCXX_DEBUG issues.
llvm-svn: 41697
2007-09-04 15:46:09 +00:00
Chris Lattner
aadc778782
Constant fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1)
...
Into: inttoptr (i64 0 to i8*) -> null
This occurs in the example in PR1602. With this fixed, we now compile
the example in PR1602 into fully "devirtualized" code:
define void @_Z1g1S(%struct.S* noalias %s) {
entry: %tmp131415 = getelementptr %struct.S* %s, i32 0, i32 0 ; <i32 (...)***> [#uses=1] %tmp16 = load i32 (...)*** %tmp131415, align 4 ; <i32 (...)**> [#uses=1]
%tmp26277 = load i32 (...)** %tmp16 ; <i32 (...)*> [#uses=1]
%tmp2829 = bitcast i32 (...)* %tmp26277 to void (%struct.S*)* ; <void (%struct.S*)*> [#uses=1]
tail call void %tmp2829( %struct.S* %s )
ret void
}
This still has the vtable dispatch (as required) but does not have any pointer
to method cruft left.
llvm-svn: 41046
2007-08-13 17:09:08 +00:00
Reid Spencer
05d55b396c
Fix a doxygen directive.
...
llvm-svn: 40849
2007-08-05 19:27:01 +00:00
Chris Lattner
363485da82
zext(undef) = 0 and sext(undef) = 0, not undef.
...
This hopefully fixes a miscompilation of TargetData.cpp when self hosting.
llvm-svn: 40125
2007-07-20 22:09:02 +00:00
Dan Gohman
06c60b6032
Fix comments about vectors to use the current wording.
...
llvm-svn: 39921
2007-07-16 14:29:03 +00:00
Reid Spencer
e20090b88d
Add a comment to explain a folding transform.
...
llvm-svn: 35360
2007-03-26 20:09:02 +00:00
Chris Lattner
6d94bb79ac
fold constantexprs more aggressively, fixing PR1265
...
llvm-svn: 35336
2007-03-25 05:47:04 +00:00
Reid Spencer
d96dc9020a
Fix constant fold of div by zero and rem by zero to match IEEE 754
...
requirements. We must return NaN in some cases and correctly signed
infinity in other cases. Passes CFP2006 (not that that says much).
llvm-svn: 35277
2007-03-23 05:33:23 +00:00
Reid Spencer
50d7ad9183
Fix constant folding of fp->int bitcast for vectors.
...
llvm-svn: 34880
2007-03-03 08:32:46 +00:00
Reid Spencer
2e54a15943
Prefer non-virtual calls to ConstantInt::isZero over virtual calls to
...
Constant::isNullValue() in situations where it is possible.
llvm-svn: 34821
2007-03-02 00:28:52 +00:00
Reid Spencer
4326cf5c51
Use the APInt versions of the bit-wise conversions of float/double to int
...
and back. While this is not strictly necessary, it does pave the way for
future changes in casting. It should now be possible to improve vector
casting to deal with un-equal fp/int sizes.
llvm-svn: 34808
2007-03-01 20:44:23 +00:00
Reid Spencer
a127633716
Use a simpler constructor when constructing ConstantInst.
...
llvm-svn: 34793
2007-03-01 19:31:12 +00:00
Reid Spencer
4aeaeaf894
Pull out the stops.
...
llvm-svn: 34703
2007-02-27 23:33:03 +00:00
Reid Spencer
e2eb1fab8c
Adjust to changes in the APInt interface.
...
llvm-svn: 34681
2007-02-27 20:25:25 +00:00
Reid Spencer
ac419b52ad
For PR1205:
...
Implement review feedback:
1. Use new APInt::RoundDoubleToAPInt interface to specify the bit width so
that we don't have to truncate or extend in constant folding.
2. Fix a pasteo in SDiv that prevented a check for overflow.
3. Fix the shift operators: undef happens when the shift amount is equal
to the bitwidth.
llvm-svn: 34677
2007-02-27 19:29:54 +00:00
Reid Spencer
81658a8aca
For PR1205:
...
Implement constant folding via APInt instead of uint64_t.
llvm-svn: 34660
2007-02-27 06:23:51 +00:00
Chris Lattner
33e93b84af
ConstantFolding.cpp/h -> ConstantFold.cpp/h to avoid confusion with
...
lib/Analysis/ConstantFolding.
llvm-svn: 34653
2007-02-27 03:05:06 +00:00