Commit Graph

66 Commits

Author SHA1 Message Date
Frits van Bommel 0bb2ad2cf7 Constant folding support for calls to umul.with.overflow(), basically identical to the smul.with.overflow() code.
llvm-svn: 128379
2011-03-27 14:26:13 +00:00
Anders Carlsson d21b06a0db When loading from a constant, fold inttoptr if the integer type and the resulting pointer type both have the same size.
llvm-svn: 124987
2011-02-06 20:11:56 +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
Chandler Carruth b1e7f557b7 Teach constant folding to perform conversions from constant floating
point values to their integer representation through the SSE intrinsic
calls. This is the last part of a README.txt entry for which I have real
world examples.

llvm-svn: 123206
2011-01-11 01:07:24 +00:00
Chandler Carruth fdf4969149 FileCheck-ize a test, and move a no-longer calling test case to another
file and make it actually test something...

llvm-svn: 123205
2011-01-11 01:07:20 +00:00
NAKAMURA Takumi a834008959 test/Transforms/ConstProp/logicaltest.ll: FileCheck-ize.
llvm-svn: 122620
2010-12-29 03:58:56 +00:00
Frits van Bommel a98214de10 Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.
llvm-svn: 120316
2010-11-29 20:36:52 +00:00
Chris Lattner 8d22ff90a3 rename test.
llvm-svn: 119033
2010-11-14 07:03:49 +00:00
Chris Lattner befbf975e8 filecheckize, remove an old and useless test
llvm-svn: 119032
2010-11-14 07:03:38 +00:00
Chris Lattner 4e44cb8bcb this test is pretty pointless and "propogation" isn't a word (or so Misha claims).
llvm-svn: 119031
2010-11-14 07:02:03 +00:00
Chris Lattner b9681ad442 fix a bug I introduced, no idea how this didn't repro right.
llvm-svn: 116462
2010-10-14 00:30:00 +00:00
Chris Lattner c7bd5740eb hack to unbreak buildbots
llvm-svn: 116461
2010-10-14 00:26:10 +00:00
Chris Lattner 698661c741 add uadd_ov/usub_ov to apint, consolidate constant folding
logic to use the new APInt methods.  Among other things this
implements rdar://8501501 - llvm.smul.with.overflow.i32 should constant fold

which comes from "clang -ftrapv", originally brought to my attention from PR8221.

llvm-svn: 116457
2010-10-14 00:05:07 +00:00
Chris Lattner bb451461ec remove some noise from tests.
llvm-svn: 112889
2010-09-02 22:35:33 +00:00
Chris Lattner 3c46e14137 fix PR6197 - infinite recursion in ipsccp due to block addresses
evaluateICmpRelation wasn't handling blockaddress.

llvm-svn: 94993
2010-02-01 19:35:08 +00:00
Nick Lewycky 9e26c1cc0c Fix a crasher trying to fold each element in a comparison between two vectors
if one of the vectors didn't have elements (such as undef). Fixes PR 6096.

Fix an issue in the constant folder where fcmp (<2 x %ty>, <2 x %ty>) would
have <2 x i1> type if constant folding was successful and i1 type if it wasn't.
This exposed a related issue in the bitcode reader.

llvm-svn: 94069
2010-01-21 07:03:21 +00:00
Chris Lattner a69f89c17a fix PR5978 by peeling the loop so that we avoid shifting the
result int by 8 for the first byte.  While normally harmless,
if the result is smaller than a byte, this shift is invalid.

llvm-svn: 93018
2010-01-08 19:02:23 +00:00
Chris Lattner 1ddfd9f96c Fix PR5551 by not ignoring the top level constantexpr when
folding a load from constant.

llvm-svn: 90545
2009-12-04 06:29:29 +00:00
Edward O'Callaghan e45ac76ee4 Convert a few tests to FileCheck for PR5307.
llvm-svn: 85171
2009-10-26 22:52:03 +00:00
Chris Lattner 9e2d5b3b8e fix PR5287, a serious regression from my previous patches. Thanks to
Duncan for the nice tiny testcase.

llvm-svn: 84992
2009-10-24 05:22:15 +00:00
Chris Lattner ccf1e84779 teach libanalysis to simplify vector loads with bitcast sources. This
implements something out of Target/README.txt producing:

_foo:                                                       ## @foo
	movl	4(%esp), %eax
	movapd	LCPI1_0, %xmm0
	movapd	%xmm0, (%eax)
	ret	$4

instead of:

_foo:                                                       ## @foo
	movl	4(%esp), %eax
	movapd	_b, %xmm0
	mulpd	LCPI1_0, %xmm0
	addpd	_a, %xmm0
	movapd	%xmm0, (%eax)
	ret	$4

