1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

204 Commits

Author SHA1 Message Date
Dan Gohman
82df35a657 Fix a thinko in the code that adapted SCEVMulExpr operands for
use in expanding SCEVAddExprs with GEPs. The operands of a
SCEVMulExpr need to be multiplied together, not added.

llvm-svn: 72250
2009-05-22 07:14:20 +00:00
Dan Gohman
f61ddb4c06 Create ConstantExpr GEPs the correct way. This fixes
MultiSource/Benchmarks/Prolangs-C/football and a variety of other
failures.

llvm-svn: 72120
2009-05-19 19:18:01 +00:00
Dan Gohman
922033d119 Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.

Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.

llvm-svn: 72093
2009-05-19 02:15:55 +00:00
Dan Gohman
d57099a9eb Actually insert inserted instructions into the InsertedValues map.
llvm-svn: 70557
2009-05-01 17:13:31 +00:00
Dan Gohman
bc336eab6e Short-circuit inttoptr-ptrtoint constant expressions; these aren't
always folded by the regular constant folder because it doesn't have
TargetData information.

llvm-svn: 70553
2009-05-01 17:00:00 +00:00
Dan Gohman
c0f47d6ec1 Change SCEVExpander's expandCodeFor to provide more flexibility
with the persistent insertion point, and change IndVars to make
use of it. This fixes a bug where IndVars was holding on to a
stale insertion point and forcing the SCEVExpander to continue to
use it.

This fixes PR4038.

llvm-svn: 69892
2009-04-23 15:16:49 +00:00
Devang Patel
7daece3796 Fix cut-n-pasto.
llvm-svn: 69816
2009-04-22 18:51:05 +00:00
Dan Gohman
0ab6ecf6a1 SCEVExpander's InsertCastOfTo knows how to move existing cast
instructions in order to avoid inserting new ones. However, if
the cast instruction is the SCEVExpander's InsertPt, this
causes subsequently emitted instructions to be inserted near
the cast, and not at the location of the original insert point.
Fix this by adjusting the insert point in such cases.
This fixes PR4009.

llvm-svn: 69808
2009-04-22 16:11:16 +00:00
Dan Gohman
471996598f Use BasicBlock::iterator instead of Instruction* for insert points,
to better handle inserting instructions at the end of a block.

llvm-svn: 69807
2009-04-22 16:05:50 +00:00
Dan Gohman
55d8490e7b Introduce encapsulation for ScalarEvolution's TargetData object, and refactor
the code to minimize dependencies on TargetData.

llvm-svn: 69644
2009-04-21 01:07:12 +00:00
Dan Gohman
e2e949ee98 Use more const qualifiers with SCEV interfaces.
llvm-svn: 69450
2009-04-18 17:56:28 +00:00
Dan Gohman
fa5d93b54c Handle a pointer type correctly in SCEVExpander::visitAddRecExpr.
llvm-svn: 69310
2009-04-16 21:34:54 +00:00
Dan Gohman
99b21e5635 Fix a bug with inttoptr/ptrtoint casts where the pointer has a different
size from the integer, requiring zero extension or truncation. Don't
create ZExtInsts with pointer types. This fixes a regression in
consumer-jpeg.

llvm-svn: 69307
2009-04-16 19:25:55 +00:00
Dan Gohman
f7f9a14400 Fix SCEVExpander::visitSMaxExpr and SCEVExpander::visitUMaxExpr to
not create ICmpInsts with operands of different types. This fixes
a regression in Applications/d/make_dparser.

llvm-svn: 69294
2009-04-16 16:15:25 +00:00
Dan Gohman
1482541677 Teach SCEVExpander::InsertCastOfTo to avoid creating inttoptr-of-ptrtoint
and ptrtoint-of-inttoptr expressions. This fixes a regression in 300.twolf.

llvm-svn: 69293
2009-04-16 15:52:57 +00:00
Dan Gohman
98aa1d9693 Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.

Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.

Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.

