[AMDGPU] Ignore edges from the def block in PhiIncomingAnalysis (#232297)
PhiIncomingAnalysis inserts the def block into the set of reachable
blocks so that it acts as an end point for the traversal, but it also
counted it as a reachable predecessor when deciding whether an incoming
block is a source. An edge from the def block to an incoming block
starts a new trip around a loop through the def block, so it does not
mean that some lanes may have taken their value from an earlier incoming
block.
This affects lane mask phis in loops where the header has a divergent
branch to the latch: the header phi merged the value from the latch, and
the latch phi merged the value from the header, even though EXEC is the
same at the end of the header and at the end of the latch, so the merged
bits could only belong to lanes that had already left the loop.
This relies on the incoming block's terminator not enabling any lanes
that were inactive in the block. The only terminator that could do that
is SI_ELSE, and a structurized CFG never puts an SI_ELSE block in a cycle
[2 lines not shown]
[MLIR][Vector] Lower fixed two-stream transposes to interleave ops (#237937)
Lower fixed-size rank-2 `vector.transpose` operations with a dimension
of size two to fixed-size `vector.interleave` or `vector.deinterleave`
operations. This keeps the lowering entirely VLS: it introduces no
scalable vectors, `vscale`, runtime loops, masks, or scratch buffers.
Preserving the transpose as structured vector operations avoids
elementwise expansion. For `vector<64x2xf32>`, this eliminates 128
`extractelement` and 128 `insertelement` operations. In an end-to-end
load–transpose–store benchmark on Neoverse N2, the generated assembly
decreased from 78 to 54 instructions, stack usage from 128 to 64 bytes,
compilation improved by 10.9× in MLIR and 2.1× in `llc`
The transformation remains opt-in because profitability depends on the
shape and target. It is exposed through the Transform dialect and tested
in both transpose directions, including unsupported and scalable-vector
cases.
Assisted by: GPT-5.6 Sol
[LVI][CVP] Consider pointer provenance when pointer equality is assumed (#239218)
Similarly to what GVN and SCCP already account for, make sure pointer
substitutions pass through canReplacePointersIfEqual(), subject to its
approximations. When LVI derives a pointer constant from an equality
predicate, such a constant may have different or non-existent pointer
provenance than the original value, and may therefore not be freely
substituted for it.
Fixes: https://github.com/llvm/llvm-project/issues/163144.
[mlir][vector] Add `getUnrollOrder` to `VectorUnrollOpInterface` (#243527)
In essence, the unrolling order depends on the underlying Op, so it is
natural to add `getUnrollOrder` to `VectorUnrollOpInterface`. This
change helps us unify unrolling patterns in `VectorUnroll.cpp`.
In addition, `UnrollVectorOptions` gains two new fields:
1) `bool reverseDefaultTraversalOrder = false;`
2) `SmallVector<int64_t> unrollOrderForContractOp`
The first one is self-explanatory. The second one is currently driven by
the test pipeline option, e.g.:
* `-test-vector-unrolling-patterns="unroll-based-on-type
unroll-order=2,0,1"`
The provided unrolling order is only used when unrolling ContractionOp,
hence `unrollOrderForContractOp` rather than some more generic name. It
effectively replaces `traversalOrderCallback`, which was mostly used in
TestVectorTransforms.cpp (the remaining user in `GPUTransformOps.cpp`
[16 lines not shown]
[RelLookupTableConverter] Add support for multiple uses (#244625)
This adds support for uses of the lookup table in multiple gep+load
pairs (including in different functions), as long as *all* of them can
be converted.
I've factored out the use analysis logic to make it easier to extend
this to support uses through phis/selects in the future.
[mlir][ODS] Register the operations of a dialect by default
Dialects registered their ODS operations by expanding `GET_OP_LIST` into
`addOperations` in `initialize`, while sharded and partitioned dialects
had to call the generated `register<Dialect>Operations` themselves.
This was not only an inconsistent interface but also boilerplate for every dialect definition.
Like attributes and types do since https://github.com/llvm/llvm-project/pull/243481, operations are now only registered by a generated
`register<Dialect>Operations` hook that the generated dialect
constructor calls, for all generated files whether sharded, partitioned
or neither (i.e., we are consistent again!).
Contrary to attributes and types, this is the default, as
almost every dialect defines operations in ODS. Dialects without
operations, or that register them manually, set
`useDefaultOperationRegistration` to 0. `-op-registration-name` names the
hooks of dialects whose operations are generated from several files.
Dialects whose `initialize` would now be empty can set `hasInitializer`
to 0 instead of defining an empty one.
[9 lines not shown]
[mlir][ODS] Add partitions for attributes and types
Allow attributes and types to be grouped into named partitions, like
ops. Each def can set `partition` to a `Partition` record. Passing
`-attrdefs-partition=<name>` or `-typedefs-partition=<name>` to the
attrdef/typedef decls and defs generators then emits only the defs of
that partition. A large dialect can thus split its attributes and types
over several compilation units with narrower headers.
The implementation mirrors the approach used in op partitioning
with a `register<DialectClass>Attributes` function (or Types) is used to register every attribute (or type) of the dialect and dispatches to partition specific functions.
The `generated{Parser,Printer}` function saw the biggest change.
It is not generated as `generated<DialectClass>{Attribute,Type}{Parser,Printer}` which is a method with public linkage.
This method is also generated for non-partitioned dialects and the old `generated{Parser,Printer}` function soft-deprecated (but for now retained for migration purposes).
The additional testing, the test dialect's attributes and types are split into the
partitions `Core` and `Syntax`.
This roughly halves the compile time (15.1s -> 6.7s + 6.9s) and peak memory (721 MiB -> 385 and
376 MiB) of the largest test dialect attribute compilation unit.
[2 lines not shown]
[mlir] Fix scalable index handling and support scalable forall tiling (#235596)
Fixes https://github.com/llvm/llvm-project/issues/150203.
`tile_using_forall` accepts `tile_sizes [[8], 1]`, but the parser drops
the scalable flag and prints it back as `[8, 1]`. At `vscale = 2`, this
requests a tile size of 8 instead of 16. The bug changes the requested
tiling even when numerical results remain correct.
Preserve the flags in `scalable_sizes` and use the SCF tile-size
callback to materialize each nonzero scalable factor times
`vector.vscale`, after checking the target's tiling interface and tensor
semantics. Materialization happens separately for each payload target to
preserve SSA dominance across functions. Zero sizes remain untiled, and
omitted flags retain fixed-size behavior.
Parser overloads that cannot return scalable flags now diagnose scalable
indices instead of discarding them. Previously accepted markers in SCF
bounds and pack/unpack inner tiles are now rejected intentionally.
[28 lines not shown]
[BOLT][DWARF] Do not modify file name entries in CU line tables (#241862)
When rewriting a compile unit's line table, we should make sure that we
don't modify the file name list. In turn, this means that BOLT doesn't
have to update `DW_AT_decl_file` and `DW_AT_call_file` values when
rewriting debug info, as the same index should be used in both the input
and the output.
For this, we explicitly require that the same index is assigned to the
file name entries in the output table as in the input by passing a
non-zero index to `BinaryContext::getDwarfFile`.
Additionally, DWARF 5 requires that a compile unit's `DW_AT_comp_dir`
and `DW_AT_name` attributes match the corresponding directory and file
name entries in the CU's associated line table. However, input files may
not always have correct DWARF debug info.
Instead of relying on the inputs being correct, we should use the file
name from the input line table as the correct value so that we don't
[3 lines not shown]
Fix nits in the tests and MayFoldRegister's doc
MayFoldRegister's doc didn't name the operands it leaves out. In the tests,
the FastISel RUN lines in inline-asm-callbase.ll gave the same output as the
SelectionDAG ones, asm-constraints-rm-i686.ll had an unused CHECK prefix, and
the torture test's early-clobber cases had the "=m" cases' labels. The
pressure test scrubbed the stack offsets that show two operands sharing a
slot, and it didn't print the tied inputs, which show each tie keeping its
output's location.
Assisted-by: Claude Opus 5.5
Generate the checks for the tied fold tests
update_mir_test_checks.py can't check debugValueSubstitutions, so
debug_instr_number moves to its own test, which keeps its hand-written
checks, and the tied tests' checks are generated.
Assisted-by: Claude Opus 5.5
Give each asm in the error tests its own srcloc
Several functions report the same error, so their CHECK lines were
identical, and a change in which of them errors would go unnoticed. With a
!srcloc, each error names its asm's line.
Assisted-by: Claude Opus 5.5
Generate the peephole test's checks
The checks were written by hand. Generate them with update_mir_test_checks.py,
and drop the mayload from asm_may_store's asm, which its C source doesn't
produce. It still doesn't fold.
Assisted-by: Claude Opus 5.5
Update getFrameIndexOperands' example, and check its offset
The doc's example still showed the operand flag as a raw immediate, and it
didn't say where Offset goes. X86 also narrowed Offset to an int without
checking that it fits in a displacement.
Assisted-by: Claude Opus 5.5
[mlir][acc][test] Skip openacc-offload-objdump on Darwin (#245476)
The test added in #242808 pipes IR through `llc` without an explicit
triple, so on macOS `llc` picks the Mach-O backend and rejects the
hard-coded `.llvm.offloading` section name:
```
LLVM ERROR: Global variable 'device_module_binary' has an invalid section
specifier '.llvm.offloading': mach-o section specifier requires a segment
and section separated by a comma.
```
The LLVM offloading image packaging pipeline (section naming in
`OffloadWrapper`, image extraction in `OffloadBinary`, the linker
wrapper's objcopy calls) is currently built around ELF/COFF and has not
been adapted to Mach-O.
---------
Co-authored-by: Ivan R. Ivanov <iivanov at nvidia.com>