llvm-svn: 84942
2009-10-23 06:57:37 +00:00
Chris Lattner 59f94c01dd enhance FoldReinterpretLoadFromConstPtr to handle loads of up to 32
bytes (i256).

llvm-svn: 84941
2009-10-23 06:50:36 +00:00
Chris Lattner ed00b80bf8 teach libanalysis to fold int and fp loads from almost arbitrary
non-type-safe constant initializers.  This sort of thing happens
quite a bit for 4-byte loads out of string constants, unions, 
bitfields, and an interesting endianness check from sqlite, which
is something like this:

const int sqlite3one = 1;
# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)

all of these macros now constant fold away.

This implements PR3152 and is based on a patch started by Eli, but heavily
modified and extended.

llvm-svn: 84936
2009-10-23 06:23:49 +00:00
Chris Lattner f67d297eda Teach vm core to more aggressively fold 'trunc' constantexprs,
allowing it to simplify the crazy constantexprs in the testcases
down to something sensible.  This allows -std-compile-opts to
completely "devirtualize" the pointers to member functions in
the testcase from PR5176.

llvm-svn: 84368
2009-10-17 21:53:27 +00:00
Chris Lattner 6f463f9ad4 remove # uses from FileCheck lines.
llvm-svn: 84367
2009-10-17 21:51:19 +00:00
Chris Lattner 965fe98af6 rename test
llvm-svn: 84364
2009-10-17 21:31:19 +00:00
Evan Phoenix 44e5dbcaf0 Extend ConstantFolding to understand signed overflow variants
llvm-svn: 83338
2009-10-05 22:53:52 +00:00
Chris Lattner 59d939894b teach the optimizer how to constant fold uadd/usub intrinsics.
llvm-svn: 83295
2009-10-05 05:26:04 +00:00
Nick Lewycky 9b3ed87506 Peer through zext and sext to eliminate them when it is safe to do so.
llvm-svn: 82389
2009-09-20 07:31:25 +00:00
Nick Lewycky b0225ba289 Fold 'icmp eq (icmp), true' into an xor(icmp).
llvm-svn: 82386
2009-09-20 07:21:39 +00:00
Nick Lewycky 22fc051bd7 Rewrite this check so that it checks what it's supposed to and doesn't use
CHECK-NOT.

llvm-svn: 82383
2009-09-20 07:00:24 +00:00
Nick Lewycky 28260409f2 Teach the constant folder how to not a cmpinst.
llvm-svn: 82378
2009-09-20 06:24:51 +00:00
Nick Lewycky 4a03452077 Try turning icmp(bitcast(x), bitcast(y)) into icmp(bitcast(bitcast(x)), y) in
the hopes that the two bitcasts will merge.

llvm-svn: 82371
2009-09-20 05:48:50 +00:00
Nick Lewycky 605109d151 Teach the constant folder how to handle a few simple i1 cases.
llvm-svn: 82340
2009-09-20 00:04:02 +00:00
Chris Lattner d7490a4763 convert to filecheck
llvm-svn: 81848
2009-09-15 06:34:29 +00:00
Dan Gohman 1880092722 Change tests from "opt %s" to "opt < %s" so that opt doesn't see the
input filename so that opt doesn't print the input filename in the
output so that grep lines in the tests don't unintentionally match
strings in the input filename.

llvm-svn: 81537
2009-09-11 18:01:28 +00:00
Dan Gohman 72a13d2476 Use opt -S instead of piping bitcode output through llvm-dis.
llvm-svn: 81257
2009-09-08 22:34:10 +00:00
Dan Gohman 9737a63ed8 Change these tests to feed the assembly files to opt directly, instead
of using llvm-as, now that opt supports this.

llvm-svn: 81226
2009-09-08 16:50:01 +00:00
Daniel Dunbar 77e2f2583b Eliminate some Tclisms.
llvm-svn: 81081
2009-09-05 11:34:46 +00:00
Chris Lattner defbbc9105 Fix month.
llvm-svn: 80769
2009-09-02 06:34:22 +00:00
Chris Lattner 950e60ea97 fix PR4848 an infinite loop when indexing down through a recursive gep
and we get the original pointer type.  This doesn't mean that we're
at the first pointer being indexed.  Correct the predicate.

llvm-svn: 80762
2009-09-02 05:35:45 +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
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
Chris Lattner 1baace07c4 apply Eli's patch for PR2165 and provide a testcase.
llvm-svn: 57625
2008-10-16 05:26:51 +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 4f1a9ffc09 'Optimize' test
llvm-svn: 53242
2008-07-08 18:33:33 +00:00