Skip to content

[IR] Strip dead code post ConstExpr removals (NFC) #139524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

artagnon
Copy link
Contributor

Strip dead code in Operator.h related to the removal of several constant expressions. Note that PossiblyExactOperator can no longer be a ConstantExpr.

Strip dead code in Operator.h related to the removal of several constant
expressions. Note that PossiblyExactOperator can no longer be a
ConstantExpr.
@artagnon artagnon requested a review from nikic May 12, 2025 10:05
@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@llvm/pr-subscribers-llvm-ir

Author: Ramkumar Ramachandra (artagnon)

Changes

Strip dead code in Operator.h related to the removal of several constant expressions. Note that PossiblyExactOperator can no longer be a ConstantExpr.


Full diff: https://github.com/llvm/llvm-project/pull/139524.diff

1 Files Affected:

  • (modified) llvm/include/llvm/IR/Operator.h (+3-9)
diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h
index 4d77860be994e..38f84647ec74e 100644
--- a/llvm/include/llvm/IR/Operator.h
+++ b/llvm/include/llvm/IR/Operator.h
@@ -134,9 +134,7 @@ class OverflowingBinaryOperator : public Operator {
   }
   static bool classof(const ConstantExpr *CE) {
     return CE->getOpcode() == Instruction::Add ||
-           CE->getOpcode() == Instruction::Sub ||
-           CE->getOpcode() == Instruction::Mul ||
-           CE->getOpcode() == Instruction::Shl;
+           CE->getOpcode() == Instruction::Sub;
   }
   static bool classof(const Value *V) {
     return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
@@ -150,7 +148,7 @@ struct OperandTraits<OverflowingBinaryOperator>
 
 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(OverflowingBinaryOperator, Value)
 
-/// A udiv or sdiv instruction, which can be marked as "exact",
+/// A udiv, sdiv, lshr, or ashr instruction, which can be marked as "exact",
 /// indicating that no bits are destroyed.
 class PossiblyExactOperator : public Operator {
 public:
@@ -182,15 +180,11 @@ class PossiblyExactOperator : public Operator {
            OpC == Instruction::LShr;
   }
 
-  static bool classof(const ConstantExpr *CE) {
-    return isPossiblyExactOpcode(CE->getOpcode());
-  }
   static bool classof(const Instruction *I) {
     return isPossiblyExactOpcode(I->getOpcode());
   }
   static bool classof(const Value *V) {
-    return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
-           (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
+    return (isa<Instruction>(V) && classof(cast<Instruction>(V)));
   }
 };
 

@artagnon
Copy link
Contributor Author

Gentle ping.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, see also #72501.

@artagnon artagnon merged commit 2804643 into llvm:main May 22, 2025
13 checks passed
@artagnon artagnon deleted the ir-dead-code-constexpr branch May 22, 2025 16:35
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Strip dead code in Operator.h related to the removal of several constant
expressions. Note that PossiblyExactOperator can no longer be a
ConstantExpr.
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
Strip dead code in Operator.h related to the removal of several constant
expressions. Note that PossiblyExactOperator can no longer be a
ConstantExpr.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants