Commit Graph

5125 Commits

Author SHA1 Message Date
Nick Lewycky a8e84fb56b Turn cos(-x) into cos(x). Patch by Alexander Malyshev!
llvm-svn: 147291
2011-12-27 18:25:50 +00:00
Rafael Espindola 2b14b80b60 Fix warning.
llvm-svn: 147284
2011-12-26 23:12:42 +00:00
Nick Lewycky d9d1de4f69 Fix typo "infinte".
llvm-svn: 147226
2011-12-23 23:49:25 +00:00
Chad Rosier 3ba90a1655 Add the actual code for r147175.
llvm-svn: 147176
2011-12-22 21:10:46 +00:00
Chad Rosier 1b7e2baf47 Speculatively revert r146578 to determine if it is the cause of a number of
performance regressions (both execution-time and compile-time) on our
nightly testers.

Original commit message:
Fix for bug #11429: Wrong behaviour for switches. Small improvement for code
size heuristics.

llvm-svn: 147131
2011-12-22 02:40:57 +00:00
Dan Gohman 51c81685a8 Fix a copy+pasto. No testcase, because the symptoms of dereferencing
an invalid iterator aren't reproducible.  rdar://10614085.

llvm-svn: 147098
2011-12-21 21:43:50 +00:00
Dan Gohman 75d7d5e988 Move Instruction::isSafeToSpeculativelyExecute out of VMCore and
into Analysis as a standalone function, since there's no need for
it to be in VMCore. Also, update it to use isKnownNonZero and
other goodies available in Analysis, making it more precise,
enabling more aggressive optimization.

llvm-svn: 146610
2011-12-14 23:49:11 +00:00
Stepan Dyatkovskiy d7b2bb3bdd Fix for bug #11429: Wrong behaviour for switches. Small improvement for code size heuristics.
llvm-svn: 146578
2011-12-14 19:19:17 +00:00
Dan Gohman bd944b4153 It turns out that clang does use pointer-to-function types to
point to ARC-managed pointers sometimes. This fixes rdar://10551239.

llvm-svn: 146577
2011-12-14 19:10:53 +00:00
Andrew Trick dc18e383b7 Cleanup. Clarify LSRInstance public methods.
llvm-svn: 146459
2011-12-13 00:55:33 +00:00
Andrew Trick dbe2bdf9e7 Indvars: guard against exponential behavior in isHighCostExpansion.
This should always be done as a matter of principal. I don't have a
case that exposes the problem. I just noticed this recently while
scanning the code and realized I meant to fix it long ago.

llvm-svn: 146438
2011-12-12 22:46:16 +00:00
Joerg Sonnenberger 45c4164166 Only replace fwrite with fputc, if the return value is unused.
llvm-svn: 146411
2011-12-12 20:18:31 +00:00
Daniel Dunbar 27a7489a03 LLVMBuild: Remove trailing newline, which irked me.
llvm-svn: 146409
2011-12-12 19:48:00 +00:00
Dan Gohman a53a12ce03 When computing reverse-CFG reverse-post-order, skip backedges, as
detected in the forward-CFG DFS. This prevents the reverse-CFG from
visiting blocks inside loops after blocks that dominate them in the
case where loops have multiple exits.

No testcase, because this fixes a bug which in practice only shows
up in a full optimizer run, due to the use-list order.

This fixes rdar://10422791 and others.

llvm-svn: 146408
2011-12-12 19:42:25 +00:00
Dan Gohman 766a54bde5 Add a TODO comment.
llvm-svn: 146389
2011-12-12 18:30:26 +00:00
Dan Gohman 20db059d06 Fix a copy+pasto in a comment.
llvm-svn: 146385
2011-12-12 18:20:00 +00:00
Dan Gohman 09b272bb2b Use getArgOperand instead of getOperand on a call.
llvm-svn: 146384
2011-12-12 18:19:12 +00:00
Dan Gohman 843044b75b Inline SetSeqToRelease into its only caller, since it's more clear that way.
llvm-svn: 146383
2011-12-12 18:16:56 +00:00
Dan Gohman 0444370645 Fix omitted break statements in a switch.
llvm-svn: 146380
2011-12-12 18:13:53 +00:00
Chandler Carruth 58a71ed339 Switch llvm.cttz and llvm.ctlz to accept a second i1 parameter which
indicates whether the intrinsic has a defined result for a first
argument equal to zero. This will eventually allow these intrinsics to
accurately model the semantics of GCC's __builtin_ctz and __builtin_clz
and the X86 instructions (prior to AVX) which implement them.

