[llvm] [polly] [SCEV] Introduce SCEVUse, use it instead of const SCEV * (NFCI) (WIP). (PR #91961)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 12:29:26 PDT 2024
================
@@ -65,6 +65,117 @@ enum SCEVTypes : unsigned short;
extern bool VerifySCEV;
+class SCEV;
+
+class SCEVUse : public PointerIntPair<const SCEV *, 3> {
+ bool computeIsCanonical() const;
+ const SCEV *computeCanonical(ScalarEvolution &SE) const;
+
+public:
+ SCEVUse() : PointerIntPair(nullptr, 0) {}
+ SCEVUse(const SCEV *S) : PointerIntPair(S, 0) {}
+ SCEVUse(const SCEV *S, int Flags) : PointerIntPair(S, Flags) {
+ if (Flags > 0)
+ setInt(Flags | 1);
+ }
+
+ operator const SCEV *() const { return getPointer(); }
+ const SCEV *operator->() const { return getPointer(); }
+ const SCEV *operator->() { return getPointer(); }
+
+ void *getRawPointer() const { return getOpaqueValue(); }
+
+ bool isCanonical() const {
+ assert(((getFlags() & 1) != 0 || computeIsCanonical()) &&
+ "Canonical bit set incorrectly");
+ return (getFlags() & 1) == 0;
+ }
+
+ const SCEV *getCanonical(ScalarEvolution &SE) {
+ if (isCanonical())
+ return getPointer();
+ return computeCanonical(SE);
----------------
artagnon wrote:
I'm a little confused by why you can't computeCanonical at the callsites, and keep the canonical representation. Alternatively, why can't you computeCanonical in the constructor? Calling computeCanonical every time has caused a huge compile-time regression.
https://github.com/llvm/llvm-project/pull/91961
More information about the llvm-commits
mailing list