[mlir][vector] Record the positive lower bound of vscale (#241919)
According to the
[docs](https://mlir.llvm.org/docs/Dialects/Vector/#vectorvscale-vectorvectorscaleop)
in the Vector dialect, `vscale` is a positive integer value, so it is at
least 1.
I was working on a patch that touches value bounds and noticed this gap.
For example, the following cannot currently reify a constant lower
bound:
```sh
build/bin/mlir-opt --pass-pipeline='builtin.module(func.func(test-affine-reify-value-bounds,canonicalize))' <<'MLIR'
func.func @vscale_lower_bound() -> index {
%vscale = vector.vscale
%lb = "test.reify_bound"(%vscale) {type = "LB", constant} : (index) -> index
return %lb : index
}
MLIR
[17 lines not shown]
[InstCombine][JumpTableToSwitch] Make a helper for iterating globals elements
Currently there are at least two folds/passes that read elements of a constant
global:
- instcombine's `foldCmpLoadFromIndexedGlobal`
- jump-table-to-switch, when reading the functions from a jump table
and a third one is being written for simplifycfg in PR #229035.
The code to do that is not trivial, especially in its most general form. The
two implementation above currently have different limitations, and PR #229035
has yet another buggy and limited implementation of it.
This PR adds a helper class `ConstGlobalIterator` that analyzes a load from a
global and allows iterating the accessed elements. Current implementation is a
copy of the instcombine's: that's the most general version we have today
(though even that has limitations, e.g. it gives up when the stride is smaller
than the load size).
[11 lines not shown]
[InstCombine] Simplify foldCmpLoadFromIndexedGlobal calls (NFC) (#242818)
Instead of checking the load's address operand at each call site, check
it once in foldCmpLoadFromIndexedGlobal.
[libc][math] disable ddivf128 smoke-test for GPU targets (#242831)
addresses the issue reported in
https://github.com/llvm/llvm-project/pull/242651#issuecomment-6895016120
by temporarily disabling the smoke test for GPU targets until a fix is
landed, with a TODO note to re-enable it afterward
[X86] Add WritePack scheduler classes (#240819)
Split off PACKSSUS DW/WB instructions from WriteShuffle class to remove
need for most custom overrides
znver4 - fixes failure to override rm variants to correctly use FPU1/2
pipes like the rr variants
SapphireRapids and C864GM7/8 - still have overrides for their predicated
instructions - best to leave them until #240761 is finalized.
Fixes #240425
[InstCombine][JumpTableToSwitch] Make a helper for iterating globals elements
Currently there are at least two folds/passes that read elements of a constant
global:
- instcombine's `foldCmpLoadFromIndexedGlobal`
- jump-table-to-switch, when reading the functions from a jump table
and a third one is being written for simplifycfg in PR #229035.
The code to do that is not trivial, especially in its most general form. The
two implementation above currently have different limitations, and PR #229035
has yet another buggy and limited implementation of it.
This PR adds a helper class `ConstGlobalIterator` that analyzes a load from a
global and allows iterating the accessed elements. Current implementation is a
copy of the instcombine's: that's the most general version we have today
(though even that has limitations, e.g. it gives up when the stride is smaller
than the load size).
[11 lines not shown]
[InstCombine] Simplify foldCmpLoadFromIndexedGlobal calls (NFC)
Instead of checking the load's address operand at each call site, check
it once in foldCmpLoadFromIndexedGlobal.
[mlir] Add LabelLike trait for blocks entered without a CFG edge
Some ops mark a block that control enters through a jump the CFG does
not show yet. ClangIR's cir.label is the target of cir.goto, which may
leave a region and only becomes a branch once the CFG is flattened.
Such a block often has no predecessors, so eraseUnreachableBlocks
deletes it and the greedy driver skips its ops.
This adds OpTrait::LabelLike for an op that starts a non-entry block,
and findLabelEntry, which returns the op where control enters a block
through a label. That is either the label itself or an op whose regions
contain one, unless that op, or one between it and the label, is
isolated from above.
eraseUnreachableBlocks keeps these blocks, the blocks they reach and the
blocks whose values they use. Region DCE treats every remaining block as
live, and cf.br does not merge a labeled block into its predecessor.
GreedyRewriteConfig::enableRewritingAfterLabels, off by default, lets
[7 lines not shown]
[mlir][bufferization] Do not hoist copying allocations to out-params (#242630)
With `hoist-static-allocs` enabled, `-buffer-results-to-out-params`
replaces returned allocations with caller-provided output buffers and
erases their defining operations. Checking only `AllocationOpInterface`
also matches `memref.realloc` and `bufferization.clone`, whose results
preserve or reproduce existing data. Erasing these operations loses that
data and leaves the output buffer partially or entirely uninitialized.
Require `getHoistingKind() != HoistingKind::None` before replacing an
allocation. `memref.realloc` (`None` since #231608) and
`bufferization.clone` (`None` by default) are retained. For the static
results in #242611, the pass copies their contents into the output
parameters through the existing fallback path. `memref.alloc` remains
eligible for replacement.
The check remains interface-based, preserving support for custom
allocation operations introduced in #120288. Such operations remain
eligible when they report a non-None hoisting kind.
[12 lines not shown]
[lld/mac] Claim per-file work one item at a time (#242765)
This ports #240094 to lld/MachO.
Relocation processing in lld/MachO doesn't need an index, so this can
use parallelForFineGrained instead of parallelForSharded() in lld/ELF.
Linking Chromium Framework on an M4 Max (time trace scopes, median of
7):
Parse relocations: 115 ms -> 75 ms
Apply linker optimization hints: 36 ms -> 22 ms
Total link (hyperfine, median of 15): 3.911 s -> 3.859 s
No behavior change.
[mlir][docs] Add guidance on "non observable" side effect modeling (#242620)
Mention that a dialect defines which aspects of execution are observable
and which are
implementation details outside that semantic model. Also add a few
examples.
Discussion:
https://discourse.llvm.org/t/guidance-on-not-observable-side-effect-modeling/92790
Assisted-by: Codex
[VPlan] Build SCEV of VPDerivedIVRecipe like its expansion (NFC). (#242804)
Compute the SCEV of a VPDerivedIVRecipe as Start + zext-or-trunc(Index)
* Step, matching expandVPDerivedIV. Previously Start and Step were
truncated or sign-extended to the type of Index, so the SCEV had Index's
type rather than the recipe's, and VPScalarIVStepsRecipe truncated it
back. Remove that truncate.
All derived IVs queried today have an Index at least as wide as Start,
where both forms fold to the same SCEV.
[ConstantFolding] Use the pointer width for ptrtoint of inttoptr (#237878)
Previously, folding `ptrtoint (inttoptr C)` truncated C to the address
width and dropped the non-address bits; use the pointer width instead.
Fixes #235642.
Assisted-by: Claude Opus 5.5