This patch merely sets the stage by extending the signature of these
intrinsics and establishing auto-upgrade logic so that the old spelling
still works both in IR and in bitcode. The upgrade logic preserves the
existing (inefficient) semantics. This patch should not change any
behavior. CodeGen isn't updated because it can use the existing
semantics regardless of the flag's value.

Note that this will be followed by API updates to Clang and DragonEgg.

Reviewed by Nick Lewycky!

llvm-svn: 146357
2011-12-12 04:26:04 +00:00
Andrew Trick e8b4f409b2 LSR: ignore strides in outer loops.
Since we're not rewriting IVs in other loops, there's not much reason
to consider their stride when generating formulae.
This should reduce the number of useless formulas considered by LSR.

llvm-svn: 146302
2011-12-10 00:25:00 +00:00
Jakub Staszak f5b32e52db SplitBlockPredecessors uses ArrayRef instead of Data and Size.
llvm-svn: 146277
2011-12-09 21:19:53 +00:00
Andrew Trick d04d152998 Add -unroll-runtime for unrolling loops with run-time trip counts.
Patch by Brendon Cahoon!

This extends the existing LoopUnroll and LoopUnrollPass. Brendon
measured no regressions in the llvm test suite with -unroll-runtime
enabled. This implementation works by using the existing loop
unrolling code to unroll the loop by a power-of-two (default 8). It
generates an if-then-else sequence of code prior to the loop to
execute the extra iterations before entering the unrolled loop.

llvm-svn: 146245
2011-12-09 06:19:40 +00:00
Nick Lewycky fe970725cc Fix infinite loop in DSE when deleting a free in a reachable loop that's also
trivially infinite.

llvm-svn: 146197
2011-12-08 22:36:35 +00:00
Benjamin Kramer b3bd019cd7 Push StringRefs through the metadata interface.
llvm-svn: 145934
2011-12-06 11:50:26 +00:00
Andrew Trick 5df9096584 LSR: prune undesirable formulae early.
It's always good to prune early, but formulae that are unsatisfactory
in their own right need to be removed before running any other pruning
heuristics. We easily avoid generating such formulae, but we need them
as an intermediate basis for forming other good formulae.

llvm-svn: 145906
2011-12-06 03:13:31 +00:00
Chad Rosier 3277557741 Update comment.
llvm-svn: 145866
2011-12-05 22:53:09 +00:00
Chad Rosier 19446a07a7 Make the MemCpyOptimizer a bit more aggressive. I can't think of a scenerio
where this would be bad as the backend shouldn't have a problem inlining small
memcpys.
rdar://10510150

llvm-svn: 145865
2011-12-05 22:37:00 +00:00
Nadav Rotem 3924cb0267 Add support for vectors of pointers.
llvm-svn: 145801
2011-12-05 06:29:09 +00:00
Pete Cooper e03fe83d98 Fixed deadstoreelimination bug where negative indices were incorrectly causing the optimisation to occur
Turns out long long + unsigned long long is unsigned.  Doh!

Fixes http://llvm.org/bugs/show_bug.cgi?id=11455

llvm-svn: 145731
2011-12-03 00:04:30 +00:00
Chad Rosier 43a33066b4 Fix a few more places where TargetData/TargetLibraryInfo is not being passed.
Add FIXMEs to places that are non-trivial to fix.

llvm-svn: 145661
2011-12-02 01:26:24 +00:00
Chad Rosier e6de63dfc5 Last bit of TargetLibraryInfo propagation. Also fixed a case for TargetData
where it appeared beneficial to pass.
More of rdar://10500969

llvm-svn: 145630
2011-12-01 21:29:16 +00:00
Chad Rosier c24b86ffbe Propagate TargetLibraryInfo throughout ConstantFolding.cpp and
InstructionSimplify.cpp.  Other fixups as needed.
Part of rdar://10500969

