[llvm] 119aac0 - EarlyCSE: refactor getOrCreateResult (NFC) (#113339)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 06:27:58 PST 2024
Author: Ramkumar Ramachandra
Date: 2024-11-05T14:27:48Z
New Revision: 119aac00d5d3001cce80dbe6cba065873836e1d4
URL: https://github.com/llvm/llvm-project/commit/119aac00d5d3001cce80dbe6cba065873836e1d4
DIFF: https://github.com/llvm/llvm-project/commit/119aac00d5d3001cce80dbe6cba065873836e1d4.diff
LOG: EarlyCSE: refactor getOrCreateResult (NFC) (#113339)
Added:
Modified:
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index a1dbb4e1d5e75f..cd4846e006031d 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -964,33 +964,26 @@ class EarlyCSE {
bool overridingStores(const ParseMemoryInst &Earlier,
const ParseMemoryInst &Later);
- Value *getOrCreateResult(Value *Inst, Type *ExpectedType) const {
- // TODO: We could insert relevant casts on type mismatch here.
- if (auto *LI = dyn_cast<LoadInst>(Inst))
- return LI->getType() == ExpectedType ? LI : nullptr;
- if (auto *SI = dyn_cast<StoreInst>(Inst)) {
- Value *V = SI->getValueOperand();
- return V->getType() == ExpectedType ? V : nullptr;
+ Value *getOrCreateResult(Instruction *Inst, Type *ExpectedType) const {
+ // TODO: We could insert relevant casts on type mismatch.
+ // The load or the store's first operand.
+ Value *V;
+ if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::masked_load:
+ V = II;
+ break;
+ case Intrinsic::masked_store:
+ V = II->getOperand(0);
+ break;
+ default:
+ return TTI.getOrCreateResultFromMemIntrinsic(II, ExpectedType);
+ }
+ } else {
+ V = isa<LoadInst>(Inst) ? Inst : cast<StoreInst>(Inst)->getValueOperand();
}
- assert(isa<IntrinsicInst>(Inst) && "Instruction not supported");
- auto *II = cast<IntrinsicInst>(Inst);
- if (isHandledNonTargetIntrinsic(II->getIntrinsicID()))
- return getOrCreateResultNonTargetMemIntrinsic(II, ExpectedType);
- return TTI.getOrCreateResultFromMemIntrinsic(II, ExpectedType);
- }
- Value *getOrCreateResultNonTargetMemIntrinsic(IntrinsicInst *II,
- Type *ExpectedType) const {
- // TODO: We could insert relevant casts on type mismatch here.
- switch (II->getIntrinsicID()) {
- case Intrinsic::masked_load:
- return II->getType() == ExpectedType ? II : nullptr;
- case Intrinsic::masked_store: {
- Value *V = II->getOperand(0);
- return V->getType() == ExpectedType ? V : nullptr;
- }
- }
- return nullptr;
+ return V->getType() == ExpectedType ? V : nullptr;
}
/// Return true if the instruction is known to only operate on memory
More information about the llvm-commits
mailing list