diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-10-23 18:12:54 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-10-25 10:56:25 +0200 |
commit | 75384ecdf8049b6eb8934790f1239c0c6c0a2502 (patch) | |
tree | c9e5a89f857797c23a77e95b50994d3b7650860b /llvm/lib/IR/Value.cpp | |
parent | a6c4969f5f451d40a1eef86e75689e2d90aa3a4a (diff) | |
download | llvm-75384ecdf8049b6eb8934790f1239c0c6c0a2502.zip llvm-75384ecdf8049b6eb8934790f1239c0c6c0a2502.tar.gz llvm-75384ecdf8049b6eb8934790f1239c0c6c0a2502.tar.bz2 |
[InstSimplify] Refactor invariant.group load folding
Currently strip.invariant/launder.invariant are handled by
constructing constant expressions with the intrinsics skipped.
This takes an alternative approach of accumulating the offset
using stripAndAccumulateConstantOffsets(), with a flag to look
through invariant.group intrinsics.
Differential Revision: https://reviews.llvm.org/D112382
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 0f11bf61..4136a9a 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -706,6 +706,7 @@ const Value *Value::stripPointerCastsForAliasAnalysis() const { const Value *Value::stripAndAccumulateConstantOffsets( const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, + bool AllowInvariantGroup, function_ref<bool(Value &, APInt &)> ExternalAnalysis) const { if (!getType()->isPtrOrPtrVectorTy()) return this; @@ -765,6 +766,8 @@ const Value *Value::stripAndAccumulateConstantOffsets( } else if (const auto *Call = dyn_cast<CallBase>(V)) { if (const Value *RV = Call->getReturnedArgOperand()) V = RV; + if (AllowInvariantGroup && Call->isLaunderOrStripInvariantGroup()) + V = Call->getArgOperand(0); } assert(V->getType()->isPtrOrPtrVectorTy() && "Unexpected operand type!"); } while (Visited.insert(V).second); |