[llvm] 7753ae8 - [SCEV] Remove unused alignof/offsetof print special cases (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 08:00:19 PST 2023


Author: Nikita Popov
Date: 2023-02-22T17:00:11+01:00
New Revision: 7753ae8da24cf16f380eff4eaac6d414937acf8e

URL: https://github.com/llvm/llvm-project/commit/7753ae8da24cf16f380eff4eaac6d414937acf8e
DIFF: https://github.com/llvm/llvm-project/commit/7753ae8da24cf16f380eff4eaac6d414937acf8e.diff

LOG: [SCEV] Remove unused alignof/offsetof print special cases (NFC)

These shouldn't really reach SCEV without being folded away first,
and we don't have any tests that hit these cases.

The sizeof case does occur with scalable types.

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 80443510d449c..9245cf1e5f4b7 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -580,15 +580,12 @@ class SCEVUnknown final : public SCEV, private CallbackVH {
   Value *getValue() const { return getValPtr(); }
 
   /// @{
-  /// Test whether this is a special constant representing a type
-  /// size, alignment, or field offset in a target-independent
-  /// manner, and hasn't happened to have been folded with other
-  /// operations into something unrecognizable. This is mainly only
+  /// Test whether this is a special constant representing a type size in a
+  /// target-independent manner, and hasn't happened to have been folded with
+  /// other operations into something unrecognizable. This is mainly only
   /// useful for pretty-printing and other situations where it isn't
   /// absolutely required for these to succeed.
   bool isSizeOf(Type *&AllocTy) const;
-  bool isAlignOf(Type *&AllocTy) const;
-  bool isOffsetOf(Type *&STy, Constant *&FieldNo) const;
   /// @}
 
   Type *getType() const { return getValPtr()->getType(); }

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 93257e330934f..5c2c12c7d0591 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -373,19 +373,6 @@ void SCEV::print(raw_ostream &OS) const {
       OS << "sizeof(" << *AllocTy << ")";
       return;
     }
-    if (U->isAlignOf(AllocTy)) {
-      OS << "alignof(" << *AllocTy << ")";
-      return;
-    }
-
-    Type *CTy;
-    Constant *FieldNo;
-    if (U->isOffsetOf(CTy, FieldNo)) {
-      OS << "offsetof(" << *CTy << ", ";
-      FieldNo->printAsOperand(OS, false);
-      OS << ")";
-      return;
-    }
 
     // Otherwise just print it normally.
     U->getValue()->printAsOperand(OS, false);
@@ -590,51 +577,6 @@ bool SCEVUnknown::isSizeOf(Type *&AllocTy) const {
   return false;
 }
 
-bool SCEVUnknown::isAlignOf(Type *&AllocTy) const {
-  if (ConstantExpr *VCE = dyn_cast<ConstantExpr>(getValue()))
-    if (VCE->getOpcode() == Instruction::PtrToInt)
-      if (ConstantExpr *CE = dyn_cast<ConstantExpr>(VCE->getOperand(0)))
-        if (CE->getOpcode() == Instruction::GetElementPtr &&
-            CE->getOperand(0)->isNullValue()) {
-          Type *Ty = cast<GEPOperator>(CE)->getSourceElementType();
-          if (StructType *STy = dyn_cast<StructType>(Ty))
-            if (!STy->isPacked() &&
-                CE->getNumOperands() == 3 &&
-                CE->getOperand(1)->isNullValue()) {
-              if (ConstantInt *CI = dyn_cast<ConstantInt>(CE->getOperand(2)))
-                if (CI->isOne() &&
-                    STy->getNumElements() == 2 &&
-                    STy->getElementType(0)->isIntegerTy(1)) {
-                  AllocTy = STy->getElementType(1);
-                  return true;
-                }
-            }
-        }
-
-  return false;
-}
-
-bool SCEVUnknown::isOffsetOf(Type *&CTy, Constant *&FieldNo) const {
-  if (ConstantExpr *VCE = dyn_cast<ConstantExpr>(getValue()))
-    if (VCE->getOpcode() == Instruction::PtrToInt)
-      if (ConstantExpr *CE = dyn_cast<ConstantExpr>(VCE->getOperand(0)))
-        if (CE->getOpcode() == Instruction::GetElementPtr &&
-            CE->getNumOperands() == 3 &&
-            CE->getOperand(0)->isNullValue() &&
-            CE->getOperand(1)->isNullValue()) {
-          Type *Ty = cast<GEPOperator>(CE)->getSourceElementType();
-          // Ignore vector types here so that ScalarEvolutionExpander doesn't
-          // emit getelementptrs that index into vectors.
-          if (Ty->isStructTy() || Ty->isArrayTy()) {
-            CTy = Ty;
-            FieldNo = CE->getOperand(2);
-            return true;
-          }
-        }
-
-  return false;
-}
-
 //===----------------------------------------------------------------------===//
 //                               SCEV Utilities
 //===----------------------------------------------------------------------===//


        


More information about the llvm-commits mailing list