[llvm] 9247b01 - [SCEVExpander] Use CreateBitOrPointerCast instead of builder (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 01:24:53 PDT 2022
Author: Florian Hahn
Date: 2022-09-29T09:24:39+01:00
New Revision: 9247b012d6dda9add8a46329acd9641eb5af24e3
URL: https://github.com/llvm/llvm-project/commit/9247b012d6dda9add8a46329acd9641eb5af24e3
DIFF: https://github.com/llvm/llvm-project/commit/9247b012d6dda9add8a46329acd9641eb5af24e3.diff
LOG: [SCEVExpander] Use CreateBitOrPointerCast instead of builder (NFC).
Simplify the code by using CastInst::CreateBitOrPointerCast directly. By
not going through the builder, the temporary instruction also won't get
registered in InsertedValues & co, which means less work overall and
simplifies the clean-up.
Added:
Modified:
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index faceb0259e430..bc2779aee1c06 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1751,20 +1751,16 @@ Value *SCEVExpander::expandCodeForImpl(const SCEV *SH, Type *Ty) {
// would accept a insertion point and return an LCSSA phi for that
// insertion point, so there is no need to insert & remove the temporary
// instruction.
- Instruction *Tmp;
+ Type *ToTy;
if (Inst->getType()->isIntegerTy())
- Tmp = cast<Instruction>(Builder.CreateIntToPtr(
- Inst, Inst->getType()->getPointerTo(), "tmp.lcssa.user"));
- else {
- assert(Inst->getType()->isPointerTy());
- Tmp = cast<Instruction>(Builder.CreatePtrToInt(
- Inst, Type::getInt32Ty(Inst->getContext()), "tmp.lcssa.user"));
- }
+ ToTy = Inst->getType()->getPointerTo();
+ else
+ ToTy = Type::getInt32Ty(Inst->getContext());
+ Instruction *Tmp = CastInst::CreateBitOrPointerCast(
+ Inst, ToTy, "tmp.lcssa.user", &*Builder.GetInsertPoint());
V = fixupLCSSAFormFor(Tmp, 0);
// Clean up temporary instruction.
- InsertedValues.erase(Tmp);
- InsertedPostIncValues.erase(Tmp);
Tmp->eraseFromParent();
}
}
More information about the llvm-commits
mailing list