[MLIR][Arith][Vector] Reject i0 integer type in arith and vector ops (#183589) Add ODS type constraints that exclude zero-bitwidth integers (i0) from operations in the arith and vector dialects. i0 has no meaningful arithmetic representation and operations on it can trigger undefined behavior (e.g. bitwidth calculations assuming non-zero width). Changes: - Add `AnyNonZeroBitwidthSignlessInteger` (as a `ConfinedType` over `AnySignlessInteger`) and `AnyNonZeroBitwidthSignlessIntegerOrIndex` to CommonTypeConstraints.td. - Introduce `Arith_SignlessIntegerOrIndexLike` in ArithOps.td that wraps `AnyNonZeroBitwidthSignlessIntegerOrIndex` via `TypeOrValueSemanticsContainer`, and update `SignlessFixedWidthIntegerLike` to use `AnyNonZeroBitwidthSignlessInteger`. Replace all uses of the shared `SignlessIntegerOrIndexLike` in ArithOps.td with the new dialect-local constraint. - Update `IndexCastTypeConstraint` to use `Arith_SignlessIntegerOrIndexLike`. - Update `BitcastTypeConstraint` to exclude i0 by composing the already- defined `SignlessFixedWidthIntegerLike` and `FloatLike` constraints, keeping the definition compact (3 alternatives instead of 7). - Add `AnyVectorOfNonI0Elem` and `AnyVectorOfNonZeroRankNonI0Elem` in VectorOps.td and apply them to `vector.contract`, `vector.reduction`, `vector.multi_reduction`, `vector.outerproduct`, `vector.bitcast`, and `vector.scan`. - Update arith/invalid.mlir with explicit i0 rejection tests covering all integer op families (binary ops, cast ops, extended-multiply ops, cmpi, bitcast, index_cast, index_castui) for both scalar and vector<N> forms. - Update vector/invalid.mlir with i0 rejection tests for all covered ops. - Remove the now-invalid i0 canonicalization tests from arith/canonicalize.mlir. Fixes #177822 Fixes #179266 Fixes #180463 Fixes #181532 See also https://discourse.llvm.org/t/rfc-reject-i0-integer-type-in-arith-and-vector-ops/90011
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.