#
60db0589 |
| 07-Sep-2014 |
Hal Finkel <hfinkel@anl.gov> |
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits (and other associated functions in ValueTracking), a
Make use of @llvm.assume in ValueTracking (computeKnownBits, etc.)
This change, which allows @llvm.assume to be used from within computeKnownBits (and other associated functions in ValueTracking), adds some (optional) parameters to computeKnownBits and friends. These functions now (optionally) take a "context" instruction pointer, an AssumptionTracker pointer, and also a DomTree pointer, and most of the changes are just to pass this new information when it is easily available from InstSimplify, InstCombine, etc.
As explained below, the significant conceptual change is that known properties of a value might depend on the control-flow location of the use (because we care that the @llvm.assume dominates the use because assumptions have control-flow dependencies). This means that, when we ask if bits are known in a value, we might get different answers for different uses.
The significant changes are all in ValueTracking. Two main changes: First, as with the rest of the code, new parameters need to be passed around. To make this easier, I grouped them into a structure, and I made internal static versions of the relevant functions that take this structure as a parameter. The new code does as you might expect, it looks for @llvm.assume calls that make use of the value we're trying to learn something about (often indirectly), attempts to pattern match that expression, and uses the result if successful. By making use of the AssumptionTracker, the process of finding @llvm.assume calls is not expensive.
Part of the structure being passed around inside ValueTracking is a set of already-considered @llvm.assume calls. This is to prevent a query using, for example, the assume(a == b), to recurse on itself. The context and DT params are used to find applicable assumptions. An assumption needs to dominate the context instruction, or come after it deterministically. In this latter case we only handle the specific case where both the assumption and the context instruction are in the same block, and we need to exclude assumptions from being used to simplify their own ephemeral values (those which contribute only to the assumption) because otherwise the assumption would prove its feeding comparison trivial and would be removed.
This commit adds the plumbing and the logic for a simple masked-bit propagation (just enough to write a regression test). Future commits add more patterns (and, correspondingly, more regression tests).
llvm-svn: 217342
show more ...
|
Revision tags: llvmorg-3.5.0, llvmorg-3.5.0-rc4, llvmorg-3.5.0-rc3, llvmorg-3.5.0-rc2, llvmorg-3.5.0-rc1 |
|
#
b4db99c7 |
| 16-Jul-2014 |
Manuel Jacob <me@manueljacob.de> |
Fix comment in InstCombiner::visitAddrSpaceCast.
In the original version of the patch the behaviour was like described in the comment. This behaviour was changed before committing it without updati
Fix comment in InstCombiner::visitAddrSpaceCast.
In the original version of the patch the behaviour was like described in the comment. This behaviour was changed before committing it without updating the comment.
llvm-svn: 213117
show more ...
|
#
baabe509 |
| 15-Jun-2014 |
Jingyue Wu <jingyue@google.com> |
Canonicalize addrspacecast ConstExpr between different pointer types
As a follow-up to r210375 which canonicalizes addrspacecast instructions, this patch canonicalizes addrspacecast constant express
Canonicalize addrspacecast ConstExpr between different pointer types
As a follow-up to r210375 which canonicalizes addrspacecast instructions, this patch canonicalizes addrspacecast constant expressions.
Given clang uses ConstantExpr::getAddrSpaceCast to emit addrspacecast cosntant expressions, this patch is also a step towards having the frontend emit canonicalized addrspacecasts.
Piggyback a minor refactor in InstCombineCasts.cpp
Update three affected tests in addrspacecast-alias.ll, access-non-generic.ll and constant-fold-gep.ll and added one new test in constant-fold-address-space-pointer.ll
llvm-svn: 211004
show more ...
|
#
77145d94 |
| 06-Jun-2014 |
Jingyue Wu <jingyue@google.com> |
InstCombine: Canonicalize addrspacecast between different element types
addrspacecast X addrspace(M)* to Y addrspace(N)*
-->
bitcast X addrspace(M)* to Y addrspace(M)* addrspacecast Y addrspace(M)
InstCombine: Canonicalize addrspacecast between different element types
addrspacecast X addrspace(M)* to Y addrspace(N)*
-->
bitcast X addrspace(M)* to Y addrspace(M)* addrspacecast Y addrspace(M)* to Y addrspace(N)*
Updat all affected tests and add several new tests in addrspacecast.ll.
This patch is based on http://reviews.llvm.org/D2186 (authored by Matt Arsenault) with fixes and more tests.
llvm-svn: 210375
show more ...
|
Revision tags: llvmorg-3.4.2, llvmorg-3.4.2-rc1 |
|
#
a0653a3e |
| 14-May-2014 |
Jay Foad <jay.foad@gmail.com> |
Rename ComputeMaskedBits to computeKnownBits. "Masked" has been inappropriate since it lost its Mask parameter in r154011.
llvm-svn: 208811
|
#
e36e1168 |
| 28-Apr-2014 |
Hans Wennborg <hans@hanshq.net> |
InstCombine: don't drop 'inalloca' in PromoteCastOfAllocation (PR19569)
llvm-svn: 207426
|
Revision tags: llvmorg-3.4.1, llvmorg-3.4.1-rc2 |
|
#
f40110f4 |
| 25-Apr-2014 |
Craig Topper <craig.topper@gmail.com> |
[C++] Use 'nullptr'. Transforms edition.
llvm-svn: 207196
|
#
964daaaf |
| 22-Apr-2014 |
Chandler Carruth <chandlerc@gmail.com> |
[Modules] Fix potential ODR violations by sinking the DEBUG_TYPE definition below all of the header #include lines, lib/Transforms/... edition.
This one is tricky for two reasons. We again have a co
[Modules] Fix potential ODR violations by sinking the DEBUG_TYPE definition below all of the header #include lines, lib/Transforms/... edition.
This one is tricky for two reasons. We again have a couple of passes that define something else before the includes as well. I've sunk their name macros with the DEBUG_TYPE.
Also, InstCombine contains headers that need DEBUG_TYPE, so now those headers #define and #undef DEBUG_TYPE around their code, leaving them well formed modular headers. Fixing these headers was a large motivation for all of these changes, as "leaky" macros of this form are hard on the modules implementation.
llvm-svn: 206844
show more ...
|
#
5f1f26e8 |
| 21-Apr-2014 |
Chandler Carruth <chandlerc@gmail.com> |
[Modules] Sink all the DEBUG_TYPE defines for InstCombine out of the header files and into the cpp files.
These files will require more touches as the header files actually use DEBUG(). Eventually,
[Modules] Sink all the DEBUG_TYPE defines for InstCombine out of the header files and into the cpp files.
These files will require more touches as the header files actually use DEBUG(). Eventually, I'll have to introduce a matched #define and #undef of DEBUG_TYPE for the header files, but that comes as step N of many to clean all of this up.
llvm-svn: 206777
show more ...
|
Revision tags: llvmorg-3.4.1-rc1 |
|
#
cdf47884 |
| 09-Mar-2014 |
Chandler Carruth <chandlerc@gmail.com> |
[C++11] Add range based accessors for the Use-Def chain of a Value.
This requires a number of steps. 1) Move value_use_iterator into the Value class as an implementation detail 2) Change it to ac
[C++11] Add range based accessors for the Use-Def chain of a Value.
This requires a number of steps. 1) Move value_use_iterator into the Value class as an implementation detail 2) Change it to actually be a *Use* iterator rather than a *User* iterator. 3) Add an adaptor which is a User iterator that always looks through the Use to the User. 4) Wrap these in Value::use_iterator and Value::user_iterator typedefs. 5) Add the range adaptors as Value::uses() and Value::users(). 6) Update *all* of the callers to correctly distinguish between whether they wanted a use_iterator (and to explicitly dig out the User when needed), or a user_iterator which makes the Use itself totally opaque.
Because #6 requires churning essentially everything that walked the Use-Def chains, I went ahead and added all of the range adaptors and switched them to range-based loops where appropriate. Also because the renaming requires at least churning every line of code, it didn't make any sense to split these up into multiple commits -- all of which would touch all of the same lies of code.
The result is still not quite optimal. The Value::use_iterator is a nice regular iterator, but Value::user_iterator is an iterator over User*s rather than over the User objects themselves. As a consequence, it fits a bit awkwardly into the range-based world and it has the weird extra-dereferencing 'operator->' that so many of our iterators have. I think this could be fixed by providing something which transforms a range of T&s into a range of T*s, but that *can* be separated into another patch, and it isn't yet 100% clear whether this is the right move.
However, this change gets us most of the benefit and cleans up a substantial amount of code around Use and User. =]
llvm-svn: 203364
show more ...
|
#
820a908d |
| 04-Mar-2014 |
Chandler Carruth <chandlerc@gmail.com> |
[Modules] Move the LLVM IR pattern match header into the IR library, it obviously is coupled to the IR.
llvm-svn: 202818
|
#
aeff8a9c |
| 24-Feb-2014 |
Rafael Espindola <rafael.espindola@gmail.com> |
Make some DataLayout pointers const.
No functionality change. Just reduces the noise of an upcoming patch.
llvm-svn: 202087
|
#
37dc9e19 |
| 21-Feb-2014 |
Rafael Espindola <rafael.espindola@gmail.com> |
Rename many DataLayout variables from TD to DL.
I am really sorry for the noise, but the current state where some parts of the code use TD (from the old name: TargetData) and other parts use DL make
Rename many DataLayout variables from TD to DL.
I am really sorry for the noise, but the current state where some parts of the code use TD (from the old name: TargetData) and other parts use DL makes it hard to write a patch that changes where those variables come from and how they are passed along.
llvm-svn: 201827
show more ...
|
#
cb402911 |
| 24-Jan-2014 |
Alp Toker <alp@nuanti.com> |
Fix known typos
Sweep the codebase for common typos. Includes some changes to visible function names that were misspelt.
llvm-svn: 200018
|
#
b80e1699 |
| 19-Jan-2014 |
Benjamin Kramer <benny.kra@googlemail.com> |
InstCombine: Modernize a bunch of cast combines.
Also make them vector-aware.
llvm-svn: 199608
|
#
48b842ef |
| 18-Jan-2014 |
Owen Anderson <resistor@mac.com> |
Fix more instances of dropped fast math flags when optimizing FADD instructions. All found by inspection (aka grep).
llvm-svn: 199528
|
#
2d353d1a |
| 14-Jan-2014 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
Do pointer cast simplifications on addrspacecast
llvm-svn: 199254
|
#
f08a44f9 |
| 14-Jan-2014 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
Remove a check for an illegal condition.
Bitcasts can't be between address spaces anymore.
llvm-svn: 199253
|
Revision tags: llvmorg-3.4.0, llvmorg-3.4.0-rc3, llvmorg-3.4.0-rc2 |
|
#
c454964c |
| 28-Nov-2013 |
Stephen Canon <scanon@apple.com> |
Rein in overzealous InstCombine of fptrunc(OP(fpextend, fpextend)).
llvm-svn: 195934
|
Revision tags: llvmorg-3.4.0-rc1 |
|
#
12100bf7 |
| 16-Nov-2013 |
Hal Finkel <hfinkel@anl.gov> |
Apply the InstCombine fptrunc sqrt optimization to llvm.sqrt
InstCombine, in visitFPTrunc, applies the following optimization to sqrt calls:
(fptrunc (sqrt (fpext x))) -> (sqrtf x)
but does not
Apply the InstCombine fptrunc sqrt optimization to llvm.sqrt
InstCombine, in visitFPTrunc, applies the following optimization to sqrt calls:
(fptrunc (sqrt (fpext x))) -> (sqrtf x)
but does not apply the same optimization to llvm.sqrt. This is a problem because, to enable vectorization, Clang generates llvm.sqrt instead of sqrt in fast-math mode, and because this optimization is being applied to sqrt and not applied to llvm.sqrt, sometimes the fast-math code is slower.
This change makes InstCombine apply this optimization to llvm.sqrt as well.
This fixes the specific problem in PR17758, although the same underlying issue (optimizations applied to libcalls are not applied to intrinsics) exists for other optimizations in SimplifyLibCalls.
llvm-svn: 194935
show more ...
|
#
a9e95abc |
| 15-Nov-2013 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
Add instcombine visitor for addrspacecast
llvm-svn: 194786
|
#
5797bfd4 |
| 03-Oct-2013 |
Owen Anderson <resistor@mac.com> |
Pull fptrunc's upwards through selects when one of the select's selectands was a constant. This has a number of benefits, including producing small immediates (easier to materialize, smaller constan
Pull fptrunc's upwards through selects when one of the select's selectands was a constant. This has a number of benefits, including producing small immediates (easier to materialize, smaller constant pools) as well as being more likely to allow the fptrunc to fuse with a preceding instruction (truncating selects are unusual).
llvm-svn: 191929
show more ...
|
#
745101d6 |
| 21-Aug-2013 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
Teach InstCombine about address spaces
llvm-svn: 188926
|
#
d79f7d9e |
| 19-Aug-2013 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
Teach InstCombine visitGetElementPtr about address spaces
llvm-svn: 188721
|
#
94a028aa |
| 19-Aug-2013 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
commonPointerCast cleanups to make address space change easier
llvm-svn: 188719
|