llvm-svn: 69258
2009-04-16 03:18:22 +00:00
Nick Lewycky
911bb6122c Wind SCEV back in time, to Nov 18th. This 'fixes' PR3275, PR3294, PR3295,
PR3296 and PR3302.

llvm-svn: 62160
2009-01-13 09:18:58 +00:00
Nick Lewycky
81635468b3 Add a new SCEV representing signed division.
llvm-svn: 60407
2008-12-02 08:05:48 +00:00
Gabor Greif
5f75f1372e do not use deprecated interfaces
llvm-svn: 57433
2008-10-13 10:21:17 +00:00
Nick Lewycky
9cecc07bec Expand SCEVUDiv of power of 2 to a lshr instruction.
llvm-svn: 53217
2008-07-08 05:05:37 +00:00
Dan Gohman
81c83d9a1d Use SCEVAddRecExpr::isAffine.
llvm-svn: 52614
2008-06-22 19:23:09 +00:00
Dan Gohman
311865bd24 Move a few more SCEVExpander methods out-of-line.
llvm-svn: 52612
2008-06-22 19:09:18 +00:00
Dan Gohman
606a60ad68 Move SCEVExpander::visitAddExpr out-of-line.
llvm-svn: 52464
2008-06-18 16:37:11 +00:00
Dan Gohman
82f9df016e Move LSR's private isZero function to a public SCEV member
function, and make use of it in several places.

llvm-svn: 52463
2008-06-18 16:23:07 +00:00
Wojciech Matyjewicz
58f5cc8864 Fix PR2434. When scanning for exising binary operator to reuse don't
take into account the instrucion pointed by InsertPt. Thanks to it, 
returning the new value of InsertPt to the InsertBinop() caller can be 
avoided. The bug was, actually, in visitAddRecExpr() method which wasn't 
correctly handling changes of InsertPt. There shouldn't be any 
performance regression, as -gvn pass (run after -indvars) removes any 
redundant binops.

llvm-svn: 52291
2008-06-15 19:07:39 +00:00
Wojciech Matyjewicz
f66a7fe9de Change 'while' loop to 'do' loop.
Add a safety measure. It isn't safe to assume in ScalarEvolutionExpander that
all loops are in canonical form (but it should be safe for loops that have
AddRecs).
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

llvm-svn: 52275
2008-06-14 16:48:22 +00:00
Gabor Greif
d61f20217a API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Gabor Greif
6c6b8a57f3 API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Nick Lewycky
0b6cdd1eff Add 'umax' similar to 'smax' SCEV. Closes PR2003.
Parse reversed smax and umax as smin and umin and express them with negative
or binary-not SCEVs (which are really just subtract under the hood).

Parse 'xor %x, -1' as (-1 - %x).

Remove dead code (ConstantInt::get always returns a ConstantInt).

Don't use getIntegerSCEV(-1, Ty). The first value is an int, then it gets
passed into a uint64_t. Instead, create the -1 directly from
ConstantInt::getAllOnesValue().

llvm-svn: 47360
2008-02-20 06:48:22 +00:00
Wojciech Matyjewicz
8095000596 We should check that existing cast operation has the appropriate opcode before we reuse it.
llvm-svn: 46908
2008-02-09 18:30:13 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Nick Lewycky
1536b3f230 Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.
llvm-svn: 44319
2007-11-25 22:41:31 +00:00
Dan Gohman
68fc6d7395 Move the SCEV object factors from being static members of the individual
SCEV subclasses to being non-static member functions of the ScalarEvolution
class.

llvm-svn: 43224
2007-10-22 18:31:58 +00:00
Dan Gohman
5f29ab68e1 Change "tmp." to "tmp" for temporaries created by ScalarEvolutionExpander
for consistency with many other transforms.

llvm-svn: 41957
2007-09-14 20:11:40 +00:00
Anton Korobeynikov
4e15adaf04 - Use correct header for SCEV inside LoopPass.cpp
- Move SCEVExpander::expand() out-of-line workarounding possible toolchain bug

