[llvm] [mlir] [mlir][polynomial] Remove polynomial dialect (PR #139766)

Jeremy Kun via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 10:12:20 PDT 2025


https://github.com/j2kun updated https://github.com/llvm/llvm-project/pull/139766

>From 0ee85e99f6aafd0924c6c539fbe564de9d1d426e Mon Sep 17 00:00:00 2001
From: Jeremy Kun <jkun at google.com>
Date: Tue, 13 May 2025 09:14:29 -0700
Subject: [PATCH 1/2] Remove polynomial dialect

---
 mlir/include/mlir/Dialect/CMakeLists.txt      |   1 -
 .../mlir/Dialect/Polynomial/CMakeLists.txt    |   1 -
 .../mlir/Dialect/Polynomial/IR/CMakeLists.txt |   7 -
 .../mlir/Dialect/Polynomial/IR/Polynomial.h   | 282 --------------
 .../mlir/Dialect/Polynomial/IR/Polynomial.td  | 350 ------------------
 .../Polynomial/IR/PolynomialAttributes.h      |  17 -
 .../Polynomial/IR/PolynomialAttributes.td     | 222 -----------
 .../Dialect/Polynomial/IR/PolynomialDialect.h |  19 -
 .../Polynomial/IR/PolynomialDialect.td        |  55 ---
 .../Dialect/Polynomial/IR/PolynomialOps.h     |  21 --
 .../Dialect/Polynomial/IR/PolynomialTypes.h   |  17 -
 .../Dialect/Polynomial/IR/PolynomialTypes.td  |  33 --
 mlir/include/mlir/InitAllDialects.h           |   6 +-
 mlir/lib/Dialect/CMakeLists.txt               |   1 -
 mlir/lib/Dialect/Polynomial/CMakeLists.txt    |   1 -
 mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt |  26 --
 mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp |  68 ----
 .../Polynomial/IR/PolynomialAttributes.cpp    | 236 ------------
 .../IR/PolynomialCanonicalization.td          |  44 ---
 .../Polynomial/IR/PolynomialDialect.cpp       |  49 ---
 .../Dialect/Polynomial/IR/PolynomialOps.cpp   | 298 ---------------
 mlir/test/Dialect/Polynomial/attributes.mlir  |  73 ----
 .../Dialect/Polynomial/canonicalization.mlir  |  47 ---
 mlir/test/Dialect/Polynomial/ops.mlir         | 112 ------
 mlir/test/Dialect/Polynomial/ops_errors.mlir  | 126 -------
 mlir/test/Dialect/Polynomial/types.mlir       |  65 ----
 mlir/test/IR/parser_dialect_loading.mlir      |  19 -
 mlir/test/lib/Dialect/Test/CMakeLists.txt     |   1 -
 mlir/test/lib/Dialect/Test/TestAttrDefs.td    |  17 -
 mlir/test/lib/Dialect/Test/TestAttributes.h   |  10 +-
 mlir/test/lib/Dialect/Test/TestOps.td         |  10 -
 mlir/unittests/Dialect/CMakeLists.txt         |   1 -
 .../Dialect/Polynomial/CMakeLists.txt         |   8 -
 .../Dialect/Polynomial/PolynomialMathTest.cpp |  44 ---
 .../llvm-project-overlay/mlir/BUILD.bazel     |  91 -----
 .../mlir/test/BUILD.bazel                     |   2 -
 36 files changed, 7 insertions(+), 2373 deletions(-)
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.td
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.td
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h
 delete mode 100644 mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.td
 delete mode 100644 mlir/lib/Dialect/Polynomial/CMakeLists.txt
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp
 delete mode 100644 mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp
 delete mode 100644 mlir/test/Dialect/Polynomial/attributes.mlir
 delete mode 100644 mlir/test/Dialect/Polynomial/canonicalization.mlir
 delete mode 100644 mlir/test/Dialect/Polynomial/ops.mlir
 delete mode 100644 mlir/test/Dialect/Polynomial/ops_errors.mlir
 delete mode 100644 mlir/test/Dialect/Polynomial/types.mlir
 delete mode 100644 mlir/test/IR/parser_dialect_loading.mlir
 delete mode 100644 mlir/unittests/Dialect/Polynomial/CMakeLists.txt
 delete mode 100644 mlir/unittests/Dialect/Polynomial/PolynomialMathTest.cpp

diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt
index 9d1a840d6644b..56dc97282fa4a 100644
--- a/mlir/include/mlir/Dialect/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/CMakeLists.txt
@@ -28,7 +28,6 @@ add_subdirectory(OpenACCMPCommon)
 add_subdirectory(OpenMP)
 add_subdirectory(PDL)
 add_subdirectory(PDLInterp)
-add_subdirectory(Polynomial)
 add_subdirectory(Ptr)
 add_subdirectory(Quant)
 add_subdirectory(SCF)
diff --git a/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt b/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt
deleted file mode 100644
index f33061b2d87cf..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(IR)
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt
deleted file mode 100644
index ecdea158ddefb..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_mlir_dialect(Polynomial polynomial)
-add_mlir_doc(Polynomial PolynomialDialect Dialects/ -gen-dialect-doc -dialect=polynomial)
-
-set(LLVM_TARGET_DEFINITIONS PolynomialAttributes.td)
-mlir_tablegen(PolynomialAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=polynomial)
-mlir_tablegen(PolynomialAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=polynomial)
-add_public_tablegen_target(MLIRPolynomialAttributesIncGen)
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
deleted file mode 100644
index 8d7f1436fdc60..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
+++ /dev/null
@@ -1,282 +0,0 @@
-//===- Polynomial.h - A data class for polynomials --------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
-#define MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
-
-#include "mlir/Support/LLVM.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace mlir {
-
-class MLIRContext;
-
-namespace polynomial {
-
-/// This restricts statically defined polynomials to have at most 64-bit
-/// coefficients. This may be relaxed in the future, but it seems unlikely one
-/// would want to specify 128-bit polynomials statically in the source code.
-constexpr unsigned apintBitWidth = 64;
-
-template <class Derived, typename CoefficientType>
-class MonomialBase {
-public:
-  MonomialBase(const CoefficientType &coeff, const APInt &expo)
-      : coefficient(coeff), exponent(expo) {}
-  virtual ~MonomialBase() = default;
-
-  const CoefficientType &getCoefficient() const { return coefficient; }
-  CoefficientType &getMutableCoefficient() { return coefficient; }
-  const APInt &getExponent() const { return exponent; }
-  void setCoefficient(const CoefficientType &coeff) { coefficient = coeff; }
-  void setExponent(const APInt &exp) { exponent = exp; }
-
-  bool operator==(const MonomialBase &other) const {
-    return other.coefficient == coefficient && other.exponent == exponent;
-  }
-  bool operator!=(const MonomialBase &other) const {
-    return other.coefficient != coefficient || other.exponent != exponent;
-  }
-
-  /// Monomials are ordered by exponent.
-  bool operator<(const MonomialBase &other) const {
-    return (exponent.ult(other.exponent));
-  }
-
-  Derived add(const Derived &other) {
-    assert(exponent == other.exponent);
-    CoefficientType newCoeff = coefficient + other.coefficient;
-    Derived result;
-    result.setCoefficient(newCoeff);
-    result.setExponent(exponent);
-    return result;
-  }
-
-  virtual bool isMonic() const = 0;
-  virtual void
-  coefficientToString(llvm::SmallString<16> &coeffString) const = 0;
-
-  template <class D, typename T>
-  friend ::llvm::hash_code hash_value(const MonomialBase<D, T> &arg);
-
-protected:
-  CoefficientType coefficient;
-  APInt exponent;
-};
-
-/// A class representing a monomial of a single-variable polynomial with integer
-/// coefficients.
-class IntMonomial : public MonomialBase<IntMonomial, APInt> {
-public:
-  IntMonomial(int64_t coeff, uint64_t expo)
-      : MonomialBase(APInt(apintBitWidth, coeff), APInt(apintBitWidth, expo)) {}
-
-  IntMonomial()
-      : MonomialBase(APInt(apintBitWidth, 0), APInt(apintBitWidth, 0)) {}
-
-  ~IntMonomial() override = default;
-
-  bool isMonic() const override { return coefficient == 1; }
-
-  void coefficientToString(llvm::SmallString<16> &coeffString) const override {
-    coefficient.toStringSigned(coeffString);
-  }
-};
-
-/// A class representing a monomial of a single-variable polynomial with integer
-/// coefficients.
-class FloatMonomial : public MonomialBase<FloatMonomial, APFloat> {
-public:
-  FloatMonomial(double coeff, uint64_t expo)
-      : MonomialBase(APFloat(coeff), APInt(apintBitWidth, expo)) {}
-
-  FloatMonomial() : MonomialBase(APFloat((double)0), APInt(apintBitWidth, 0)) {}
-
-  ~FloatMonomial() override = default;
-
-  bool isMonic() const override { return coefficient == APFloat(1.0); }
-
-  void coefficientToString(llvm::SmallString<16> &coeffString) const override {
-    coefficient.toString(coeffString);
-  }
-};
-
-template <class Derived, typename Monomial>
-class PolynomialBase {
-public:
-  PolynomialBase() = delete;
-
-  explicit PolynomialBase(ArrayRef<Monomial> terms) : terms(terms) {};
-
-  explicit operator bool() const { return !terms.empty(); }
-  bool operator==(const PolynomialBase &other) const {
-    return other.terms == terms;
-  }
-  bool operator!=(const PolynomialBase &other) const {
-    return !(other.terms == terms);
-  }
-
-  void print(raw_ostream &os, ::llvm::StringRef separator,
-             ::llvm::StringRef exponentiation) const {
-    bool first = true;
-    for (const Monomial &term : getTerms()) {
-      if (first) {
-        first = false;
-      } else {
-        os << separator;
-      }
-      std::string coeffToPrint;
-      if (term.isMonic() && term.getExponent().uge(1)) {
-        coeffToPrint = "";
-      } else {
-        llvm::SmallString<16> coeffString;
-        term.coefficientToString(coeffString);
-        coeffToPrint = coeffString.str();
-      }
-
-      if (term.getExponent() == 0) {
-        os << coeffToPrint;
-      } else if (term.getExponent() == 1) {
-        os << coeffToPrint << "x";
-      } else {
-        llvm::SmallString<16> expString;
-        term.getExponent().toStringSigned(expString);
-        os << coeffToPrint << "x" << exponentiation << expString;
-      }
-    }
-  }
-
-  Derived add(const Derived &other) {
-    SmallVector<Monomial> newTerms;
-    auto it1 = terms.begin();
-    auto it2 = other.terms.begin();
-    while (it1 != terms.end() || it2 != other.terms.end()) {
-      if (it1 == terms.end()) {
-        newTerms.emplace_back(*it2);
-        it2++;
-        continue;
-      }
-
-      if (it2 == other.terms.end()) {
-        newTerms.emplace_back(*it1);
-        it1++;
-        continue;
-      }
-
-      while (it1->getExponent().ult(it2->getExponent())) {
-        newTerms.emplace_back(*it1);
-        it1++;
-        if (it1 == terms.end())
-          break;
-      }
-
-      while (it2->getExponent().ult(it1->getExponent())) {
-        newTerms.emplace_back(*it2);
-        it2++;
-        if (it2 == terms.end())
-          break;
-      }
-
-      newTerms.emplace_back(it1->add(*it2));
-      it1++;
-      it2++;
-    }
-    return Derived(newTerms);
-  }
-
-  // Prints polynomial to 'os'.
-  void print(raw_ostream &os) const { print(os, " + ", "**"); }
-
-  void dump() const;
-
-  // Prints polynomial so that it can be used as a valid identifier
-  std::string toIdentifier() const {
-    std::string result;
-    llvm::raw_string_ostream os(result);
-    print(os, "_", "");
-    return os.str();
-  }
-
-  unsigned getDegree() const {
-    return terms.back().getExponent().getZExtValue();
-  }
-
-  ArrayRef<Monomial> getTerms() const { return terms; }
-
-  template <class D, typename T>
-  friend ::llvm::hash_code hash_value(const PolynomialBase<D, T> &arg);
-
-private:
-  // The monomial terms for this polynomial.
-  SmallVector<Monomial> terms;
-};
-
-/// A single-variable polynomial with integer coefficients.
-///
-/// Eg: x^1024 + x + 1
-class IntPolynomial : public PolynomialBase<IntPolynomial, IntMonomial> {
-public:
-  explicit IntPolynomial(ArrayRef<IntMonomial> terms) : PolynomialBase(terms) {}
-
-  // Returns a Polynomial from a list of monomials.
-  // Fails if two monomials have the same exponent.
-  static FailureOr<IntPolynomial>
-  fromMonomials(ArrayRef<IntMonomial> monomials);
-
-  /// Returns a polynomial with coefficients given by `coeffs`. The value
-  /// coeffs[i] is converted to a monomial with exponent i.
-  static IntPolynomial fromCoefficients(ArrayRef<int64_t> coeffs);
-};
-
-/// A single-variable polynomial with double coefficients.
-///
-/// Eg: 1.0 x^1024 + 3.5 x + 1e-05
-class FloatPolynomial : public PolynomialBase<FloatPolynomial, FloatMonomial> {
-public:
-  explicit FloatPolynomial(ArrayRef<FloatMonomial> terms)
-      : PolynomialBase(terms) {}
-
-  // Returns a Polynomial from a list of monomials.
-  // Fails if two monomials have the same exponent.
-  static FailureOr<FloatPolynomial>
-  fromMonomials(ArrayRef<FloatMonomial> monomials);
-
-  /// Returns a polynomial with coefficients given by `coeffs`. The value
-  /// coeffs[i] is converted to a monomial with exponent i.
-  static FloatPolynomial fromCoefficients(ArrayRef<double> coeffs);
-};
-
-// Make Polynomials hashable.
-template <class D, typename T>
-inline ::llvm::hash_code hash_value(const PolynomialBase<D, T> &arg) {
-  return ::llvm::hash_combine_range(arg.terms);
-}
-
-template <class D, typename T>
-inline ::llvm::hash_code hash_value(const MonomialBase<D, T> &arg) {
-  return llvm::hash_combine(::llvm::hash_value(arg.coefficient),
-                            ::llvm::hash_value(arg.exponent));
-}
-
-template <class D, typename T>
-inline raw_ostream &operator<<(raw_ostream &os,
-                               const PolynomialBase<D, T> &polynomial) {
-  polynomial.print(os);
-  return os;
-}
-
-} // namespace polynomial
-} // namespace mlir
-
-#endif // MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td
deleted file mode 100644
index 755396c8b9023..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td
+++ /dev/null
@@ -1,350 +0,0 @@
-//===- Polynomial.td - Polynomial dialect ------------------*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_OPS
-#define POLYNOMIAL_OPS
-
-include "mlir/IR/BuiltinAttributes.td"
-include "mlir/IR/OpBase.td"
-include "mlir/Interfaces/InferTypeOpInterface.td"
-include "mlir/Interfaces/SideEffectInterfaces.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialDialect.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialTypes.td"
-
-class Polynomial_Op<string mnemonic, list<Trait> traits = []> :
-    Op<Polynomial_Dialect, mnemonic, traits # [Pure]> {
-  let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
-}
-
-class Polynomial_UnaryOp<string mnemonic, list<Trait> traits = []> :
-    Polynomial_Op<mnemonic, traits # [SameOperandsAndResultType]> {
-  let arguments = (ins Polynomial_PolynomialType:$operand);
-  let results = (outs Polynomial_PolynomialType:$result);
-}
-
-class Polynomial_BinaryOp<string mnemonic, list<Trait> traits = []> :
-    Polynomial_Op<mnemonic, !listconcat(traits, [Pure, SameOperandsAndResultType, ElementwiseMappable])> {
-  let arguments = (ins PolynomialLike:$lhs, PolynomialLike:$rhs);
-  let results = (outs PolynomialLike:$result);
-  let assemblyFormat = "operands attr-dict `:` type($result)";
-}
-
-def Polynomial_AddOp : Polynomial_BinaryOp<"add", [Commutative]> {
-  let summary = "Addition operation between polynomials.";
-  let description = [{
-    Performs polynomial addition on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Addition is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the addition is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // add two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.add %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-}
-
-def Polynomial_SubOp : Polynomial_BinaryOp<"sub"> {
-  let summary = "Subtraction operation between polynomials.";
-  let description = [{
-    Performs polynomial subtraction on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Subtraction is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the subtraction is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // subtract two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.sub %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-  let hasCanonicalizer = 1;
-}
-
-def Polynomial_MulOp : Polynomial_BinaryOp<"mul", [Commutative]> {
-  let summary = "Multiplication operation between polynomials.";
-  let description = [{
-    Performs polynomial multiplication on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Multiplication is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the multiplication is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // multiply two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.mul %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-}
-
-def Polynomial_MulScalarOp : Polynomial_Op<"mul_scalar", [
-      ElementwiseMappable, AllTypesMatch<["polynomial", "output"]>]> {
-  let summary = "Multiplication by a scalar of the field.";
-  let description = [{
-    Multiplies the polynomial operand's coefficients by a given scalar value.
-    The operation is defined to occur in the ring defined by the ring attribute
-    of the two operands, meaning the multiplication is taken modulo the
-    coefficientModulus of the ring.
-
-    The `scalar` input must have the same type as the polynomial ring's
-    coefficientType.
-
-    Example:
-
-    ```mlir
-    // multiply two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = arith.constant 3 : i32
-    %2 = polynomial.mul_scalar %0, %1 : !polynomial.polynomial<#ring>, i32
-    ```
-  }];
-
-  let arguments = (ins
-    PolynomialLike:$polynomial,
-    AnyInteger:$scalar
-  );
-  let results = (outs
-    PolynomialLike:$output
-  );
-  let assemblyFormat = "operands attr-dict `:` type($polynomial) `,` type($scalar)";
-  let hasVerifier = 1;
-}
-
-def Polynomial_LeadingTermOp: Polynomial_Op<"leading_term"> {
-  let summary = "Compute the leading term of the polynomial.";
-  let description = [{
-    The degree of a polynomial is the largest $k$ for which the coefficient
-    `a_k` of `x^k` is nonzero. The leading term is the term `a_k * x^k`, which
-    this op represents as a pair of results. The first is the degree `k` as an
-    index, and the second is the coefficient, whose type matches the
-    coefficient type of the polynomial's ring attribute.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1, %2 = polynomial.leading_term %0 : !polynomial.polynomial<#ring> -> (index, i32)
-    ```
-  }];
-  let arguments = (ins Polynomial_PolynomialType:$input);
-  let results = (outs Index:$degree, AnyInteger:$coefficient);
-  let assemblyFormat = "operands attr-dict `:` type($input) `->` `(` type($degree) `,` type($coefficient) `)`";
-}
-
-def Polynomial_MonomialOp: Polynomial_Op<"monomial"> {
-  let summary = "Create a polynomial that consists of a single monomial.";
-  let description = [{
-    Construct a polynomial that consists of a single monomial term, from its
-    degree and coefficient as dynamic inputs.
-
-    The coefficient type of the output polynomial's ring attribute must match
-    the `coefficient` input type.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %deg = arith.constant 1023 : index
-    %five = arith.constant 5 : i32
-    %0 = polynomial.monomial %five, %deg : (i32, index) -> !polynomial.polynomial<#ring>
-    ```
-  }];
-  let arguments = (ins AnyInteger:$coefficient, Index:$degree);
-  let results = (outs Polynomial_PolynomialType:$output);
-}
-
-def Polynomial_MonicMonomialMulOp: Polynomial_Op<"monic_monomial_mul", [AllTypesMatch<["input", "output"]>]> {
-  let summary = "Multiply a polynomial by a monic monomial.";
-  let description = [{
-    Multiply a polynomial by a monic monomial, meaning a polynomial of the form
-    `1 * x^k` for an index operand `k`.
-
-    In some special rings of polynomials, such as a ring of polynomials
-    modulo `x^n - 1`, `monomial_mul` can be interpreted as a cyclic shift of
-    the coefficients of the polynomial. For some rings, this results in
-    optimized lowerings that involve rotations and rescaling of the
-    coefficients of the input.
-  }];
-  let arguments = (ins PolynomialLike:$input, Index:$monomialDegree);
-  let results = (outs PolynomialLike:$output);
-}
-
-def Polynomial_FromTensorOp : Polynomial_Op<"from_tensor", [Pure]> {
-  let summary = "Creates a polynomial from integer coefficients stored in a tensor.";
-  let description = [{
-    `polynomial.from_tensor` creates a polynomial value from a tensor of coefficients.
-    The input tensor must list the coefficients in degree-increasing order.
-
-    The input one-dimensional tensor may have size at most the degree of the
-    ring's polynomialModulus generator polynomial, with smaller dimension implying that
-    all higher-degree terms have coefficient zero.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %two = arith.constant 2 : i32
-    %five = arith.constant 5 : i32
-    %coeffs = tensor.from_elements %two, %two, %five : tensor<3xi32>
-    %poly = polynomial.from_tensor %coeffs : tensor<3xi32> -> !polynomial.polynomial<#ring>
-    ```
-  }];
-  let arguments = (ins RankedTensorOf<[AnyInteger]>:$input);
-  let results = (outs Polynomial_PolynomialType:$output);
-
-  let assemblyFormat = "$input attr-dict `:` type($input) `->` type($output)";
-
-  let builders = [
-    // Builder that infers coefficient modulus from tensor bit width,
-    // and uses whatever input ring is provided by the caller.
-    OpBuilder<(ins "::mlir::Value":$input, "::mlir::polynomial::RingAttr":$ring)>
-  ];
-  let hasVerifier = 1;
-}
-
-def Polynomial_ToTensorOp : Polynomial_Op<"to_tensor", [Pure]> {
-  let summary = "Creates a tensor containing the coefficients of a polynomial.";
-  let description = [{
-    `polynomial.to_tensor` creates a dense tensor value containing the
-    coefficients of the input polynomial. The output tensor contains the
-    coefficients in degree-increasing order.
-
-    Operations that act on the coefficients of a polynomial, such as extracting
-    a specific coefficient or extracting a range of coefficients, should be
-    implemented by composing `to_tensor` with the relevant `tensor` dialect
-    ops.
-
-    The output tensor has shape equal to the degree of the polynomial ring
-    attribute's polynomialModulus, including zeroes.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %two = arith.constant 2 : i32
-    %five = arith.constant 5 : i32
-    %coeffs = tensor.from_elements %two, %two, %five : tensor<3xi32>
-    %poly = polynomial.from_tensor %coeffs : tensor<3xi32> -> !polynomial.polynomial<#ring>
-    %tensor = polynomial.to_tensor %poly : !polynomial.polynomial<#ring> -> tensor<1024xi32>
-    ```
-  }];
-  let arguments = (ins Polynomial_PolynomialType:$input);
-  let results = (outs RankedTensorOf<[AnyInteger]>:$output);
-  let assemblyFormat = "$input attr-dict `:` type($input) `->` type($output)";
-  let hasVerifier = 1;
-}
-
-def Polynomial_AnyTypedPolynomialAttr : AnyAttrOf<[
-  Polynomial_TypedFloatPolynomialAttr,
-  Polynomial_TypedIntPolynomialAttr
-]>;
-
-def Polynomial_ConstantOp : Op<Polynomial_Dialect, "constant",
-    [Pure, InferTypeOpAdaptor]> {
-  let summary = "Define a constant polynomial via an attribute.";
-  let description = [{
-    Example:
-
-    ```mlir
-    !int_poly_ty = !polynomial.polynomial<ring=<coefficientType=i32>>
-    %0 = polynomial.constant int<1 + x**2> : !int_poly_ty
-
-    !float_poly_ty = !polynomial.polynomial<ring=<coefficientType=f32>>
-    %1 = polynomial.constant float<0.5 + 1.3e06 x**2> : !float_poly_ty
-    ```
-  }];
-  let arguments = (ins Polynomial_AnyTypedPolynomialAttr:$value);
-  let results = (outs Polynomial_PolynomialType:$output);
-  let hasCustomAssemblyFormat = 1;
-}
-
-def Polynomial_NTTOp : Polynomial_Op<"ntt", [Pure]> {
-  let summary = "Computes point-value tensor representation of a polynomial.";
-  let description = [{
-    `polynomial.ntt` computes the forward integer Number Theoretic Transform
-    (NTT) on the input polynomial. It returns a tensor containing a point-value
-    representation of the input polynomial. The output tensor has shape equal
-    to the degree of the ring's `polynomialModulus`. The polynomial's RingAttr
-    is embedded as the encoding attribute of the output tensor.
-
-    Given an input polynomial `F(x)` over a ring whose `polynomialModulus` has
-    degree `n`, and a primitive `n`-th root of unity `omega_n`, the output is
-    the list of $n$ evaluations
-
-      `f[k] = F(omega[n]^k) ; k = {0, ..., n-1}`
-
-    The choice of primitive root may be optionally specified.
-  }];
-  let arguments = (ins
-    Polynomial_PolynomialType:$input,
-    OptionalAttr<Polynomial_PrimitiveRootAttr>:$root
-  );
-  let results = (outs RankedTensorOf<[AnyInteger]>:$output);
-  let assemblyFormat = "$input attr-dict `:` qualified(type($input)) `->` type($output)";
-  let hasCanonicalizer = 1;
-  let hasVerifier = 1;
-}
-
-def Polynomial_INTTOp : Polynomial_Op<"intt", [Pure]> {
-  let summary = "Computes the reverse integer Number Theoretic Transform (NTT).";
-  let description = [{
-    `polynomial.intt` computes the reverse integer Number Theoretic Transform
-    (INTT) on the input tensor. This is the inverse operation of the
-    `polynomial.ntt` operation.
-
-    The input tensor is interpreted as a point-value representation of the
-    output polynomial at powers of a primitive `n`-th root of unity (see
-    `polynomial.ntt`). The ring of the polynomial is taken from the required
-    encoding attribute of the tensor.
-
-    The choice of primitive root may be optionally specified.
-  }];
-  let arguments = (
-    ins RankedTensorOf<[AnyInteger]>:$input,
-    OptionalAttr<Polynomial_PrimitiveRootAttr>:$root
-  );
-  let results = (outs Polynomial_PolynomialType:$output);
-  let assemblyFormat = "$input attr-dict `:` qualified(type($input)) `->` type($output)";
-  let hasCanonicalizer = 1;
-  let hasVerifier = 1;
-}
-
-#endif // POLYNOMIAL_OPS
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h
deleted file mode 100644
index b37d17bb89fb2..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//===- PolynomialAttributes.h - polynomial dialect attributes ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALATTRIBUTES_H_
-#define MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALATTRIBUTES_H_
-
-#include "Polynomial.h"
-#include "PolynomialDialect.h"
-
-#define GET_ATTRDEF_CLASSES
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h.inc"
-
-#endif // MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALATTRIBUTES_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.td b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.td
deleted file mode 100644
index 7d59add3d37c2..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.td
+++ /dev/null
@@ -1,222 +0,0 @@
-//===- PolynomialOps.td - Polynomial dialect ---------------*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_ATTRIBUTES
-#define POLYNOMIAL_ATTRIBUTES
-
-include "mlir/IR/BuiltinAttributes.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialDialect.td"
-
-class Polynomial_Attr<string name, string attrMnemonic, list<Trait> traits = []>
-    : AttrDef<Polynomial_Dialect, name, traits> {
-  let mnemonic = attrMnemonic;
-}
-
-def Polynomial_IntPolynomialAttr : Polynomial_Attr<"IntPolynomial", "int_polynomial"> {
-  let summary = "an attribute containing a single-variable polynomial with integer coefficients";
-  let description = [{
-    A polynomial attribute represents a single-variable polynomial with integer
-    coefficients, which is used to define the modulus of a `RingAttr`, as well
-    as to define constants and perform constant folding for `polynomial` ops.
-
-    The polynomial must be expressed as a list of monomial terms, with addition
-    or subtraction between them. The choice of variable name is arbitrary, but
-    must be consistent across all the monomials used to define a single
-    attribute. The order of monomial terms is arbitrary, each monomial degree
-    must occur at most once.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 + 1>
-    ```
-  }];
-  let parameters = (ins "::mlir::polynomial::IntPolynomial":$polynomial);
-  let hasCustomAssemblyFormat = 1;
-}
-
-def Polynomial_FloatPolynomialAttr : Polynomial_Attr<"FloatPolynomial", "float_polynomial"> {
-  let summary = "an attribute containing a single-variable polynomial with double precision floating point coefficients";
-  let description = [{
-    A polynomial attribute represents a single-variable polynomial with double
-    precision floating point coefficients.
-
-    The polynomial must be expressed as a list of monomial terms, with addition
-    or subtraction between them. The choice of variable name is arbitrary, but
-    must be consistent across all the monomials used to define a single
-    attribute. The order of monomial terms is arbitrary, each monomial degree
-    must occur at most once.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.float_polynomial<0.5 x**7 + 1.5>
-    ```
-  }];
-  let parameters = (ins "FloatPolynomial":$polynomial);
-  let hasCustomAssemblyFormat = 1;
-}
-
-def Polynomial_TypedIntPolynomialAttr : Polynomial_Attr<
-    "TypedIntPolynomial", "typed_int_polynomial", [TypedAttrInterface]> {
-  let summary = "a typed int_polynomial";
-  let description = [{
-    Example:
-
-    ```mlir
-    !poly_ty = !polynomial.polynomial<ring=<coefficientType=i32>>
-    #poly = int<1 x**7 + 4> : !poly_ty
-    #poly_verbose = #polynomial.typed_int_polynomial<1 x**7 + 4> : !poly_ty
-    ```
-  }];
-  let parameters = (ins "::mlir::Type":$type, "::mlir::polynomial::IntPolynomialAttr":$value);
-  let assemblyFormat = "$value `:` $type";
-  let builders = [
-    AttrBuilderWithInferredContext<(ins "Type":$type,
-                                        "const IntPolynomial &":$value), [{
-      return $_get(
-        type.getContext(),
-        type,
-        IntPolynomialAttr::get(type.getContext(), value));
-    }]>,
-    AttrBuilderWithInferredContext<(ins "Type":$type,
-                                        "const Attribute &":$value), [{
-      return $_get(type.getContext(), type, ::llvm::cast<IntPolynomialAttr>(value));
-    }]>
-  ];
-  let extraClassDeclaration = [{
-    using ValueType = ::mlir::Attribute;
-  }];
-}
-
-def Polynomial_TypedFloatPolynomialAttr : Polynomial_Attr<
-    "TypedFloatPolynomial", "typed_float_polynomial", [TypedAttrInterface]> {
-  let summary = "a typed float_polynomial";
-  let description = [{
-    Example:
-
-    ```mlir
-    !poly_ty = !polynomial.polynomial<ring=<coefficientType=f32>>
-    #poly = float<1.4 x**7 + 4.5> : !poly_ty
-    #poly_verbose = #polynomial.typed_float_polynomial<1.4 x**7 + 4.5> : !poly_ty
-    ```
-  }];
-  let parameters = (ins "::mlir::Type":$type, "::mlir::polynomial::FloatPolynomialAttr":$value);
-  let assemblyFormat = "$value `:` $type";
-  let builders = [
-    AttrBuilderWithInferredContext<(ins "Type":$type,
-                                        "const FloatPolynomial &":$value), [{
-      return $_get(
-        type.getContext(),
-        type,
-        FloatPolynomialAttr::get(type.getContext(), value));
-    }]>,
-    AttrBuilderWithInferredContext<(ins "Type":$type,
-                                        "const Attribute &":$value), [{
-      return $_get(type.getContext(), type, ::llvm::cast<FloatPolynomialAttr>(value));
-    }]>
-  ];
-  let extraClassDeclaration = [{
-    using ValueType = ::mlir::Attribute;
-  }];
-}
-
-def Polynomial_RingAttr : Polynomial_Attr<"Ring", "ring"> {
-  let summary = "an attribute specifying a polynomial ring";
-  let description = [{
-    A ring describes the domain in which polynomial arithmetic occurs. The ring
-    attribute in `polynomial` represents the more specific case of polynomials
-    with a single indeterminate; whose coefficients can be represented by
-    another MLIR type (`coefficientType`); and, if the coefficient type is
-    integral, whose coefficients are taken modulo some statically known modulus
-    (`coefficientModulus`).
-
-    Additionally, a polynomial ring can specify a _polynomialModulus_, which converts
-    polynomial arithmetic to the analogue of modular integer arithmetic, where
-    each polynomial is represented as its remainder when dividing by the
-    modulus. For single-variable polynomials, an "polynomialModulus" is always specificed
-    via a single polynomial, which we call `polynomialModulus`.
-
-    An expressive example is polynomials with i32 coefficients, whose
-    coefficients are taken modulo `2**32 - 5`, with a polynomial modulus of
-    `x**1024 - 1`.
-
-    ```mlir
-    #poly_mod = #polynomial.int_polynomial<-1 + x**1024>
-    #ring = #polynomial.ring<coefficientType=i32,
-                             coefficientModulus=4294967291:i32,
-                             polynomialModulus=#poly_mod>
-
-    %0 = ... : polynomial.polynomial<#ring>
-    ```
-
-    In this case, the value of a polynomial is always "converted" to a
-    canonical form by applying repeated reductions by setting `x**1024 = 1`
-    and simplifying.
-
-    The coefficient and polynomial modulus parameters are optional, and the
-    coefficient modulus is only allowed if the coefficient type is integral.
-
-    The coefficient modulus, if specified, should be positive and not larger
-    than `2 ** width(coefficientType)`.
-
-    If the coefficient modulus is not specified, the handling of coefficients
-    overflows is determined by subsequent lowering passes, which may choose to
-    wrap around or widen the overflow at their discretion.
-
-    Note that coefficient modulus is contained in `i64` by default, which is signed.
-    To specify a 64 bit number without intepreting it as a negative number, its container
-    type should be manually specified like `coefficientModulus=18446744073709551615:i128`.
-  }];
-
-  let parameters = (ins
-    "Type": $coefficientType,
-    OptionalParameter<"::mlir::IntegerAttr">: $coefficientModulus,
-    OptionalParameter<"::mlir::polynomial::IntPolynomialAttr">: $polynomialModulus
-  );
-  let genVerifyDecl = 1;
-  let assemblyFormat = "`<` struct(params) `>`";
-  let builders = [
-    AttrBuilderWithInferredContext<
-        (ins "::mlir::Type":$coefficientTy,
-              CArg<"::mlir::IntegerAttr", "nullptr"> :$coefficientModulusAttr,
-              CArg<"::mlir::polynomial::IntPolynomialAttr", "nullptr"> :$polynomialModulusAttr), [{
-      return $_get(
-        coefficientTy.getContext(),
-        coefficientTy,
-        coefficientModulusAttr,
-        polynomialModulusAttr);
-    }]>,
-  ];
-}
-
-def Polynomial_PrimitiveRootAttr: Polynomial_Attr<"PrimitiveRoot", "primitive_root"> {
-  let summary = "an attribute containing an integer and its degree as a root of unity";
-  let description = [{
-    A primitive root attribute stores an integer root `value` and an integer
-    `degree`, corresponding to a primitive root of unity of the given degree in
-    an unspecified ring.
-
-    This is used as an attribute on `polynomial.ntt` and `polynomial.intt` ops
-    to specify the root of unity used in lowering the transform.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.primitive_root<value=123 : i32, degree : 7 index>
-    ```
-  }];
-  let parameters = (ins
-    "::mlir::IntegerAttr":$value,
-    "::mlir::IntegerAttr":$degree
-  );
-  let assemblyFormat = "`<` struct(params) `>`";
-}
-
-
-#endif // POLYNOMIAL_ATTRIBUTES
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h
deleted file mode 100644
index 7b7acebe7a93b..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//===- PolynomialDialect.h - The Polynomial dialect -------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALDIALECT_H_
-#define MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALDIALECT_H_
-
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/DialectImplementation.h"
-
-// Generated headers (block clang-format from messing up order)
-#include "mlir/Dialect/Polynomial/IR/PolynomialDialect.h.inc"
-
-#endif // MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALDIALECT_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.td b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.td
deleted file mode 100644
index b0573b3715f78..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.td
+++ /dev/null
@@ -1,55 +0,0 @@
-//===- PolynomialDialect.td - Polynomial dialect base ------*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_DIALECT
-#define POLYNOMIAL_DIALECT
-
-include "mlir/IR/OpBase.td"
-
-def Polynomial_Dialect : Dialect {
-  let name = "polynomial";
-  let cppNamespace = "::mlir::polynomial";
-  let description = [{
-    The Polynomial dialect defines single-variable polynomial types and
-    operations.
-
-    The simplest use of `polynomial` is to represent mathematical operations in
-    a polynomial ring `R[x]`, where `R` is another MLIR type like `i32`.
-
-    More generally, this dialect supports representing polynomial operations in a
-    quotient ring `R[X]/(f(x))` for some statically fixed polynomial `f(x)`.
-    Two polyomials `p(x), q(x)` are considered equal in this ring if they have the
-    same remainder when dividing by `f(x)`. When a modulus is given, ring operations
-    are performed with reductions modulo `f(x)` and relative to the coefficient ring
-    `R`.
-
-    Examples:
-
-    ```mlir
-    // A constant polynomial in a ring with i32 coefficients and no polynomial modulus
-    #ring = #polynomial.ring<coefficientType=i32>
-    %a = polynomial.constant <1 + x**2 - 3x**3> : polynomial.polynomial<#ring>
-
-    // A constant polynomial in a ring with i32 coefficients, modulo (x^1024 + 1)
-    #modulus = #polynomial.int_polynomial<1 + x**1024>
-    #ring = #polynomial.ring<coefficientType=i32, polynomialModulus=#modulus>
-    %a = polynomial.constant <1 + x**2 - 3x**3> : polynomial.polynomial<#ring>
-
-    // A constant polynomial in a ring with i32 coefficients, with a polynomial
-    // modulus of (x^1024 + 1) and a coefficient modulus of 17.
-    #modulus = #polynomial.int_polynomial<1 + x**1024>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=17:i32, polynomialModulus=#modulus>
-    %a = polynomial.constant <1 + x**2 - 3x**3> : polynomial.polynomial<#ring>
-    ```
-  }];
-
-  let useDefaultTypePrinterParser = 1;
-  let useDefaultAttributePrinterParser = 1;
-}
-
-#endif // POLYNOMIAL_OPS
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h
deleted file mode 100644
index bacaad81ce8e5..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===- PolynomialOps.h - Ops for the Polynomial dialect ---------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALOPS_H_
-#define MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALOPS_H_
-
-#include "PolynomialDialect.h"
-#include "PolynomialTypes.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Interfaces/InferTypeOpInterface.h"
-
-#define GET_OP_CLASSES
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h.inc"
-
-#endif // MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALOPS_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h
deleted file mode 100644
index 2fc6877452547..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//===- PolynomialTypes.h - Types for the Polynomial dialect -----*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALTYPES_H_
-#define MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALTYPES_H_
-
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialDialect.h"
-
-#define GET_TYPEDEF_CLASSES
-#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.h.inc"
-
-#endif // MLIR_INCLUDE_MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIALTYPES_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.td b/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.td
deleted file mode 100644
index cf33503764abb..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.td
+++ /dev/null
@@ -1,33 +0,0 @@
-//===- PolynomialTypes.td - Polynomial types ---------------*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_TYPES
-#define POLYNOMIAL_TYPES
-
-include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialDialect.td"
-
-class Polynomial_Type<string name, string typeMnemonic>
-    : TypeDef<Polynomial_Dialect, name> {
-  let mnemonic = typeMnemonic;
-}
-
-def Polynomial_PolynomialType : Polynomial_Type<"Polynomial", "polynomial"> {
-  let summary = "An element of a polynomial ring.";
-  let description = [{
-    A type for polynomials in a polynomial quotient ring.
-  }];
-  let parameters = (ins Polynomial_RingAttr:$ring);
-  let assemblyFormat = "`<` struct(params) `>`";
-}
-
-def PolynomialLike : TypeOrValueSemanticsContainer<
-    Polynomial_PolynomialType, "polynomial-like">;
-
-
-#endif // POLYNOMIAL_TYPES
diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h
index e83be7b40eded..e751bf7109c99 100644
--- a/mlir/include/mlir/InitAllDialects.h
+++ b/mlir/include/mlir/InitAllDialects.h
@@ -65,7 +65,6 @@
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/Dialect/PDL/IR/PDL.h"
 #include "mlir/Dialect/PDLInterp/IR/PDLInterp.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialDialect.h"
 #include "mlir/Dialect/Ptr/IR/PtrDialect.h"
 #include "mlir/Dialect/Quant/IR/Quant.h"
 #include "mlir/Dialect/SCF/IR/SCF.h"
@@ -138,7 +137,6 @@ inline void registerAllDialects(DialectRegistry &registry) {
                   omp::OpenMPDialect,
                   pdl::PDLDialect,
                   pdl_interp::PDLInterpDialect,
-                  polynomial::PolynomialDialect,
                   ptr::PtrDialect,
                   quant::QuantDialect,
                   ROCDL::ROCDLDialect,
@@ -207,6 +205,6 @@ inline void registerAllDialects(MLIRContext &context) {
   context.appendDialectRegistry(registry);
 }
 
-} // namespace mlir
+}  // namespace mlir
 
-#endif // MLIR_INITALLDIALECTS_H_
+#endif  // MLIR_INITALLDIALECTS_H_
diff --git a/mlir/lib/Dialect/CMakeLists.txt b/mlir/lib/Dialect/CMakeLists.txt
index a473f2ff317c9..3cc52ebc0a8d9 100644
--- a/mlir/lib/Dialect/CMakeLists.txt
+++ b/mlir/lib/Dialect/CMakeLists.txt
@@ -28,7 +28,6 @@ add_subdirectory(OpenACCMPCommon)
 add_subdirectory(OpenMP)
 add_subdirectory(PDL)
 add_subdirectory(PDLInterp)
-add_subdirectory(Polynomial)
 add_subdirectory(Ptr)
 add_subdirectory(Quant)
 add_subdirectory(SCF)
diff --git a/mlir/lib/Dialect/Polynomial/CMakeLists.txt b/mlir/lib/Dialect/Polynomial/CMakeLists.txt
deleted file mode 100644
index f33061b2d87cf..0000000000000
--- a/mlir/lib/Dialect/Polynomial/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(IR)
diff --git a/mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt b/mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt
deleted file mode 100644
index 975315ff49158..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-set(LLVM_TARGET_DEFINITIONS PolynomialCanonicalization.td)
-mlir_tablegen(PolynomialCanonicalization.inc -gen-rewriters)
-add_public_tablegen_target(MLIRPolynomialCanonicalizationIncGen)
-
-add_mlir_dialect_library(MLIRPolynomialDialect
-  Polynomial.cpp
-  PolynomialAttributes.cpp
-  PolynomialDialect.cpp
-  PolynomialOps.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Polynomial
-
-  DEPENDS
-  MLIRPolynomialIncGen
-  MLIRPolynomialAttributesIncGen
-  MLIRPolynomialCanonicalizationIncGen
-  MLIRBuiltinAttributesIncGen
-
-  LINK_LIBS PUBLIC
-  MLIRArithDialect
-  MLIRSupport
-  MLIRDialect
-  MLIRIR
-  MLIRInferTypeOpInterface
-  )
diff --git a/mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp b/mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp
deleted file mode 100644
index 650a369a2abab..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//===- Polynomial.cpp - MLIR storage type for static Polynomial -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
-
-#include "llvm/ADT/SmallVector.h"
-
-namespace mlir {
-namespace polynomial {
-
-template <typename PolyT, typename MonomialT>
-FailureOr<PolyT> fromMonomialsImpl(ArrayRef<MonomialT> monomials) {
-  // A polynomial's terms are canonically stored in order of increasing degree.
-  auto monomialsCopy = llvm::SmallVector<MonomialT>(monomials);
-  std::sort(monomialsCopy.begin(), monomialsCopy.end());
-
-  // Ensure non-unique exponents are not present. Since we sorted the list by
-  // exponent, a linear scan of adjancent monomials suffices.
-  if (std::adjacent_find(monomialsCopy.begin(), monomialsCopy.end(),
-                         [](const MonomialT &lhs, const MonomialT &rhs) {
-                           return lhs.getExponent() == rhs.getExponent();
-                         }) != monomialsCopy.end()) {
-    return failure();
-  }
-
-  return PolyT(monomialsCopy);
-}
-
-FailureOr<IntPolynomial>
-IntPolynomial::fromMonomials(ArrayRef<IntMonomial> monomials) {
-  return fromMonomialsImpl<IntPolynomial, IntMonomial>(monomials);
-}
-
-FailureOr<FloatPolynomial>
-FloatPolynomial::fromMonomials(ArrayRef<FloatMonomial> monomials) {
-  return fromMonomialsImpl<FloatPolynomial, FloatMonomial>(monomials);
-}
-
-template <typename PolyT, typename MonomialT, typename CoeffT>
-PolyT fromCoefficientsImpl(ArrayRef<CoeffT> coeffs) {
-  llvm::SmallVector<MonomialT> monomials;
-  auto size = coeffs.size();
-  monomials.reserve(size);
-  for (size_t i = 0; i < size; i++) {
-    monomials.emplace_back(coeffs[i], i);
-  }
-  auto result = PolyT::fromMonomials(monomials);
-  // Construction guarantees unique exponents, so the failure mode of
-  // fromMonomials can be bypassed.
-  assert(succeeded(result));
-  return result.value();
-}
-
-IntPolynomial IntPolynomial::fromCoefficients(ArrayRef<int64_t> coeffs) {
-  return fromCoefficientsImpl<IntPolynomial, IntMonomial, int64_t>(coeffs);
-}
-
-FloatPolynomial FloatPolynomial::fromCoefficients(ArrayRef<double> coeffs) {
-  return fromCoefficientsImpl<FloatPolynomial, FloatMonomial, double>(coeffs);
-}
-
-} // namespace polynomial
-} // namespace mlir
diff --git a/mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp b/mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp
deleted file mode 100644
index cd7789a2e9531..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-//===- PolynomialAttributes.cpp - Polynomial dialect attrs ------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
-
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
-#include "mlir/Support/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSet.h"
-
-namespace mlir {
-namespace polynomial {
-
-void IntPolynomialAttr::print(AsmPrinter &p) const {
-  p << '<' << getPolynomial() << '>';
-}
-
-void FloatPolynomialAttr::print(AsmPrinter &p) const {
-  p << '<' << getPolynomial() << '>';
-}
-
-/// A callable that parses the coefficient using the appropriate method for the
-/// given monomial type, and stores the parsed coefficient value on the
-/// monomial.
-template <typename MonomialType>
-using ParseCoefficientFn = std::function<OptionalParseResult(MonomialType &)>;
-
-/// Try to parse a monomial. If successful, populate the fields of the outparam
-/// `monomial` with the results, and the `variable` outparam with the parsed
-/// variable name. Sets shouldParseMore to true if the monomial is followed by
-/// a '+'.
-///
-template <typename Monomial>
-ParseResult
-parseMonomial(AsmParser &parser, Monomial &monomial, llvm::StringRef &variable,
-              bool &isConstantTerm, bool &shouldParseMore,
-              ParseCoefficientFn<Monomial> parseAndStoreCoefficient) {
-  OptionalParseResult parsedCoeffResult = parseAndStoreCoefficient(monomial);
-
-  isConstantTerm = false;
-  shouldParseMore = false;
-
-  // A + indicates it's a constant term with more to go, as in `1 + x`.
-  if (succeeded(parser.parseOptionalPlus())) {
-    // If no coefficient was parsed, and there's a +, then it's effectively
-    // parsing an empty string.
-    if (!parsedCoeffResult.has_value()) {
-      return failure();
-    }
-    monomial.setExponent(APInt(apintBitWidth, 0));
-    isConstantTerm = true;
-    shouldParseMore = true;
-    return success();
-  }
-
-  // A monomial can be a trailing constant term, as in `x + 1`.
-  if (failed(parser.parseOptionalKeyword(&variable))) {
-    // If neither a coefficient nor a variable was found, then it's effectively
-    // parsing an empty string.
-    if (!parsedCoeffResult.has_value()) {
-      return failure();
-    }
-
-    monomial.setExponent(APInt(apintBitWidth, 0));
-    isConstantTerm = true;
-    return success();
-  }
-
-  // Parse exponentiation symbol as `**`. We can't use caret because it's
-  // reserved for basic block identifiers If no star is present, it's treated
-  // as a polynomial with exponent 1.
-  if (succeeded(parser.parseOptionalStar())) {
-    // If there's one * there must be two.
-    if (failed(parser.parseStar())) {
-      return failure();
-    }
-
-    // If there's a **, then the integer exponent is required.
-    APInt parsedExponent(apintBitWidth, 0);
-    if (failed(parser.parseInteger(parsedExponent))) {
-      parser.emitError(parser.getCurrentLocation(),
-                       "found invalid integer exponent");
-      return failure();
-    }
-
-    monomial.setExponent(parsedExponent);
-  } else {
-    monomial.setExponent(APInt(apintBitWidth, 1));
-  }
-
-  if (succeeded(parser.parseOptionalPlus())) {
-    shouldParseMore = true;
-  }
-  return success();
-}
-
-template <typename Monomial>
-LogicalResult
-parsePolynomialAttr(AsmParser &parser, llvm::SmallVector<Monomial> &monomials,
-                    llvm::StringSet<> &variables,
-                    ParseCoefficientFn<Monomial> parseAndStoreCoefficient) {
-  while (true) {
-    Monomial parsedMonomial;
-    llvm::StringRef parsedVariableRef;
-    bool isConstantTerm;
-    bool shouldParseMore;
-    if (failed(parseMonomial<Monomial>(
-            parser, parsedMonomial, parsedVariableRef, isConstantTerm,
-            shouldParseMore, parseAndStoreCoefficient))) {
-      parser.emitError(parser.getCurrentLocation(), "expected a monomial");
-      return failure();
-    }
-
-    if (!isConstantTerm) {
-      std::string parsedVariable = parsedVariableRef.str();
-      variables.insert(parsedVariable);
-    }
-    monomials.push_back(parsedMonomial);
-
-    if (shouldParseMore)
-      continue;
-
-    if (succeeded(parser.parseOptionalGreater())) {
-      break;
-    }
-    parser.emitError(
-        parser.getCurrentLocation(),
-        "expected + and more monomials, or > to end polynomial attribute");
-    return failure();
-  }
-
-  if (variables.size() > 1) {
-    std::string vars = llvm::join(variables.keys(), ", ");
-    parser.emitError(
-        parser.getCurrentLocation(),
-        "polynomials must have one indeterminate, but there were multiple: " +
-            vars);
-    return failure();
-  }
-
-  return success();
-}
-
-Attribute IntPolynomialAttr::parse(AsmParser &parser, Type type) {
-  if (failed(parser.parseLess()))
-    return {};
-
-  llvm::SmallVector<IntMonomial> monomials;
-  llvm::StringSet<> variables;
-
-  if (failed(parsePolynomialAttr<IntMonomial>(
-          parser, monomials, variables,
-          [&](IntMonomial &monomial) -> OptionalParseResult {
-            APInt parsedCoeff(apintBitWidth, 1);
-            OptionalParseResult result =
-                parser.parseOptionalInteger(parsedCoeff);
-            monomial.setCoefficient(parsedCoeff);
-            return result;
-          }))) {
-    return {};
-  }
-
-  auto result = IntPolynomial::fromMonomials(monomials);
-  if (failed(result)) {
-    parser.emitError(parser.getCurrentLocation())
-        << "parsed polynomial must have unique exponents among monomials";
-    return {};
-  }
-  return IntPolynomialAttr::get(parser.getContext(), result.value());
-}
-Attribute FloatPolynomialAttr::parse(AsmParser &parser, Type type) {
-  if (failed(parser.parseLess()))
-    return {};
-
-  llvm::SmallVector<FloatMonomial> monomials;
-  llvm::StringSet<> variables;
-
-  ParseCoefficientFn<FloatMonomial> parseAndStoreCoefficient =
-      [&](FloatMonomial &monomial) -> OptionalParseResult {
-    double coeffValue = 1.0;
-    ParseResult result = parser.parseFloat(coeffValue);
-    monomial.setCoefficient(APFloat(coeffValue));
-    return OptionalParseResult(result);
-  };
-
-  if (failed(parsePolynomialAttr<FloatMonomial>(parser, monomials, variables,
-                                                parseAndStoreCoefficient))) {
-    return {};
-  }
-
-  auto result = FloatPolynomial::fromMonomials(monomials);
-  if (failed(result)) {
-    parser.emitError(parser.getCurrentLocation())
-        << "parsed polynomial must have unique exponents among monomials";
-    return {};
-  }
-  return FloatPolynomialAttr::get(parser.getContext(), result.value());
-}
-
-LogicalResult
-RingAttr::verify(function_ref<mlir::InFlightDiagnostic()> emitError,
-                 Type coefficientType, IntegerAttr coefficientModulus,
-                 IntPolynomialAttr polynomialModulus) {
-  if (coefficientModulus) {
-    auto coeffIntType = llvm::dyn_cast<IntegerType>(coefficientType);
-    if (!coeffIntType) {
-      return emitError() << "coefficientModulus specified but coefficientType "
-                            "is not integral";
-    }
-    APInt coeffModValue = coefficientModulus.getValue();
-    if (coeffModValue == 0) {
-      return emitError() << "coefficientModulus should not be 0";
-    }
-    if (coeffModValue.slt(0)) {
-      return emitError() << "coefficientModulus should be positive";
-    }
-    auto coeffModWidth = (coeffModValue - 1).getActiveBits();
-    auto coeffWidth = coeffIntType.getWidth();
-    if (coeffModWidth > coeffWidth) {
-      return emitError() << "coefficientModulus needs bit width of "
-                         << coeffModWidth
-                         << " but coefficientType can only contain "
-                         << coeffWidth << " bits";
-    }
-  }
-  return success();
-}
-
-} // namespace polynomial
-} // namespace mlir
diff --git a/mlir/lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td b/mlir/lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td
deleted file mode 100644
index 28c45e6846380..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td
+++ /dev/null
@@ -1,44 +0,0 @@
-//===- PolynomialCanonicalization.td - Polynomial patterns -*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_CANONICALIZATION
-#define POLYNOMIAL_CANONICALIZATION
-
-include "mlir/Dialect/Arith/IR/ArithOps.td"
-include "mlir/Dialect/Polynomial/IR/Polynomial.td"
-include "mlir/IR/OpBase.td"
-include "mlir/IR/PatternBase.td"
-
-def Equal : Constraint<CPred<"$0 == $1">>;
-
-// Get a -1 integer attribute of the same type as the polynomial SSA value's
-// ring coefficient type.
-def getMinusOne
-  : NativeCodeCall<
-      "$_builder.getIntegerAttr("
-        "cast<PolynomialType>($0.getType()).getRing().getCoefficientType(), -1)">;
-
-def SubAsAdd : Pat<
-  (Polynomial_SubOp $f, $g),
-  (Polynomial_AddOp $f,
-    (Polynomial_MulScalarOp $g,
-      (Arith_ConstantOp (getMinusOne $g))))>;
-
-def INTTAfterNTT : Pat<
-  (Polynomial_INTTOp (Polynomial_NTTOp $poly, $r1), $r2),
-  (replaceWithValue $poly),
-  [(Equal $r1, $r2)]
->;
-
-def NTTAfterINTT : Pat<
-  (Polynomial_NTTOp (Polynomial_INTTOp $tensor, $r1), $r2),
-  (replaceWithValue $tensor),
-  [(Equal $r1, $r2)]
->;
-
-#endif  // POLYNOMIAL_CANONICALIZATION
diff --git a/mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp b/mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp
deleted file mode 100644
index 7f8ba0670d65e..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//===- PolynomialDialect.cpp - Polynomial dialect ---------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
-
-#include "mlir/Dialect/Arith/IR/Arith.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialOps.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "mlir/Interfaces/InferTypeOpInterface.h"
-#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/TypeSwitch.h"
-
-using namespace mlir;
-using namespace mlir::polynomial;
-
-#include "mlir/Dialect/Polynomial/IR/PolynomialDialect.cpp.inc"
-
-#define GET_ATTRDEF_CLASSES
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.cpp.inc"
-#define GET_TYPEDEF_CLASSES
-#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.cpp.inc"
-#define GET_OP_CLASSES
-#include "mlir/Dialect/Polynomial/IR/Polynomial.cpp.inc"
-
-void PolynomialDialect::initialize() {
-  addAttributes<
-#define GET_ATTRDEF_LIST
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.cpp.inc"
-      >();
-  addTypes<
-#define GET_TYPEDEF_LIST
-#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.cpp.inc"
-      >();
-  addOperations<
-#define GET_OP_LIST
-#include "mlir/Dialect/Polynomial/IR/Polynomial.cpp.inc"
-      >();
-}
diff --git a/mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp b/mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp
deleted file mode 100644
index 460ef17167e80..0000000000000
--- a/mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-//===- PolynomialOps.cpp - Polynomial dialect ops ---------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Polynomial/IR/PolynomialOps.h"
-#include "mlir/Dialect/Arith/IR/Arith.h"
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/PatternMatch.h"
-#include "llvm/ADT/APInt.h"
-
-using namespace mlir;
-using namespace mlir::polynomial;
-
-void FromTensorOp::build(OpBuilder &builder, OperationState &result,
-                         Value input, RingAttr ring) {
-  TensorType tensorType = dyn_cast<TensorType>(input.getType());
-  auto bitWidth = tensorType.getElementTypeBitWidth();
-  APInt cmod(1 + bitWidth, 1);
-  cmod = cmod << bitWidth;
-  Type resultType = PolynomialType::get(builder.getContext(), ring);
-  build(builder, result, resultType, input);
-}
-
-LogicalResult FromTensorOp::verify() {
-  ArrayRef<int64_t> tensorShape = getInput().getType().getShape();
-  RingAttr ring = getOutput().getType().getRing();
-  IntPolynomialAttr polyMod = ring.getPolynomialModulus();
-  if (polyMod) {
-    unsigned polyDegree = polyMod.getPolynomial().getDegree();
-    bool compatible = tensorShape.size() == 1 && tensorShape[0] <= polyDegree;
-    if (!compatible) {
-      InFlightDiagnostic diag = emitOpError()
-                                << "input type " << getInput().getType()
-                                << " does not match output type "
-                                << getOutput().getType();
-      diag.attachNote()
-          << "the input type must be a tensor of shape [d] where d "
-             "is at most the degree of the polynomialModulus of "
-             "the output type's ring attribute";
-      return diag;
-    }
-  }
-
-  unsigned inputBitWidth = getInput().getType().getElementTypeBitWidth();
-  if (inputBitWidth > ring.getCoefficientType().getIntOrFloatBitWidth()) {
-    InFlightDiagnostic diag = emitOpError()
-                              << "input tensor element type "
-                              << getInput().getType().getElementType()
-                              << " is too large to fit in the coefficients of "
-                              << getOutput().getType();
-    diag.attachNote() << "the input tensor's elements must be rescaled"
-                         " to fit before using from_tensor";
-    return diag;
-  }
-
-  return success();
-}
-
-LogicalResult ToTensorOp::verify() {
-  ArrayRef<int64_t> tensorShape = getOutput().getType().getShape();
-  IntPolynomialAttr polyMod =
-      getInput().getType().getRing().getPolynomialModulus();
-  if (polyMod) {
-    unsigned polyDegree = polyMod.getPolynomial().getDegree();
-    bool compatible = tensorShape.size() == 1 && tensorShape[0] == polyDegree;
-
-    if (compatible)
-      return success();
-
-    InFlightDiagnostic diag = emitOpError()
-                              << "input type " << getInput().getType()
-                              << " does not match output type "
-                              << getOutput().getType();
-    diag.attachNote()
-        << "the output type must be a tensor of shape [d] where d "
-           "is at most the degree of the polynomialModulus of "
-           "the input type's ring attribute";
-    return diag;
-  }
-
-  return success();
-}
-
-LogicalResult MulScalarOp::verify() {
-  Type argType = getPolynomial().getType();
-  PolynomialType polyType;
-
-  if (auto shapedPolyType = dyn_cast<ShapedType>(argType)) {
-    polyType = cast<PolynomialType>(shapedPolyType.getElementType());
-  } else {
-    polyType = cast<PolynomialType>(argType);
-  }
-
-  Type coefficientType = polyType.getRing().getCoefficientType();
-
-  if (coefficientType != getScalar().getType())
-    return emitOpError() << "polynomial coefficient type " << coefficientType
-                         << " does not match scalar type "
-                         << getScalar().getType();
-
-  return success();
-}
-
-/// Test if a value is a primitive nth root of unity modulo cmod.
-bool isPrimitiveNthRootOfUnity(const APInt &root, const APInt &n,
-                               const APInt &cmod) {
-  // The first or subsequent multiplications, may overflow the input bit width,
-  // so scale them up to ensure they do not overflow.
-  unsigned requiredBitWidth =
-      std::max(root.getActiveBits() * 2, cmod.getActiveBits() * 2);
-  APInt r = APInt(root).zextOrTrunc(requiredBitWidth);
-  APInt cmodExt = APInt(cmod).zextOrTrunc(requiredBitWidth);
-  assert(r.ule(cmodExt) && "root must be less than cmod");
-  uint64_t upperBound = n.getZExtValue();
-
-  APInt a = r;
-  for (size_t k = 1; k < upperBound; k++) {
-    if (a.isOne())
-      return false;
-    a = (a * r).urem(cmodExt);
-  }
-  return a.isOne();
-}
-
-/// Verify that the types involved in an NTT or INTT operation are
-/// compatible.
-static LogicalResult verifyNTTOp(Operation *op, RingAttr ring,
-                                 RankedTensorType tensorType,
-                                 std::optional<PrimitiveRootAttr> root) {
-  Attribute encoding = tensorType.getEncoding();
-  if (!encoding) {
-    return op->emitOpError()
-           << "expects a ring encoding to be provided to the tensor";
-  }
-  auto encodedRing = dyn_cast<RingAttr>(encoding);
-  if (!encodedRing) {
-    return op->emitOpError()
-           << "the provided tensor encoding is not a ring attribute";
-  }
-
-  if (encodedRing != ring) {
-    return op->emitOpError()
-           << "encoded ring type " << encodedRing
-           << " is not equivalent to the polynomial ring " << ring;
-  }
-
-  unsigned polyDegree = ring.getPolynomialModulus().getPolynomial().getDegree();
-  ArrayRef<int64_t> tensorShape = tensorType.getShape();
-  bool compatible = tensorShape.size() == 1 && tensorShape[0] == polyDegree;
-  if (!compatible) {
-    InFlightDiagnostic diag = op->emitOpError()
-                              << "tensor type " << tensorType
-                              << " does not match output type " << ring;
-    diag.attachNote() << "the tensor must have shape [d] where d "
-                         "is exactly the degree of the polynomialModulus of "
-                         "the polynomial type's ring attribute";
-    return diag;
-  }
-
-  if (root.has_value()) {
-    APInt rootValue = root.value().getValue().getValue();
-    APInt rootDegree = root.value().getDegree().getValue();
-    APInt cmod = ring.getCoefficientModulus().getValue();
-    if (!isPrimitiveNthRootOfUnity(rootValue, rootDegree, cmod)) {
-      return op->emitOpError()
-             << "provided root " << rootValue.getZExtValue()
-             << " is not a primitive root "
-             << "of unity mod " << cmod.getZExtValue()
-             << ", with the specified degree " << rootDegree.getZExtValue();
-    }
-  }
-
-  return success();
-}
-
-LogicalResult NTTOp::verify() {
-  return verifyNTTOp(this->getOperation(), getInput().getType().getRing(),
-                     getOutput().getType(), getRoot());
-}
-
-LogicalResult INTTOp::verify() {
-  return verifyNTTOp(this->getOperation(), getOutput().getType().getRing(),
-                     getInput().getType(), getRoot());
-}
-
-ParseResult ConstantOp::parse(OpAsmParser &parser, OperationState &result) {
-  // Using the built-in parser.parseAttribute requires the full
-  // #polynomial.typed_int_polynomial syntax, which is excessive.
-  // Instead we parse a keyword int to signal it's an integer polynomial
-  Type type;
-  if (succeeded(parser.parseOptionalKeyword("float"))) {
-    Attribute floatPolyAttr = FloatPolynomialAttr::parse(parser, nullptr);
-    if (floatPolyAttr) {
-      if (parser.parseColon() || parser.parseType(type))
-        return failure();
-      result.addAttribute("value",
-                          TypedFloatPolynomialAttr::get(type, floatPolyAttr));
-      result.addTypes(type);
-      return success();
-    }
-  }
-
-  if (succeeded(parser.parseOptionalKeyword("int"))) {
-    Attribute intPolyAttr = IntPolynomialAttr::parse(parser, nullptr);
-    if (intPolyAttr) {
-      if (parser.parseColon() || parser.parseType(type))
-        return failure();
-
-      result.addAttribute("value",
-                          TypedIntPolynomialAttr::get(type, intPolyAttr));
-      result.addTypes(type);
-      return success();
-    }
-  }
-
-  // In the worst case, still accept the verbose versions.
-  TypedIntPolynomialAttr typedIntPolyAttr;
-  OptionalParseResult res =
-      parser.parseOptionalAttribute<TypedIntPolynomialAttr>(
-          typedIntPolyAttr, "value", result.attributes);
-  if (res.has_value() && succeeded(res.value())) {
-    result.addTypes(typedIntPolyAttr.getType());
-    return success();
-  }
-
-  TypedFloatPolynomialAttr typedFloatPolyAttr;
-  res = parser.parseAttribute<TypedFloatPolynomialAttr>(
-      typedFloatPolyAttr, "value", result.attributes);
-  if (res.has_value() && succeeded(res.value())) {
-    result.addTypes(typedFloatPolyAttr.getType());
-    return success();
-  }
-
-  return failure();
-}
-
-void ConstantOp::print(OpAsmPrinter &p) {
-  p << " ";
-  if (auto intPoly = dyn_cast<TypedIntPolynomialAttr>(getValue())) {
-    p << "int";
-    intPoly.getValue().print(p);
-  } else if (auto floatPoly = dyn_cast<TypedFloatPolynomialAttr>(getValue())) {
-    p << "float";
-    floatPoly.getValue().print(p);
-  } else {
-    assert(false && "unexpected attribute type");
-  }
-  p << " : ";
-  p.printType(getOutput().getType());
-}
-
-LogicalResult ConstantOp::inferReturnTypes(
-    MLIRContext *context, std::optional<mlir::Location> location,
-    ConstantOp::Adaptor adaptor,
-    llvm::SmallVectorImpl<mlir::Type> &inferredReturnTypes) {
-  Attribute operand = adaptor.getValue();
-  if (auto intPoly = dyn_cast<TypedIntPolynomialAttr>(operand)) {
-    inferredReturnTypes.push_back(intPoly.getType());
-  } else if (auto floatPoly = dyn_cast<TypedFloatPolynomialAttr>(operand)) {
-    inferredReturnTypes.push_back(floatPoly.getType());
-  } else {
-    assert(false && "unexpected attribute type");
-    return failure();
-  }
-  return success();
-}
-
-//===----------------------------------------------------------------------===//
-// TableGen'd canonicalization patterns
-//===----------------------------------------------------------------------===//
-
-namespace {
-#include "PolynomialCanonicalization.inc"
-} // namespace
-
-void SubOp::getCanonicalizationPatterns(RewritePatternSet &results,
-                                        MLIRContext *context) {
-  results.add<SubAsAdd>(context);
-}
-
-void NTTOp::getCanonicalizationPatterns(RewritePatternSet &results,
-                                        MLIRContext *context) {
-  results.add<NTTAfterINTT>(context);
-}
-
-void INTTOp::getCanonicalizationPatterns(RewritePatternSet &results,
-                                         MLIRContext *context) {
-  results.add<INTTAfterNTT>(context);
-}
diff --git a/mlir/test/Dialect/Polynomial/attributes.mlir b/mlir/test/Dialect/Polynomial/attributes.mlir
deleted file mode 100644
index cb3216900cb43..0000000000000
--- a/mlir/test/Dialect/Polynomial/attributes.mlir
+++ /dev/null
@@ -1,73 +0,0 @@
-// RUN: mlir-opt %s --split-input-file --verify-diagnostics
-
-#my_poly = #polynomial.int_polynomial<y + x**1024>
-// expected-error at below {{polynomials must have one indeterminate, but there were multiple: x, y}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-
-// -----
-
-// expected-error at below {{expected integer value}}
-// expected-error at below {{expected a monomial}}
-// expected-error at below {{found invalid integer exponent}}
-#my_poly = #polynomial.int_polynomial<5 + x**f>
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<5 + x**2 + 3x**2>
-// expected-error at below {{parsed polynomial must have unique exponents among monomials}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-
-// -----
-
-// expected-error at below {{expected + and more monomials, or > to end polynomial attribute}}
-#my_poly = #polynomial.int_polynomial<5 + x**2 7>
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-
-// -----
-
-// expected-error at below {{expected a monomial}}
-#my_poly = #polynomial.int_polynomial<5 + x**2 +>
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<5 + x**2>
-// expected-error at below {{failed to parse Polynomial_RingAttr parameter 'coefficientModulus' which is to be a `::mlir::IntegerAttr`}}
-// expected-error at below {{expected attribute value}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=x, polynomialModulus=#my_poly>
-
-// -----
-
-// expected-error at below {{coefficientModulus specified but coefficientType is not integral}}
-#ring1 = #polynomial.ring<coefficientType=f32, coefficientModulus=17>
-
-// -----
-
-// expected-error at below {{coefficientModulus should not be 0}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=0>
-
-// -----
-
-// expected-error at below {{coefficientModulus should be positive}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=-1>
-
-// -----
-
-// expected-error at below {{coefficientModulus needs bit width of 33 but coefficientType can only contain 32 bits}}
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=4294967297>
-
-// -----
-
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=4294967296>
-
-// -----
-
-// expected-error at below {{coefficientModulus should be positive}}
-#ring1 = #polynomial.ring<coefficientType=i64, coefficientModulus=18446744073709551615>
-
-// -----
-
-// unfortunately, coefficientModulus of 64bit should be contained in larger type
-#ring1 = #polynomial.ring<coefficientType=i64, coefficientModulus=18446744073709551615 : i128>
diff --git a/mlir/test/Dialect/Polynomial/canonicalization.mlir b/mlir/test/Dialect/Polynomial/canonicalization.mlir
deleted file mode 100644
index c0ee514daab64..0000000000000
--- a/mlir/test/Dialect/Polynomial/canonicalization.mlir
+++ /dev/null
@@ -1,47 +0,0 @@
-// RUN: mlir-opt -canonicalize %s | FileCheck %s
-#ntt_poly = #polynomial.int_polynomial<-1 + x**8>
-#ntt_ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#ntt_poly>
-#root = #polynomial.primitive_root<value=31:i32, degree=8:index>
-!ntt_poly_ty = !polynomial.polynomial<ring=#ntt_ring>
-!tensor_ty = tensor<8xi32, #ntt_ring>
-
-// CHECK-LABEL: @test_canonicalize_intt_after_ntt
-// CHECK: (%[[P:.*]]: [[T:.*]]) -> [[T]]
-func.func @test_canonicalize_intt_after_ntt(%p0 : !ntt_poly_ty) -> !ntt_poly_ty {
-  // CHECK-NOT: polynomial.ntt
-  // CHECK-NOT: polynomial.intt
-  // CHECK: %[[RESULT:.+]] = polynomial.add %[[P]], %[[P]]  : [[T]]
-  %t0 = polynomial.ntt %p0 {root=#root} : !ntt_poly_ty -> !tensor_ty
-  %p1 = polynomial.intt %t0 {root=#root} : !tensor_ty -> !ntt_poly_ty
-  %p2 = polynomial.add %p1, %p1 : !ntt_poly_ty
-  // CHECK: return %[[RESULT]] : [[T]]
-  return %p2 : !ntt_poly_ty
-}
-
-// CHECK-LABEL: @test_canonicalize_ntt_after_intt
-// CHECK: (%[[X:.*]]: [[T:.*]]) -> [[T]]
-func.func @test_canonicalize_ntt_after_intt(%t0 : !tensor_ty) -> !tensor_ty {
-  // CHECK-NOT: polynomial.intt
-  // CHECK-NOT: polynomial.ntt
-  // CHECK: %[[RESULT:.+]] = arith.addi %[[X]], %[[X]] : [[T]]
-  %p0 = polynomial.intt %t0 {root=#root} : !tensor_ty -> !ntt_poly_ty
-  %t1 = polynomial.ntt %p0 {root=#root} : !ntt_poly_ty -> !tensor_ty
-  %t2 = arith.addi %t1, %t1 : !tensor_ty
-  // CHECK: return %[[RESULT]] : [[T]]
-  return %t2 : !tensor_ty
-}
-
-#cycl_2048 = #polynomial.int_polynomial<1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256:i32, polynomialModulus=#cycl_2048>
-!sub_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-LABEL: test_canonicalize_sub
-// CHECK-SAME: (%[[p0:.*]]: [[T:.*]], %[[p1:.*]]: [[T]]) -> [[T]] {
-func.func @test_canonicalize_sub(%poly0 : !sub_ty, %poly1 : !sub_ty) -> !sub_ty {
-  %0 = polynomial.sub %poly0, %poly1  : !sub_ty
-  // CHECK: %[[minus_one:.+]] = arith.constant -1 : i32
-  // CHECK: %[[p1neg:.+]] = polynomial.mul_scalar %[[p1]], %[[minus_one]]
-  // CHECK: [[ADD:%.+]] = polynomial.add %[[p0]], %[[p1neg]]
-  return %0 : !sub_ty
-}
-
diff --git a/mlir/test/Dialect/Polynomial/ops.mlir b/mlir/test/Dialect/Polynomial/ops.mlir
deleted file mode 100644
index faeb68a8b2c09..0000000000000
--- a/mlir/test/Dialect/Polynomial/ops.mlir
+++ /dev/null
@@ -1,112 +0,0 @@
-// RUN: mlir-opt %s | FileCheck %s
-
-// This simply tests for syntax.
-
-#my_poly = #polynomial.int_polynomial<1 + x**1024>
-#my_poly_2 = #polynomial.int_polynomial<2>
-#my_poly_3 = #polynomial.int_polynomial<3x>
-#my_poly_4 = #polynomial.int_polynomial<t**3 + 4t + 2>
-#ring1 = #polynomial.ring<coefficientType=i32, coefficientModulus=2837465, polynomialModulus=#my_poly>
-#ring2 = #polynomial.ring<coefficientType=f32>
-#one_plus_x_squared = #polynomial.int_polynomial<1 + x**2>
-
-#ideal = #polynomial.int_polynomial<-1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#ideal>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-#ntt_poly = #polynomial.int_polynomial<-1 + x**8>
-#ntt_ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256, polynomialModulus=#ntt_poly>
-!ntt_poly_ty = !polynomial.polynomial<ring=#ntt_ring>
-
-#ntt_poly_2 = #polynomial.int_polynomial<1 + x**65536>
-#ntt_ring_2 = #polynomial.ring<coefficientType = i32, coefficientModulus = 786433 : i32, polynomialModulus=#ntt_poly_2>
-#ntt_ring_2_root = #polynomial.primitive_root<value=283965:i32, degree=131072:i32>
-!ntt_poly_ty_2 = !polynomial.polynomial<ring=#ntt_ring_2>
-
-module {
-  func.func @test_multiply() -> !polynomial.polynomial<ring=#ring1> {
-    %c0 = arith.constant 0 : index
-    %two = arith.constant 2 : i16
-    %five = arith.constant 5 : i16
-    %coeffs1 = tensor.from_elements %two, %two, %five : tensor<3xi16>
-    %coeffs2 = tensor.from_elements %five, %five, %two : tensor<3xi16>
-
-    %poly1 = polynomial.from_tensor %coeffs1 : tensor<3xi16> -> !polynomial.polynomial<ring=#ring1>
-    %poly2 = polynomial.from_tensor %coeffs2 : tensor<3xi16> -> !polynomial.polynomial<ring=#ring1>
-
-    %3 = polynomial.mul %poly1, %poly2 : !polynomial.polynomial<ring=#ring1>
-
-    return %3 : !polynomial.polynomial<ring=#ring1>
-  }
-
-  func.func @test_elementwise(%p0 : !polynomial.polynomial<ring=#ring1>, %p1: !polynomial.polynomial<ring=#ring1>) {
-    %tp0 = tensor.from_elements %p0, %p1 : tensor<2x!polynomial.polynomial<ring=#ring1>>
-    %tp1 = tensor.from_elements %p1, %p0 : tensor<2x!polynomial.polynomial<ring=#ring1>>
-
-    %c = arith.constant 2 : i32
-    %mul_const_sclr = polynomial.mul_scalar %tp0, %c : tensor<2x!polynomial.polynomial<ring=#ring1>>, i32
-
-    %add = polynomial.add %tp0, %tp1 : tensor<2x!polynomial.polynomial<ring=#ring1>>
-    %sub = polynomial.sub %tp0, %tp1 : tensor<2x!polynomial.polynomial<ring=#ring1>>
-    %mul = polynomial.mul %tp0, %tp1 : tensor<2x!polynomial.polynomial<ring=#ring1>>
-
-    return
-  }
-
-  func.func @test_to_from_tensor(%p0 : !polynomial.polynomial<ring=#ring1>) {
-    %c0 = arith.constant 0 : index
-    %two = arith.constant 2 : i16
-    %coeffs1 = tensor.from_elements %two, %two : tensor<2xi16>
-    // CHECK: from_tensor
-    %poly = polynomial.from_tensor %coeffs1 : tensor<2xi16> -> !polynomial.polynomial<ring=#ring1>
-    // CHECK: to_tensor
-    %tensor = polynomial.to_tensor %poly : !polynomial.polynomial<ring=#ring1> -> tensor<1024xi16>
-
-    return
-  }
-
-  func.func @test_degree(%p0 : !polynomial.polynomial<ring=#ring1>) {
-    %0, %1 = polynomial.leading_term %p0 : !polynomial.polynomial<ring=#ring1> -> (index, i32)
-    return
-  }
-
-  func.func @test_monomial() {
-    %deg = arith.constant 1023 : index
-    %five = arith.constant 5 : i16
-    %0 = polynomial.monomial %five, %deg : (i16, index) -> !polynomial.polynomial<ring=#ring1>
-    return
-  }
-
-  func.func @test_monic_monomial_mul() {
-    %five = arith.constant 5 : index
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<ring=#ring1>
-    %1 = polynomial.monic_monomial_mul %0, %five : (!polynomial.polynomial<ring=#ring1>, index) -> !polynomial.polynomial<ring=#ring1>
-    return
-  }
-
-  func.func @test_constant() {
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<ring=#ring1>
-    %1 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<ring=#ring1>
-    %2 = polynomial.constant float<1.5 + 0.5 x**2> : !polynomial.polynomial<ring=#ring2>
-
-    // Test verbose fallbacks
-    %verb0 = polynomial.constant #polynomial.typed_int_polynomial<1 + x**2> : !polynomial.polynomial<ring=#ring1>
-    %verb2 = polynomial.constant #polynomial.typed_float_polynomial<1.5 + 0.5 x**2> : !polynomial.polynomial<ring=#ring2>
-    return
-  }
-
-  func.func @test_ntt(%0 : !ntt_poly_ty) {
-    %1 = polynomial.ntt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : !ntt_poly_ty -> tensor<8xi32, #ntt_ring>
-    return
-  }
-
-  func.func @test_ntt_with_overflowing_root(%0 : !ntt_poly_ty_2) {
-    %1 = polynomial.ntt %0 {root=#ntt_ring_2_root} : !ntt_poly_ty_2 -> tensor<65536xi32, #ntt_ring_2>
-    return
-  }
-
-  func.func @test_intt(%0 : tensor<8xi32, #ntt_ring>) {
-    %1 = polynomial.intt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : tensor<8xi32, #ntt_ring> -> !ntt_poly_ty
-    return
-  }
-}
diff --git a/mlir/test/Dialect/Polynomial/ops_errors.mlir b/mlir/test/Dialect/Polynomial/ops_errors.mlir
deleted file mode 100644
index 4937e17027afa..0000000000000
--- a/mlir/test/Dialect/Polynomial/ops_errors.mlir
+++ /dev/null
@@ -1,126 +0,0 @@
-// RUN: mlir-opt --split-input-file --verify-diagnostics %s
-
-#my_poly = #polynomial.int_polynomial<1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16>
-!ty = !polynomial.polynomial<ring=#ring>
-
-func.func @test_from_tensor_too_large_coeffs() {
-  %two = arith.constant 2 : i32
-  %coeffs1 = tensor.from_elements %two, %two : tensor<2xi32>
-  // expected-error at below {{is too large to fit in the coefficients}}
-  // expected-note at below {{rescaled to fit}}
-  %poly = polynomial.from_tensor %coeffs1 : tensor<2xi32> -> !ty
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<1 + x**4>
-#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256:i32, polynomialModulus=#my_poly>
-!ty = !polynomial.polynomial<ring=#ring>
-func.func @test_from_tensor_wrong_tensor_type() {
-  %two = arith.constant 2 : i32
-  %coeffs1 = tensor.from_elements %two, %two, %two, %two, %two : tensor<5xi32>
-  // expected-error at below {{input type 'tensor<5xi32>' does not match output type '!polynomial.polynomial<ring = <coefficientType = i32, coefficientModulus = 256 : i32, polynomialModulus = <1 + x**4>>>'}}
-  // expected-note at below {{at most the degree of the polynomialModulus of the output type's ring attribute}}
-  %poly = polynomial.from_tensor %coeffs1 : tensor<5xi32> -> !ty
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<1 + x**4>
-#ring = #polynomial.ring<coefficientType=i32, coefficientModulus=256:i32, polynomialModulus=#my_poly>
-!ty = !polynomial.polynomial<ring=#ring>
-func.func @test_to_tensor_wrong_output_tensor_type(%arg0 : !ty) {
-  // expected-error at below {{input type '!polynomial.polynomial<ring = <coefficientType = i32, coefficientModulus = 256 : i32, polynomialModulus = <1 + x**4>>>' does not match output type 'tensor<5xi32>'}}
-  // expected-note at below {{at most the degree of the polynomialModulus of the input type's ring attribute}}
-  %tensor = polynomial.to_tensor %arg0 : !ty -> tensor<5xi32>
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i32, polynomialModulus=#my_poly>
-!ty = !polynomial.polynomial<ring=#ring>
-
-func.func @test_mul_scalar_wrong_type(%arg0: !ty) -> !ty {
-  %scalar = arith.constant 2 : i32  // should be i16
-  // expected-error at below {{polynomial coefficient type 'i16' does not match scalar type 'i32'}}
-  %poly = polynomial.mul_scalar %arg0, %scalar : !ty, i32
-  return %poly : !ty
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<-1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i16, polynomialModulus=#my_poly>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-NOT: @test_invalid_ntt
-// CHECK-NOT: polynomial.ntt
-func.func @test_invalid_ntt(%0 : !poly_ty) {
-  // expected-error at below {{expects a ring encoding to be provided to the tensor}}
-  %1 = polynomial.ntt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : !poly_ty -> tensor<1024xi32>
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<-1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i16, polynomialModulus=#my_poly>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-NOT: @test_invalid_ntt
-// CHECK-NOT: polynomial.ntt
-func.func @test_invalid_ntt(%0 : !poly_ty) {
-  // expected-error at below {{tensor encoding is not a ring attribute}}
-  %1 = polynomial.ntt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : !poly_ty -> tensor<1024xi32, #my_poly>
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<-1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i16, polynomialModulus=#my_poly>
-#ring1 = #polynomial.ring<coefficientType=i16, coefficientModulus=257:i16, polynomialModulus=#my_poly>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-NOT: @test_invalid_intt
-// CHECK-NOT: polynomial.intt
-func.func @test_invalid_intt(%0 : tensor<1024xi32, #ring1>) {
-  // expected-error at below {{not equivalent to the polynomial ring}}
-  %1 = polynomial.intt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : tensor<1024xi32, #ring1> -> !poly_ty
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<-1 + x**1024>
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i16, polynomialModulus=#my_poly>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-NOT: @test_invalid_intt
-// CHECK-NOT: polynomial.intt
-func.func @test_invalid_intt(%0 : tensor<1025xi32, #ring>) {
-  // expected-error at below {{does not match output type}}
-  // expected-note at below {{exactly the degree of the polynomialModulus of the polynomial type's ring attribute}}
-  %1 = polynomial.intt %0 {root=#polynomial.primitive_root<value=31:i32, degree=8:index>} : tensor<1025xi32, #ring> -> !poly_ty
-  return
-}
-
-// -----
-
-#my_poly = #polynomial.int_polynomial<-1 + x**8>
-// A valid root is 31
-#ring = #polynomial.ring<coefficientType=i16, coefficientModulus=256:i16, polynomialModulus=#my_poly>
-!poly_ty = !polynomial.polynomial<ring=#ring>
-
-// CHECK-NOT: @test_invalid_intt
-// CHECK-NOT: polynomial.intt
-func.func @test_invalid_intt(%0 : tensor<8xi32, #ring>) {
-  // expected-error at below {{provided root 32 is not a primitive root of unity mod 256, with the specified degree 8}}
-  %1 = polynomial.intt %0 {root=#polynomial.primitive_root<value=32:i16, degree=8:index>} : tensor<8xi32, #ring> -> !poly_ty
-  return
-}
diff --git a/mlir/test/Dialect/Polynomial/types.mlir b/mlir/test/Dialect/Polynomial/types.mlir
deleted file mode 100644
index dcc5663ceb84c..0000000000000
--- a/mlir/test/Dialect/Polynomial/types.mlir
+++ /dev/null
@@ -1,65 +0,0 @@
-// RUN: mlir-opt %s | FileCheck %s
-
-// CHECK-LABEL: func @test_types
-// CHECK-SAME:  !polynomial.polynomial<
-// CHECK-SAME:    ring = <
-// CHECK-SAME:       coefficientType = i32,
-// CHECK-SAME:       coefficientModulus = 2837465 : i32,
-// CHECK-SAME:       polynomialModulus = <1 + x**1024>>>
-#my_poly = #polynomial.int_polynomial<1 + x**1024>
-#ring1 = #polynomial.ring<coefficientType = i32, coefficientModulus = 2837465 : i32, polynomialModulus=#my_poly>
-!ty = !polynomial.polynomial<ring=#ring1>
-func.func @test_types(%0: !ty) -> !ty {
-  return %0 : !ty
-}
-
-
-// CHECK-LABEL: func @test_non_x_variable_64_bit
-// CHECK-SAME:  !polynomial.polynomial<
-// CHECK-SAME:    ring = <
-// CHECK-SAME:       coefficientType = i64,
-// CHECK-SAME:       coefficientModulus = 2837465 : i64,
-// CHECK-SAME:       polynomialModulus = <2 + 4x + x**3>>>
-#my_poly_2 = #polynomial.int_polynomial<t**3 + 4t + 2>
-#ring2 = #polynomial.ring<coefficientType = i64, coefficientModulus = 2837465 : i64, polynomialModulus=#my_poly_2>
-!ty2 = !polynomial.polynomial<ring=#ring2>
-func.func @test_non_x_variable_64_bit(%0: !ty2) -> !ty2 {
-  return %0 : !ty2
-}
-
-
-// CHECK-LABEL: func @test_linear_poly
-// CHECK-SAME:  !polynomial.polynomial<
-// CHECK-SAME:    ring = <
-// CHECK-SAME:       coefficientType = i32,
-// CHECK-SAME:       coefficientModulus = 12 : i32,
-// CHECK-SAME:       polynomialModulus = <4x>>
-#my_poly_3 = #polynomial.int_polynomial<4x>
-#ring3 = #polynomial.ring<coefficientType = i32, coefficientModulus=12 : i32, polynomialModulus=#my_poly_3>
-!ty3 = !polynomial.polynomial<ring=#ring3>
-func.func @test_linear_poly(%0: !ty3) -> !ty3 {
-  return %0 : !ty3
-}
-
-// CHECK-LABEL: func @test_negative_leading_1
-// CHECK-SAME:  !polynomial.polynomial<
-// CHECK-SAME:    ring = <
-// CHECK-SAME:       coefficientType = i32,
-// CHECK-SAME:       coefficientModulus = 2837465 : i32,
-// CHECK-SAME:       polynomialModulus = <-1 + x**1024>>>
-#my_poly_4 = #polynomial.int_polynomial<-1 + x**1024>
-#ring4 = #polynomial.ring<coefficientType = i32, coefficientModulus = 2837465 : i32, polynomialModulus=#my_poly_4>
-!ty4 = !polynomial.polynomial<ring=#ring4>
-func.func @test_negative_leading_1(%0: !ty4) -> !ty4 {
-  return %0 : !ty4
-}
-
-// CHECK-LABEL: func @test_float_coefficients
-// CHECK-SAME:  !polynomial.polynomial<ring = <coefficientType = f32>>
-#my_poly_5 = #polynomial.float_polynomial<0.5 + 1.6e03 x**1024>
-#ring5 = #polynomial.ring<coefficientType=f32>
-!ty5 = !polynomial.polynomial<ring=#ring5>
-func.func @test_float_coefficients(%0: !ty5) -> !ty5 {
-  return %0 : !ty5
-}
-
diff --git a/mlir/test/IR/parser_dialect_loading.mlir b/mlir/test/IR/parser_dialect_loading.mlir
deleted file mode 100644
index b9c2d30cf3c98..0000000000000
--- a/mlir/test/IR/parser_dialect_loading.mlir
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: mlir-opt -allow-unregistered-dialect --split-input-file %s | FileCheck %s
-
-// This is a testing that a non-qualified attribute in a custom format
-// correctly preload the dialect before creating the attribute.
-#attr = #test.nested_polynomial<poly=<1 + x**2>>
-// CHECK-LABEL: @parse_correctly
-llvm.func @parse_correctly() {
-  test.containing_int_polynomial_attr #attr
-  llvm.return
-}
-
-// -----
-
-#attr2 = #test.nested_polynomial2<poly=<1 + x**2>>
-// CHECK-LABEL: @parse_correctly_2
-llvm.func @parse_correctly_2() {
-  test.containing_int_polynomial_attr2 #attr2
-  llvm.return
-}
diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt
index 6e608e4772391..d2181cea0ecf9 100644
--- a/mlir/test/lib/Dialect/Test/CMakeLists.txt
+++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt
@@ -87,7 +87,6 @@ mlir_target_link_libraries(MLIRTestDialect PUBLIC
   MLIRPtrDialect
   MLIRLLVMDialect
   MLIRPass
-  MLIRPolynomialDialect
   MLIRReduce
   MLIRTensorDialect
   MLIRTransformUtils
diff --git a/mlir/test/lib/Dialect/Test/TestAttrDefs.td b/mlir/test/lib/Dialect/Test/TestAttrDefs.td
index 6441a82d87eba..5472a42edbdcb 100644
--- a/mlir/test/lib/Dialect/Test/TestAttrDefs.td
+++ b/mlir/test/lib/Dialect/Test/TestAttrDefs.td
@@ -16,7 +16,6 @@
 // To get the test dialect definition.
 include "TestDialect.td"
 include "TestEnumDefs.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
 include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.td"
 include "mlir/Dialect/Utils/StructuredOpsUtils.td"
 include "mlir/IR/AttrTypeBase.td"
@@ -379,22 +378,6 @@ def TestCustomStructAttr : Test_Attr<"TestCustomStruct"> {
   }];
 }
 
-def NestedPolynomialAttr : Test_Attr<"NestedPolynomialAttr"> {
-  let mnemonic = "nested_polynomial";
-  let parameters = (ins Polynomial_IntPolynomialAttr:$poly);
-  let assemblyFormat = [{
-    `<` struct(params) `>`
-  }];
-}
-
-def NestedPolynomialAttr2 : Test_Attr<"NestedPolynomialAttr2"> {
-  let mnemonic = "nested_polynomial2";
-  let parameters = (ins OptionalParameter<"::mlir::polynomial::IntPolynomialAttr">:$poly);
-  let assemblyFormat = [{
-    `<` struct(params) `>`
-  }];
-}
-
 // Test a ptr constant memory space.
 def TestConstMemorySpaceAttr : Test_Attr<"TestConstMemorySpace", [
     DeclareAttrInterfaceMethods<MemorySpaceAttrInterface>
diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.h b/mlir/test/lib/Dialect/Test/TestAttributes.h
index bcbc360758eec..8c4bdd2d79486 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.h
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.h
@@ -17,23 +17,23 @@
 #include <tuple>
 
 #include "TestTraits.h"
-#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
 #include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
 #include "mlir/Dialect/Utils/StructuredOpsUtils.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/Diagnostics.h"
 #include "mlir/IR/Dialect.h"
 #include "mlir/IR/DialectImplementation.h"
+#include "mlir/IR/DialectResourceBlobManager.h"
 
+// generated files require above includes to come first
 #include "TestAttrInterfaces.h.inc"
 #include "TestOpEnums.h.inc"
-#include "mlir/IR/DialectResourceBlobManager.h"
 
 namespace test {
 class TestDialect;
 // Payload class for the CopyCountAttr.
 class CopyCount {
-public:
+ public:
   CopyCount(std::string value) : value(value) {}
   CopyCount(const CopyCount &rhs);
   CopyCount &operator=(const CopyCount &rhs);
@@ -48,9 +48,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
 /// A handle used to reference external elements instances.
 using TestDialectResourceBlobHandle =
     mlir::DialectResourceBlobHandle<TestDialect>;
-} // namespace test
+}  // namespace test
 
 #define GET_ATTRDEF_CLASSES
 #include "TestAttrDefs.h.inc"
 
-#endif // MLIR_TESTATTRIBUTES_H
+#endif  // MLIR_TESTATTRIBUTES_H
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 85a49e05d4c73..47137b3553627 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -243,16 +243,6 @@ def FloatElementsAttrOp : TEST_Op<"float_elements_attr"> {
   );
 }
 
-def ContainingIntPolynomialAttrOp : TEST_Op<"containing_int_polynomial_attr"> {
-  let arguments = (ins NestedPolynomialAttr:$attr);
-  let assemblyFormat = "$attr attr-dict";
-}
-
-def ContainingIntPolynomialAttr2Op : TEST_Op<"containing_int_polynomial_attr2"> {
-  let arguments = (ins NestedPolynomialAttr2:$attr);
-  let assemblyFormat = "$attr attr-dict";
-}
-
 // A pattern that updates dense<[3.0, 4.0]> to dense<[5.0, 6.0]>.
 // This tests both matching and generating float elements attributes.
 def UpdateFloatElementsAttr : Pat<
diff --git a/mlir/unittests/Dialect/CMakeLists.txt b/mlir/unittests/Dialect/CMakeLists.txt
index a88dc98c034e4..aea247547473d 100644
--- a/mlir/unittests/Dialect/CMakeLists.txt
+++ b/mlir/unittests/Dialect/CMakeLists.txt
@@ -12,7 +12,6 @@ add_subdirectory(Index)
 add_subdirectory(LLVMIR)
 add_subdirectory(MemRef)
 add_subdirectory(OpenACC)
-add_subdirectory(Polynomial)
 add_subdirectory(SCF)
 add_subdirectory(SparseTensor)
 add_subdirectory(SPIRV)
diff --git a/mlir/unittests/Dialect/Polynomial/CMakeLists.txt b/mlir/unittests/Dialect/Polynomial/CMakeLists.txt
deleted file mode 100644
index 97f5b890ab4fb..0000000000000
--- a/mlir/unittests/Dialect/Polynomial/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-add_mlir_unittest(MLIRPolynomialTests
-  PolynomialMathTest.cpp
-)
-mlir_target_link_libraries(MLIRPolynomialTests
-  PRIVATE
-  MLIRIR
-  MLIRPolynomialDialect
-)
diff --git a/mlir/unittests/Dialect/Polynomial/PolynomialMathTest.cpp b/mlir/unittests/Dialect/Polynomial/PolynomialMathTest.cpp
deleted file mode 100644
index 95906ad42588e..0000000000000
--- a/mlir/unittests/Dialect/Polynomial/PolynomialMathTest.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-//===- PolynomialMathTest.cpp - Polynomial math Tests ---------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
-#include "gtest/gtest.h"
-
-using namespace mlir;
-using namespace mlir::polynomial;
-
-TEST(AddTest, checkSameDegreeAdditionOfIntPolynomial) {
-  IntPolynomial x = IntPolynomial::fromCoefficients({1, 2, 3});
-  IntPolynomial y = IntPolynomial::fromCoefficients({2, 3, 4});
-  IntPolynomial expected = IntPolynomial::fromCoefficients({3, 5, 7});
-  EXPECT_EQ(expected, x.add(y));
-}
-
-TEST(AddTest, checkDifferentDegreeAdditionOfIntPolynomial) {
-  IntMonomial term2t = IntMonomial(2, 1);
-  IntPolynomial x = IntPolynomial::fromMonomials({term2t}).value();
-  IntPolynomial y = IntPolynomial::fromCoefficients({2, 3, 4});
-  IntPolynomial expected = IntPolynomial::fromCoefficients({2, 5, 4});
-  EXPECT_EQ(expected, x.add(y));
-  EXPECT_EQ(expected, y.add(x));
-}
-
-TEST(AddTest, checkSameDegreeAdditionOfFloatPolynomial) {
-  FloatPolynomial x = FloatPolynomial::fromCoefficients({1.5, 2.5, 3.5});
-  FloatPolynomial y = FloatPolynomial::fromCoefficients({2.5, 3.5, 4.5});
-  FloatPolynomial expected = FloatPolynomial::fromCoefficients({4, 6, 8});
-  EXPECT_EQ(expected, x.add(y));
-}
-
-TEST(AddTest, checkDifferentDegreeAdditionOfFloatPolynomial) {
-  FloatPolynomial x = FloatPolynomial::fromCoefficients({1.5, 2.5});
-  FloatPolynomial y = FloatPolynomial::fromCoefficients({2.5, 3.5, 4.5});
-  FloatPolynomial expected = FloatPolynomial::fromCoefficients({4, 6, 4.5});
-  EXPECT_EQ(expected, x.add(y));
-  EXPECT_EQ(expected, y.add(x));
-}
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index da7b783e98ba8..2e9341e7fbc5d 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -6156,96 +6156,6 @@ gentbl_cc_library(
     deps = [":PDLInterpOpsTdFiles"],
 )
 
-cc_library(
-    name = "PolynomialDialect",
-    srcs = glob([
-        "lib/Dialect/Polynomial/IR/*.cpp",
-    ]),
-    hdrs = glob([
-        "include/mlir/Dialect/Polynomial/IR/*.h",
-    ]),
-    includes = ["include"],
-    deps = [
-        ":ArithDialect",
-        ":IR",
-        ":InferTypeOpInterface",
-        ":PolynomialAttributesIncGen",
-        ":PolynomialCanonicalizationIncGen",
-        ":PolynomialIncGen",
-        ":Support",
-        "//llvm:Support",
-    ],
-)
-
-td_library(
-    name = "PolynomialTdFiles",
-    srcs = glob(["include/mlir/Dialect/Polynomial/IR/*.td"]),
-    includes = ["include"],
-    deps = [
-        ":BuiltinDialectTdFiles",
-        ":InferTypeOpInterfaceTdFiles",
-        ":OpBaseTdFiles",
-        ":SideEffectInterfacesTdFiles",
-    ],
-)
-
-gentbl_cc_library(
-    name = "PolynomialIncGen",
-    tbl_outs = {
-        "include/mlir/Dialect/Polynomial/IR/Polynomial.h.inc": ["-gen-op-decls"],
-        "include/mlir/Dialect/Polynomial/IR/Polynomial.cpp.inc": ["-gen-op-defs"],
-        "include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h.inc": [
-            "-gen-dialect-decls",
-            "-dialect=polynomial",
-        ],
-        "include/mlir/Dialect/Polynomial/IR/PolynomialDialect.cpp.inc": [
-            "-gen-dialect-defs",
-            "-dialect=polynomial",
-        ],
-        "include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h.inc": [
-            "--gen-typedef-decls",
-            "-typedefs-dialect=polynomial",
-        ],
-        "include/mlir/Dialect/Polynomial/IR/PolynomialTypes.cpp.inc": [
-            "--gen-typedef-defs",
-            "-typedefs-dialect=polynomial",
-        ],
-        "g3doc/Dialects/Polynomial/Polynomial.md": ["-gen-op-doc"],
-    },
-    tblgen = ":mlir-tblgen",
-    td_file = "include/mlir/Dialect/Polynomial/IR/Polynomial.td",
-    deps = [":PolynomialTdFiles"],
-)
-
-gentbl_cc_library(
-    name = "PolynomialAttributesIncGen",
-    tbl_outs = {
-        "include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h.inc": [
-            "-gen-attrdef-decls",
-            "-attrdefs-dialect=polynomial",
-        ],
-        "include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.cpp.inc": [
-            "-gen-attrdef-defs",
-            "-attrdefs-dialect=polynomial",
-        ],
-    },
-    tblgen = ":mlir-tblgen",
-    td_file = "include/mlir/Dialect/Polynomial/IR/Polynomial.td",
-    deps = [":PolynomialTdFiles"],
-)
-
-gentbl_cc_library(
-    name = "PolynomialCanonicalizationIncGen",
-    strip_include_prefix = "include/mlir/Dialect/Polynomial/IR",
-    tbl_outs = {"include/mlir/Dialect/Polynomial/IR/PolynomialCanonicalization.inc": ["-gen-rewriters"]},
-    tblgen = ":mlir-tblgen",
-    td_file = "lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td",
-    deps = [
-        ":ArithOpsTdFiles",
-        ":PolynomialTdFiles",
-    ],
-)
-
 td_library(
     name = "PtrTdFiles",
     srcs = [
@@ -8864,7 +8774,6 @@ cc_library(
         ":PDLDialect",
         ":PDLInterpDialect",
         ":PDLToPDLInterp",
-        ":PolynomialDialect",
         ":PtrDialect",
         ":QuantOps",
         ":QuantTransforms",
diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
index 95fb5fb537678..84570fa107e47 100644
--- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
@@ -124,7 +124,6 @@ td_library(
         "//mlir:LinalgStructuredOpsTdFiles",
         "//mlir:MemorySlotInterfacesTdFiles",
         "//mlir:OpBaseTdFiles",
-        "//mlir:PolynomialTdFiles",
         "//mlir:PtrTdFiles",
         "//mlir:SideEffectInterfacesTdFiles",
     ],
@@ -370,7 +369,6 @@ cc_library(
         "//mlir:LoopLikeInterface",
         "//mlir:MemorySlotInterfaces",
         "//mlir:Pass",
-        "//mlir:PolynomialDialect",
         "//mlir:PtrDialect",
         "//mlir:Reducer",
         "//mlir:SideEffectInterfaces",

>From 3420284a141300b9798de8ac96f4c47c829f397c Mon Sep 17 00:00:00 2001
From: Jeremy Kun <jkun at google.com>
Date: Tue, 13 May 2025 10:12:07 -0700
Subject: [PATCH 2/2] formatting

---
 mlir/include/mlir/InitAllDialects.h         | 4 ++--
 mlir/test/lib/Dialect/Test/TestAttributes.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h
index e751bf7109c99..ea285ac7f16e3 100644
--- a/mlir/include/mlir/InitAllDialects.h
+++ b/mlir/include/mlir/InitAllDialects.h
@@ -205,6 +205,6 @@ inline void registerAllDialects(MLIRContext &context) {
   context.appendDialectRegistry(registry);
 }
 
-}  // namespace mlir
+} // namespace mlir
 
-#endif  // MLIR_INITALLDIALECTS_H_
+#endif // MLIR_INITALLDIALECTS_H_
diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.h b/mlir/test/lib/Dialect/Test/TestAttributes.h
index 8c4bdd2d79486..778d84fae7365 100644
--- a/mlir/test/lib/Dialect/Test/TestAttributes.h
+++ b/mlir/test/lib/Dialect/Test/TestAttributes.h
@@ -33,7 +33,7 @@ namespace test {
 class TestDialect;
 // Payload class for the CopyCountAttr.
 class CopyCount {
- public:
+public:
   CopyCount(std::string value) : value(value) {}
   CopyCount(const CopyCount &rhs);
   CopyCount &operator=(const CopyCount &rhs);
@@ -48,9 +48,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
 /// A handle used to reference external elements instances.
 using TestDialectResourceBlobHandle =
     mlir::DialectResourceBlobHandle<TestDialect>;
-}  // namespace test
+} // namespace test
 
 #define GET_ATTRDEF_CLASSES
 #include "TestAttrDefs.h.inc"
 
-#endif  // MLIR_TESTATTRIBUTES_H
+#endif // MLIR_TESTATTRIBUTES_H



More information about the llvm-commits mailing list