llvm-svn: 145559
2011-12-01 03:08:23 +00:00
Eli Friedman 6cff9df298 Make GlobalMerge honor the preferred alignment on globals without an explicitly specified alignment.
<rdar://problem/10497732>.

llvm-svn: 145523
2011-11-30 21:54:15 +00:00
Stepan Dyatkovskiy 31798ef3c0 Potential bug in RewriteLoopBodyWithConditionConstant: use iterator should not be changed inside the uses enumeration loop.
llvm-svn: 145432
2011-11-29 20:34:39 +00:00
Daniel Dunbar 539d0a8a09 build/CMake: Finish removal of add_llvm_library_dependencies.
llvm-svn: 145420
2011-11-29 19:25:30 +00:00
Andrew Trick d25089f8e0 SCEV fix. In general, Add/Mul expressions should not inherit NSW/NUW.
This reverts r139450, fixes r139453, and adds much needed comments and a
unit test.

llvm-svn: 145367
2011-11-29 02:16:38 +00:00
Andrew Trick a8bdb7cbf1 Remove the temporary flag -disable-unroll-scev and dead code.
SCEV should now be used for trip count analysis, not LoopInfo.

llvm-svn: 145262
2011-11-28 19:22:09 +00:00
Benjamin Kramer 7ba71be392 Move code into anonymous namespaces.
llvm-svn: 145154
2011-11-26 23:01:57 +00:00
Nick Lewycky 612d70b19d Refactor code to use new attribute getters on CallSite for NoCapture and ByVal.
Suggested in code review by Eli.

That code in InstCombine looks kinda suspicious.

llvm-svn: 145013
2011-11-20 19:09:04 +00:00
Eli Friedman 489c0ff4a4 Add support for custom names for library functions in TargetLibraryInfo. Add a custom name for fwrite and fputs on x86-32 OSX. Make SimplifyLibCalls honor the custom
names for fwrite and fputs.

Fixes <rdar://problem/9815881>.

llvm-svn: 144876
2011-11-17 01:27:36 +00:00
Nick Lewycky c7f1e7993c Merge isObjectPointerWithTrustworthySize with getPointerSize. Use it when
looking at the size of the pointee. Fixes PR11390!

llvm-svn: 144773
2011-11-16 03:49:48 +00:00
Nadav Rotem 51f71054b6 Fix MSVC warnings by adding a cast.
llvm-svn: 144721
2011-11-15 22:54:21 +00:00
Benjamin Kramer b106bcc536 StringRefize and simplify.
llvm-svn: 144675
2011-11-15 19:12:09 +00:00
Eli Friedman ecb453805d Make sure scalarrepl picks the correct alloca when it rewrites a bitcast. Fixes PR11353.
llvm-svn: 144442
2011-11-12 02:07:50 +00:00
Eli Friedman 0a309292c4 Get rid of an optimization in SCCP which appears to have many issues. Specifically, it doesn't handle many cases involving undef correctly, and it is missing other checks which
lead to it trying to re-mark a value marked as a constant with a different value.  It also appears to trigger very rarely.

Fixes PR11357.

llvm-svn: 144352
2011-11-11 01:16:15 +00:00
Pete Cooper a4237c380e Fixed bug in DeadStoreElimination commit r144239
Size of data being pointed to wasn't always being checked so some small writes were killing big writes

Fixes <rdar://problem/10426753>

llvm-svn: 144312
2011-11-10 20:22:08 +00:00
Pete Cooper 856977cb15 DeadStoreElimination can now trim the size of a store if the end of the store is dead.
Currently checks alignment and killing stores on a power of 2 boundary as this is likely
to trim the size of the earlier store without breaking large vector stores into scalar ones.

Fixes <rdar://problem/10140300>

llvm-svn: 144239
2011-11-09 23:07:35 +00:00
Pete Cooper 9ee220915b LICM pass now understands invariant load metadata. Nothing generates this yet so it will currently never get used in real tests
llvm-svn: 144107
2011-11-08 19:30:00 +00:00
Nick Lewycky f2905afe62 Do simple cross-block DSE when we encounter a free statement. Fixes PR11240.
llvm-svn: 143808
2011-11-05 10:48:42 +00:00