Andrew Trick
b75279cbbd
indvars: minor cleanup in preparation for sign/zero extend elimination.
...
llvm-svn: 131716
2011-05-20 03:37:48 +00:00
Evan Cheng
e8d2e9eb35
Revert r131664 and fix it in instcombine instead. rdar://9467055
...
llvm-svn: 131708
2011-05-20 00:54:37 +00:00
Devang Patel
1407fb4bbe
Reapply r131605. This time with a fix, which is to use NoFolder.
...
llvm-svn: 131673
2011-05-19 20:52:46 +00:00
Evan Cheng
dc867ae1fc
Add comment.
...
llvm-svn: 131659
2011-05-19 18:18:39 +00:00
Rafael Espindola
964602d7ba
revert 131605 to fix PR9946.
...
llvm-svn: 131620
2011-05-19 02:26:30 +00:00
Eli Friedman
6efb64ea8e
Make the demanded bits/elements optimizations preserve debug line information.
...
I'm not sure this is quite ideal, but I can't really think of any better way to do it.
llvm-svn: 131616
2011-05-19 01:20:42 +00:00
Devang Patel
3015a54813
Use IRBuilder.
...
llvm-svn: 131609
2011-05-19 00:13:33 +00:00
Devang Patel
31458a0002
Use IRBuilder while simplifying unreachable.
...
llvm-svn: 131607
2011-05-19 00:09:21 +00:00
Devang Patel
4b13f39b77
Use IRBuilder while simplifying conditional branch.
...
llvm-svn: 131605
2011-05-18 23:59:51 +00:00
Eli Friedman
41e509a33d
More instcombine cleanup, towards improving debug line info.
...
llvm-svn: 131604
2011-05-18 23:58:37 +00:00
Devang Patel
7de6c4bf75
Use IRBuilder while simplifying branch.
...
llvm-svn: 131598
2011-05-18 23:18:47 +00:00
Eli Friedman
1754a25977
More instcombine simplifications towards better debug locations.
...
llvm-svn: 131596
2011-05-18 23:11:30 +00:00
Devang Patel
dd14e0f7fa
Use IRBuilder while simplifying return instruction.
...
llvm-svn: 131580
2011-05-18 21:33:11 +00:00
Dan Gohman
3268e4d692
When forming an ICmpZero LSRUse, normalize the non-IV operand
...
of the comparison, so that the resulting expression is fully
normalized. This fixes PR9939.
llvm-svn: 131576
2011-05-18 21:02:18 +00:00
Devang Patel
583805530c
Spread use of IRBuilder even more.
...
llvm-svn: 131571
2011-05-18 20:53:17 +00:00
Devang Patel
a7ec47d23c
Use IRBuilder while simplifying switch instruction.
...
llvm-svn: 131566
2011-05-18 20:35:38 +00:00
Devang Patel
0b373dca1f
Use IRBuilder while simplifying unwind.
...
llvm-svn: 131561
2011-05-18 20:01:18 +00:00
Eli Friedman
49346010f8
More instcombine cleanup aimed towards improving debug line info.
...
llvm-svn: 131559
2011-05-18 19:57:14 +00:00
Devang Patel
2c2ea226b7
Use IRBuilder while simplifying terminator.
...
llvm-svn: 131552
2011-05-18 18:43:31 +00:00
Devang Patel
767f6930bc
Use IRBuilder while simplifying unconditional branch.
...
llvm-svn: 131551
2011-05-18 18:28:48 +00:00
Devang Patel
5c810ce4a3
Use IRBuilder while folding two entry PHINode.
...
llvm-svn: 131548
2011-05-18 18:16:44 +00:00
Eli Friedman
2fd66441c6
Switch more inst insertion in instcombine to IRBuilder.
...
llvm-svn: 131547
2011-05-18 18:10:28 +00:00
Devang Patel
15ad6761da
Set up IRBuilder for use during simplification.
...
llvm-svn: 131545
2011-05-18 18:01:27 +00:00
Eli Friedman
0b43b9ee98
Switch more inst insertion in instcombine to IRBuilder.
...
llvm-svn: 131544
2011-05-18 17:58:37 +00:00
Matt Beaumont-Gay
8fa6ebf975
fix typo
...
llvm-svn: 131543
2011-05-18 17:37:10 +00:00
Eli Friedman
cde9c1628c
Switch inst insertion in instcombine transform to IRBuilder.
...
llvm-svn: 131542
2011-05-18 17:31:55 +00:00
Devang Patel
1fabbe921b
Use IRBuiler while constant folding terminator.
...
llvm-svn: 131541
2011-05-18 17:26:46 +00:00
Stuart Hastings
728f6260b9
Fix inelegant initialization.
...
llvm-svn: 131538
2011-05-18 15:54:26 +00:00
Duncan Sands
3d9407f4eb
Revert commit 131534 since it seems to have broken several buildbots.
...
Original log entry:
Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'
code in one place.
llvm-svn: 131536
2011-05-18 14:57:56 +00:00
Nadav Rotem
c5c27ede55
Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'
...
code in one place.
llvm-svn: 131534
2011-05-18 12:26:38 +00:00
Eli Friedman
96254a0d53
Start trying to make InstCombine preserve more debug info. The idea here is to set the debug location on the IRBuilder, which will be then right location in most cases. This should magically give many transformations debug locations, and fixing places which are missing a debug location will usually just means changing the code creating it to use the IRBuilder.
...
As an example, the change to InstCombineCalls catches a common case where a call to a bitcast of a function is rewritten.
Chris, does this approach look reasonable?
llvm-svn: 131516
2011-05-18 01:28:27 +00:00
Eli Friedman
b9ed18f2cb
Use ReplaceInstUsesWith instead of replaceAllUsesWith where appropriate in instcombine.
...
llvm-svn: 131512
2011-05-18 00:32:01 +00:00
Devang Patel
b849cd511b
Preseve line numbers while simplifying CFG.
...
llvm-svn: 131508
2011-05-17 23:29:05 +00:00
Bill Wendling
0671ba8448
Conditionalize the format of the GCOV files by target type. Darwin uses the 4.2
...
format.
llvm-svn: 131503
2011-05-17 23:05:13 +00:00
Stuart Hastings
5bd18b6638
X86 pmovsx/pmovzx ignore the upper half of their inputs.
...
rdar://problem/6945110
llvm-svn: 131493
2011-05-17 22:13:31 +00:00
Devang Patel
341b38c22a
Preserve line number information.
...
llvm-svn: 131482
2011-05-17 20:00:02 +00:00
Devang Patel
c5933f2418
Set debug loc for new load instruction.
...
llvm-svn: 131481
2011-05-17 19:43:38 +00:00
Devang Patel
c23bcbc498
Preserve line number information.
...
llvm-svn: 131480
2011-05-17 19:43:06 +00:00
Devang Patel
a0b682db62
There is no need to force DebugLoc on a PHI at this point.
...
llvm-svn: 131427
2011-05-16 22:05:03 +00:00
Devang Patel
8e60ff11db
Preserve debug info for unused zero extended boolean argument.
...
Radar 9422775.
llvm-svn: 131422
2011-05-16 21:24:05 +00:00
Rafael Espindola
2050af838d
Don't do tail calls in a function that call setjmp. The stack might be
...
corrupted when setjmp returns again.
llvm-svn: 131399
2011-05-16 03:05:33 +00:00
Benjamin Kramer
d96205c4e5
SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.
...
llvm-svn: 131345
2011-05-14 15:57:25 +00:00
Stuart Hastings
66a82b966e
Avoid combining GEPs that might overflow at runtime.
...
rdar://problem/9267970
Patch by Julien Lerouge!
llvm-svn: 131339
2011-05-14 05:55:10 +00:00
Julien Lerouge
7e11f9e26d
Fix a source of non determinism in FindUsedTypes, use a SetVector instead of a
...
set.
rdar://9423996
llvm-svn: 131283
2011-05-13 05:20:42 +00:00
Andrew Trick
03957dfeb1
Convert SimplifyIVUsers into a worklist instead of a single pass over
...
the users.
llvm-svn: 131277
2011-05-13 01:12:21 +00:00
Andrew Trick
81683ed232
indvars: Added SimplifyIVUsers.
...
Interleave IV simplifications. Currently involves EliminateComparison
and EliminateRemainder. Next I'll add EliminateExtend.
llvm-svn: 131210
2011-05-12 00:04:28 +00:00
Devang Patel
3fd06f760b
Preserve line number information.
...
llvm-svn: 131112
2011-05-10 00:03:11 +00:00
Duncan Sands
a071c82900
Fix PR9820: a read-only call differs from a load in that a load doesn't
...
return the pointer being dereferenced, it returns the pointee, but a call
might return the pointer itself.
llvm-svn: 130979
2011-05-06 10:30:37 +00:00
Nick Lewycky
a7028848a1
The computation of string length is not that complicated. Fix it, again. :)
...
llvm-svn: 130967
2011-05-05 23:52:18 +00:00
Eli Friedman
8a20e66926
PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift.
...
llvm-svn: 130954
2011-05-05 21:59:18 +00:00
Nick Lewycky
4f9c367f0b
Update the gcov version used slightly, to make it stop causing modern gcov's to
...
crash.
llvm-svn: 130911
2011-05-05 02:46:38 +00:00
Nick Lewycky
baa878ce4a
Remove dead function.
...
llvm-svn: 130903
2011-05-05 00:17:34 +00:00
Nick Lewycky
a3d5d167a8
When the path wasn't emitted by the frontend, discard any path on the source
...
filename.
llvm-svn: 130897
2011-05-05 00:03:30 +00:00
Devang Patel
ffb798c1c6
Set debug loc for new instructions.
...
llvm-svn: 130895
2011-05-04 23:58:50 +00:00
Devang Patel
ac794d46bf
Set debug location for new PHI nodes created in exit block.
...
llvm-svn: 130894
2011-05-04 23:58:22 +00:00
Devang Patel
306f8db721
Preserve line number information while threading jumps.
...
llvm-svn: 130880
2011-05-04 22:48:19 +00:00
Devang Patel
c7e4fa7c19
Preserve line number info.
...
llvm-svn: 130876
2011-05-04 21:58:58 +00:00
Devang Patel
0daa07eb90
preserve line number info.
...
llvm-svn: 130869
2011-05-04 21:37:05 +00:00
Nick Lewycky
6d9f061a6b
Emit gcov data files to the directory specified in the metadata produced by the
...
frontend, if applicable.
llvm-svn: 130835
2011-05-04 04:03:04 +00:00
Andrew Trick
1abe296cfd
indvars: Added DisableIVRewrite and WidenIVs.
...
This adds functionality to remove size/zero extension during indvars
without generating a canonical IV and rewriting all IV users. It's
disabled by default so should have no effect on codegen. Work in progress.
llvm-svn: 130829
2011-05-04 02:10:13 +00:00
Andrew Trick
38c4e34abb
indvars: Added canExpandBackEdgeTakenCount.
...
Only create a canonical IV for backedge taken count if it will
actually be used by LinearFunctionTestReplace. And some related
cleanup, preparing to reduce dependence on canonical IVs.
No significant effect on x86 or arm in the test-suite.
llvm-svn: 130799
2011-05-03 22:24:10 +00:00
Benjamin Kramer
9c373c1c7a
Remove unused variables caught by GCC's -Wunused-but-set-variable.
...
llvm-svn: 130755
2011-05-03 16:00:27 +00:00
Dan Gohman
6136e94897
Add an unfolded offset field to LSR's Formula record. This is used to
...
model constants which can be added to base registers via add-immediate
instructions which don't require an additional register to materialize
the immediate.
llvm-svn: 130743
2011-05-03 00:46:49 +00:00
Devang Patel
bb35e8ba88
Scanning entire basic block may be too expensive in terms of compile time. Instead, just use whatever location info first non-phi instruction has.
...
llvm-svn: 130729
2011-05-02 21:57:00 +00:00
Duncan Sands
6b699f863f
Remove unused variable.
...
llvm-svn: 130705
2011-05-02 18:41:29 +00:00
Duncan Sands
a3e3699c88
Move some rem transforms out of instcombine and into instsimplify.
...
This automagically provides a transform noticed by my super-optimizer
as occurring quite often: "rem x, (select cond, x, 1)" -> 0.
llvm-svn: 130694
2011-05-02 16:27:02 +00:00
Chris Lattner
23f61a09af
enhance memcpyopt to obey -fno-builtin and friends. This addresses a
...
problem reported on cfe-dev.
llvm-svn: 130661
2011-05-01 18:27:11 +00:00
Benjamin Kramer
9aa91b1f4e
InstCombine: Turn (zext A) udiv (zext B) into (zext (A udiv B)). Same for urem or constant B.
...
This obviously helps a lot if the division would be turned into a libcall
(think i64 udiv on i386), but div is also one of the few remaining instructions
on modern CPUs that become more expensive when the bitwidth gets bigger.
This also helps register pressure on i386 when dividing chars, divb needs
two 8-bit parts of a 16 bit register as input where divl uses two registers.
int foo(unsigned char a) { return a/10; }
int bar(unsigned char a, unsigned char b) { return a/b; }
compiles into (x86_64)
_foo:
imull $205, %edi, %eax
shrl $11, %eax
ret
_bar:
movzbl %dil, %eax
divb %sil, %al
movzbl %al, %eax
ret
llvm-svn: 130615
2011-04-30 18:16:07 +00:00
Benjamin Kramer
57b3df59b9
Use SimplifyDemandedBits on div instructions.
...
This folds away silly stuff like (a&255)/1000 -> 0.
llvm-svn: 130614
2011-04-30 18:16:00 +00:00
Devang Patel
a8e7411c74
Assing line number info to new PHIs created by SSA updater.
...
llvm-svn: 130551
2011-04-29 22:28:59 +00:00
Devang Patel
c1f7c1d469
Preserve line number information.
...
llvm-svn: 130536
2011-04-29 20:38:55 +00:00
Peter Collingbourne
616044acd5
SimplifyCFG: Expose phi node folding cost threshold as command line parameter
...
llvm-svn: 130528
2011-04-29 18:47:38 +00:00
Peter Collingbourne
e3511e15e0
SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint
...
llvm-svn: 130527
2011-04-29 18:47:31 +00:00
Peter Collingbourne
61f6602acd
SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for phi node folding
...
llvm-svn: 130526
2011-04-29 18:47:25 +00:00
Benjamin Kramer
f0e3f04470
Balance parentheses.
...
llvm-svn: 130489
2011-04-29 08:41:23 +00:00
Benjamin Kramer
16f18ed7b5
InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A)
...
Fixes PR9809.
llvm-svn: 130485
2011-04-29 08:15:41 +00:00
Devang Patel
80d1d3aaec
Preserve line number information.
...
llvm-svn: 130450
2011-04-28 22:48:14 +00:00
Benjamin Kramer
cf9d1ad62e
We require threse bits to be zero, too.
...
This shouldn't happen in practice because the icmp would be a constant.
Add a check so we don't miscompile code if something goes wrong.
llvm-svn: 130446
2011-04-28 21:38:51 +00:00
Nick Lewycky
6aa79492a5
Only read *predecessor once so as to fix a theoretical issue where it changes
...
between two reads (threading).
Fix an off-by-one in the indirect counter table that I meant to revert after an
earlier experiment. Whoops!
Implement GCOV_PREFIX. Doesn't handle GCOV_PREFIX_STRIP yet.
Fix an off-by-one in string emission. Extra whoops!
Tolerate DISubprograms that have null Function*'s attached to them. I don't yet
understand what this means, but it happens when you have a global static with
a non-trivial constructor/destructor.
Fix a crash on switch statements with a single successor (default-only).
llvm-svn: 130443
2011-04-28 21:35:49 +00:00
Devang Patel
72aa1a8a68
Remove DbgDeclare only if all uses are converted.
...
llvm-svn: 130431
2011-04-28 20:32:02 +00:00
Benjamin Kramer
101720fb58
Fix a comment.
...
llvm-svn: 130428
2011-04-28 20:09:57 +00:00
Chris Lattner
a5452c0d67
improve comment.
...
llvm-svn: 130426
2011-04-28 20:02:57 +00:00
Devang Patel
33d87d97f6
Do not lose line number info while eliminating tail call.
...
llvm-svn: 130419
2011-04-28 18:43:39 +00:00
Chris Lattner
1777601a74
final step needed to resolve PR6627, which allows us to flatten the code down to
...
a nice and tidy:
%x1 = load i32* %0, align 4
%1 = icmp eq i32 %x1, 1179403647
br i1 %1, label %if.then, label %if.end
instead of doing lots of loads and branches. May the FreeBSD bootloader
long fit in its allocated space.
llvm-svn: 130416
2011-04-28 18:15:47 +00:00
Chris Lattner
45e393fc9c
code cleanups only.
...
llvm-svn: 130414
2011-04-28 18:08:21 +00:00
Andrew Trick
c4456ae6ec
Reapply r130340: Fix for PR9730.
...
llvm-svn: 130408
2011-04-28 17:30:04 +00:00
Benjamin Kramer
4145c0d3b1
InstCombine: Merge "(trunc x) == C1 & (and x, CA) == C2" into a single and+icmp.
...
This happens when GVN widens loads. Part of PR6627.
llvm-svn: 130405
2011-04-28 16:58:40 +00:00
Chris Lattner
f81f789b6c
centralize "marking for deletion" into a helper function. Pass GVN around to
...
static functions instead of passing around tons of random ivars.
llvm-svn: 130403
2011-04-28 16:36:48 +00:00
Chris Lattner
6cec6ab275
Promote toErase to be an ivar of the GVN class.
...
llvm-svn: 130401
2011-04-28 16:18:52 +00:00
Chris Lattner
827a270a2a
teach GVN to widen integer loads when they are overaligned, when doing an
...
wider load would allow elimination of subsequent loads, and when the wider
load is still a native integer type. This eliminates a ton of loads on
various benchmarks involving struct fields, though it is somewhat hobbled
by clang not being very aggressive about field alignment.
This is yet another step along the way towards resolving PR6627.
llvm-svn: 130390
2011-04-28 07:29:08 +00:00
Andrew Trick
1e34241abd
Reverting r130340 in the unlikely event that it's responsible for a llvm-gcc stage2 compiler error.
...
llvm-svn: 130350
2011-04-28 00:13:59 +00:00
Andrew Trick
29ac7b8858
Fixes PR9730: indvars: An asserting value handle still pointed to this value
...
Modified LinearFunctionTestReplace to push the condition on the dead
list instead of eagerly deleting it. This can cause unnecessary
IV rewrites, which should have no effect on codegen and will not be an
issue once we stop generating canonical IVs.
llvm-svn: 130340
2011-04-27 23:00:03 +00:00
Devang Patel
12bf0ab4b5
Simplify cfg inserts a call to trap when unreachable code is detected. Assign DebugLoc to this new trap instruction.
...
llvm-svn: 130315
2011-04-27 17:59:27 +00:00
Duncan Sands
085ad3b81a
Stop trying to have instcombine preserve LCSSA form: this was not
...
effective in avoiding recomputation of LCSSA form; the widespread
use of instsimplify (which looks through phi nodes) means it was
not preserving LCSSA form anyway; and instcombine is no longer
scheduled in the middle of the loop passes so this doesn't matter
anymore.
llvm-svn: 130301
2011-04-27 10:55:12 +00:00
Chris Lattner
1b06c71668
Transform: "icmp eq (trunc (lshr(X, cst1)), cst" to "icmp (and X, mask), cst"
...
when X has multiple uses. This is useful for exposing secondary optimizations,
but the X86 backend isn't ready for this when X has a single use. For example,
this can disable load folding.
This is inching towards resolving PR6627.
llvm-svn: 130238
2011-04-26 20:18:20 +00:00
Chris Lattner
31b106d7dd
some random cleanups, no functionality change.
...
llvm-svn: 130237
2011-04-26 20:02:45 +00:00
Chris Lattner
eb045f9c02
Improve the bail-out predicate to really only kick in when phi
...
translation fails. We were bailing out in some cases that would
cause us to miss GVN'ing some non-local cases away.
llvm-svn: 130206
2011-04-26 17:41:02 +00:00
Nick Lewycky
c58d293a6f
Rename everything to follow LLVM style ... I think.
...
Add support for switch and indirectbr edges. This works by densely numbering
all blocks which have such terminators, and then separately numbering the
possible successors. The predecessors write down a number, the successor knows
its own number (as a ConstantInt) and sends that and the pointer to the number
the predecessor wrote down to the runtime, who looks up the counter in a
per-function table.
Coverage data should now be functional, but I haven't tested it on anything
other than my 2-file synthetic test program for coverage.
llvm-svn: 130186
2011-04-26 03:54:16 +00:00
Chris Lattner
6f83d06ffa
Enhance MemDep: When alias analysis returns a partial alias result,
...
return it as a clobber. This allows GVN to do smart things.
Enhance GVN to be smart about the case when a small load is clobbered
by a larger overlapping load. In this case, forward the value. This
allows us to compile stuff like this:
int test(void *P) {
int tmp = *(unsigned int*)P;
return tmp+*((unsigned char*)P+1);
}
into:
_test: ## @test
movl (%rdi), %ecx
movzbl %ch, %eax
addl %ecx, %eax
ret
which has one load. We already handled the case where the smaller
load was from a must-aliased base pointer.
llvm-svn: 130180
2011-04-26 01:21:15 +00:00
Jay Foad
1a180156b6
Remove unused STL header includes.
...
llvm-svn: 130068
2011-04-23 19:53:52 +00:00