diff options
author | Nikita Popov <npopov@redhat.com> | 2023-11-08 16:53:11 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-11-08 16:53:47 +0100 |
commit | 2c61f9cab51b4e358e4c86343cbcfa6ffa8504a2 (patch) | |
tree | 0e364207f0ed7968c45e045e2a87d57ea4bef954 | |
parent | 3ccbd68480d0b8f777502300024725b9fc4ed81f (diff) |
[CVP] Fix use after scope
Store the result of ConstantRange::sdiv() in a variable, as
getSingleElement() will return a pointer to the APInt it contains.
-rw-r--r-- | llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index d58ea126f294..ece22428e3cb 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -911,7 +911,8 @@ static bool processSDiv(BinaryOperator *SDI, const ConstantRange &LCR, assert(!SDI->getType()->isVectorTy()); // Check whether the division folds to a constant. - if (const APInt *Elem = LCR.sdiv(RCR).getSingleElement()) { + ConstantRange DivCR = LCR.sdiv(RCR); + if (const APInt *Elem = DivCR.getSingleElement()) { SDI->replaceAllUsesWith(ConstantInt::get(SDI->getType(), *Elem)); SDI->eraseFromParent(); return true; |