[llvm] fdaf304 - [NFC][ScalarEvolution] Fix SCEVNAryExpr::getType().
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 12:58:28 PDT 2021
Author: Eli Friedman
Date: 2021-06-23T12:55:59-07:00
New Revision: fdaf304e0d984c9f919c6b6b2b108d0d31cbea87
URL: https://github.com/llvm/llvm-project/commit/fdaf304e0d984c9f919c6b6b2b108d0d31cbea87
DIFF: https://github.com/llvm/llvm-project/commit/fdaf304e0d984c9f919c6b6b2b108d0d31cbea87.diff
LOG: [NFC][ScalarEvolution] Fix SCEVNAryExpr::getType().
SCEVNAryExpr::getType() could return the wrong type for a SCEVAddExpr.
Remove it, and add getType() methods to the relevant subclasses.
NFC because nothing uses it directly, as far as I know; this is just
future-proofing.
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
index ad0c74717090..c0da311e4e48 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -210,8 +210,6 @@ class Type;
return make_range(op_begin(), op_end());
}
- Type *getType() const { return getOperand(0)->getType(); }
-
NoWrapFlags getNoWrapFlags(NoWrapFlags Mask = NoWrapMask) const {
return (NoWrapFlags)(SubclassData & Mask);
}
@@ -293,6 +291,8 @@ class Type;
: SCEVCommutativeExpr(ID, scMulExpr, O, N) {}
public:
+ Type *getType() const { return getOperand(0)->getType(); }
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const SCEV *S) {
return S->getSCEVType() == scMulExpr;
@@ -359,6 +359,7 @@ class Type;
: SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) {}
public:
+ Type *getType() const { return getStart()->getType(); }
const SCEV *getStart() const { return Operands[0]; }
const Loop *getLoop() const { return L; }
@@ -445,6 +446,8 @@ class Type;
}
public:
+ Type *getType() const { return getOperand(0)->getType(); }
+
static bool classof(const SCEV *S) {
return isMinMaxType(S->getSCEVType());
}
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 79925ed3dd4a..e330ed27c792 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -386,12 +386,14 @@ Type *SCEV::getType() const {
case scSignExtend:
return cast<SCEVCastExpr>(this)->getType();
case scAddRecExpr:
+ return cast<SCEVAddRecExpr>(this)->getType();
case scMulExpr:
+ return cast<SCEVMulExpr>(this)->getType();
case scUMaxExpr:
case scSMaxExpr:
case scUMinExpr:
case scSMinExpr:
- return cast<SCEVNAryExpr>(this)->getType();
+ return cast<SCEVMinMaxExpr>(this)->getType();
case scAddExpr:
return cast<SCEVAddExpr>(this)->getType();
case scUDivExpr:
More information about the llvm-commits
mailing list