diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-07-23 05:06:28 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-07-23 05:06:28 +0000 |
| commit | 8a8fb908dcf4ec1fd85e4a91333bc90d40cf4918 (patch) | |
| tree | 378ed623f97ee2ad5703f4a707289c94bc79f480 /llvm/lib/Transforms | |
| parent | e754764aa96fdb0266da0b13244e50f39c126c7b (diff) | |
| download | bcm5719-llvm-8a8fb908dcf4ec1fd85e4a91333bc90d40cf4918.tar.gz bcm5719-llvm-8a8fb908dcf4ec1fd85e4a91333bc90d40cf4918.zip | |
"Allow LICM to sink or lift loads from constant memory. Also add a test
case for this.
This allows instructions like loads from global variables declared to
be constant to be moved out of loops."
Patch by Stefanus Du Toit!
llvm-svn: 53945
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index f7afaf44da5..13440c13b65 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -370,6 +370,11 @@ bool LICM::canSinkOrHoistInst(Instruction &I) { if (LI->isVolatile()) return false; // Don't hoist volatile loads! + // Loads from constant memory are always safe to move, even if they end up + // in the same alias set as something that ends up being modified. + if (AA->pointsToConstantMemory(LI->getOperand(0))) + return true; + // Don't hoist loads which have may-aliased stores in loop. unsigned Size = 0; if (LI->getType()->isSized()) |