llvm-svn: 41197
2007-08-20 21:17:26 +00:00
Dan Gohman
1c73ccb4d3 Fold a binary operator with constant operands when expanding code for a SCEV.
llvm-svn: 37602
2007-06-15 19:21:55 +00:00
Dan Gohman
838ba27094 Add a SCEV class and supporting code for sign-extend expressions.
This created an ambiguity for expandInTy to decide when to use
sign-extension or zero-extension, but it turns out that most of its callers
don't actually need a type conversion, now that LLVM types don't have
explicit signedness. Drop expandInTy in favor of plain expand, and change
the few places that actually need a type conversion to do it themselves.

llvm-svn: 37591
2007-06-15 14:38:12 +00:00
Chris Lattner
af290edea7 Be more careful when inserting reused instructions. This fixes CodeGen/Generic/2007-04-17-lsr-crash.ll
llvm-svn: 36231
2007-04-17 23:43:50 +00:00
Chris Lattner
335f1cb1f8 CSE simple binary expressions when they are inserted. This makes LSR produce
less huge code that needs to be cleaned up by sdisel.

llvm-svn: 35959
2007-04-13 05:04:18 +00:00
Reid Spencer
1f970769e8 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
30758bbe85 Avoid a potential assert out if the loop increment is > 64 bits.
llvm-svn: 34798
2007-03-01 19:45:00 +00:00
Reid Spencer
e33c18f4d2 For PR970:
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!

llvm-svn: 33415
2007-01-21 00:29:26 +00:00
Chris Lattner
c5e1611848 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! :)

llvm-svn: 33225
2007-01-15 02:27:26 +00:00
Zhou Sheng
23d24526b2 For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.

llvm-svn: 33073
2007-01-11 12:24:14 +00:00
Reid Spencer
ad772bfec3 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.

llvm-svn: 32535
2006-12-13 08:06:42 +00:00
Reid Spencer
0e981c9088 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.

llvm-svn: 32514
2006-12-12 23:36:14 +00:00
Bill Wendling
a3246c4272 Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.

llvm-svn: 32298
2006-12-07 01:30:32 +00:00
Reid Spencer
01a0443bdd Fix 80 cols violation
llvm-svn: 32179
2006-12-04 17:04:44 +00:00
Bill Wendling
4effa38086 Replacing std::iostreams with llvm iostreams. Some of these changes involve
adding a temporary wrapper around the ostream to make it friendly to
functions expecting an LLVM stream. This should be fixed in the future.

llvm-svn: 31990
2006-11-29 00:19:40 +00:00
Reid Spencer
992d9788b3 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.

llvm-svn: 31931
2006-11-27 01:05:10 +00:00
Reid Spencer
d414793dbc For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.

llvm-svn: 31063
2006-10-20 07:07:24 +00:00
Chris Lattner
151eb931ec Pull the InsertCastOfTo out of the header, implement CSE'ing of arguments.
llvm-svn: 25973
2006-02-04 09:51:53 +00:00
Chris Lattner
2724ebe02e Fix a problem that Nate noticed with LSR:
When inserting code for an addrec expression with a non-unit stride, be
more careful where we insert the multiply.  In particular, insert the multiply
in the outermost loop we can, instead of the requested insertion point.

This allows LSR to notice the mul in the right loop, reducing it when it gets
to it.  This allows it to reduce the multiply, where before it missed it.

This happens quite a bit in the test suite, for example, eliminating 2
multiplies in art, 3 in ammp, 4 in apsi, reducing from 1050 multiplies to
910 muls in galgel (!), from 877 to 859 in applu, and 36 to 30 in bzip2.

This speeds up galgel from 16.45s to 16.01s, applu from 14.21 to 13.94s and
fourinarow from 66.67s to 63.48s.

This implements Transforms/LoopStrengthReduce/nested-reduce.ll

llvm-svn: 24102
2005-10-30 06:24:33 +00:00
Nate Begeman
0d1a7b6737 Break SCEVExpander out of IndVarSimplify into its own .h/.cpp file so that
other passes may use it.

llvm-svn: 22557
2005-07-30 00:12:19 +00:00