diff options
| author | Philip Reames <listmail@philipreames.com> | 2018-08-10 22:21:56 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2018-08-10 22:21:56 +0000 |
| commit | 85afd1a9a085d8022b2476a2158aaf62864e8d94 (patch) | |
| tree | 3d1060453481f35c9fd186c57b8ab25a831b45ee /llvm/lib/Transforms | |
| parent | b99f131ffd780170f0e012fca55d23dd0cc8b60a (diff) | |
| download | bcm5719-llvm-85afd1a9a085d8022b2476a2158aaf62864e8d94.tar.gz bcm5719-llvm-85afd1a9a085d8022b2476a2158aaf62864e8d94.zip | |
[LICM] Hoist assumes out of loops
If we have an assume which is known to execute and whose operand is invariant, we can lift that into the pre-header. So long as we don't change which paths the assume executes on, this is a legal transformation. It's likely to be a useful canonicalization as other transforms only look for dominating assumes.
Differential Revision: https://reviews.llvm.org/D50364
llvm-svn: 339481
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 4150d9fece1..b99c6d3d4ea 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -658,6 +658,15 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, if (CI->mayThrow()) return false; + if (Function *F = CI->getCalledFunction()) + switch (F->getIntrinsicID()) { + default: break; + // TODO: support invariant.start, and experimental.guard here + case Intrinsic::assume: + // Assumes don't actually alias anything or throw + return true; + }; + // Handle simple cases by querying alias analysis. FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI); if (Behavior == FMRB_DoesNotAccessMemory) |

