[mlir][bufferization] In OptimizeAllocationLiveliness optimize `dealloc` placement for unused `alloc`'s (#227975)
Addresses issue https://github.com/llvm/llvm-project/issues/227363
As of this PR (https://github.com/llvm/llvm-project/pull/229296). The
position of the `dealloc` was correctly, and safely moved within
`OptimizeAllocationLiveliness`.
Issue https://github.com/llvm/llvm-project/issues/227363 raises a missed
optimization where if the `alloc` is unused, and the only other
reference to that memory buffer is a `dealloc` the optimization is not
run. This PR fixes this.
When a `lastUser` does not exist, implying the `memref` is unused, we
can just hoist the `dealloc` to be as close to the `allocOp` as possible
[AVR] Allow ICALL and IJMP on the reduced cores (#241840)
This patch fix a crash when using function pointer on AVRTiny devices,
for which llvm would emit `icall`.
Signed-off-by: Mintsuki <mintsuki at protonmail.com>
[AutoUpgrade] Add textual IR upgrade of alias scope domains (#241786)
Alias scope domains that have no disjointness flag are implicitly
non-disjoint. Bitcode upgrade functionality was already in #218768; we
move it from `MetadataLoader` to `AutoUpgrade`, to invoke it from
`LLParser::validateEndOfModule`. The alias scope lists are discovered by
iterating over the instructions in the module.
The existing upgrade test file can be used for both upgrade paths. The
test of the bitcode upgrade relied on a (non-upgrading) llvm-as
translation of the textual source; this is replaced by a checked-in
bitcode translation (made using LLVM 21.1.8).
[InstCombine] Clarify fixpoint error message (NFC) (#241889)
Give more detailed instructions on what to do when encountering this
error. Emphasize that no issue should be filed.
[mlir][bufferization] Narrow the call aliasing rule in BufferViewFlowAnalysis to memrefs (#240508)
In `BufferViewFlowAnalysis`, a call op's results are unconditionally
treated as possible views of its operands, regardless of their types.
This change narrows the rule to memrefs: a result is a possible view of
an operand only when both are memrefs. This rule is consistent with the
rest of the analysis, which recognizes only memrefs as buffers.
Without it, `optimize-allocation-liveness` counts a use of a call's
scalar result as a use of the buffer the call received, and places the
dealloc after that use instead of after the call.
Before #229296 the pass moved the free past the `func.return` on the new
test case and produced invalid IR.
Assisted-by: Claude
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[IRBuilder] Always create at least one GEP in CreateGEP() (#241925)
This makes the behavior more consistent with CreatePtrAdd etc, which
will not implicit drop a zero-offset ptradd. This will avoid additional
churn when switching callers to CreatePtrAdd in the future.
This also reduces the risk of breaking caller assumptions, in particular
that CreateGEP will always return either a constant or a
GetElementPtrInst (unless InstSimplifyFolder is used).
[LoongArch][NFC] Move XOR combine into performXORCombine (#242151)
Extract the inline ISD::XOR handling in PerformDAGCombine into a
dedicated performXORCombine helper, matching how the other opcodes (AND,
OR, SETCC, ...) are structured. No functional change.
Also fix a clang-format issue in emitPseudoVMSKCOND.
Assisted-By: LLM
[clang][CIR] Add tests for SVE RINTI intrinsics (#240757)
adds CIR tests for svrinti (plain SVE) intrinsics.
Moves and adapts `sve-intrinsics/acle_sve_rinti.c` to `sve/rinti.c`
Part of #223963
[clang][CIR] Add tests for SVE RINTX intrinsics (#241369)
adds CIR tests for svrintx (plain SVE) intrinsics.
Move sve-intrinsics/acle_sve_rintx.c to sve/rintx.c and add
CIR checks for all f16/f32/f64 variants with _z/_m/_x predication.
Part of #223963.
Co-authored-by: Ente Wang <ente.wang at h-partners.com>
[ConstantRange] Handle llvm.{sshl,ushl}.sat (#242178)
Wire up ConstantRange::intrinsic() to sshl_sat and ushl_sat, restricting
their shift range to [0, BitWidth).
Alive2: https://alive2.llvm.org/ce/z/9WSZqW
[flang] Check the kind of subscript, bound, extent, and length expressions (#239633)
Expr<SubscriptInteger> no longer encodes the kind in its type, so
nothing guarantees anymore that subscripts, triplets, substring bounds,
cosubscripts, array bounds, extents, and character lengths have kind
SubscriptIntegerKind. Add IsSubscriptIntegerKind() helpers and CHECK the
kind where such expressions are stored, so that a missing conversion is
caught in the front end instead of surfacing later in lowering.
[MLIR][NVVM] Add support for scaled n1 ue8m0 and ue5m3 packed Convert Ops (#239189)
This patch adds support for `scaled::n1::ue8m0` to existing
`f32/f16x2/bf16x2`
to `FP8` (`e4m3x2`, `e5m2x2`), `FP6` (`e2m3x2`, `e3m2x2`) and
`FP4` (`e2m1x2`) convert Ops.
This also adds support for `ue5m3x2` to `f16x2/bf16x2` and
`ff/f16/bf16` to `ue5m3` in existing convert Ops.
Lit tests are added to verify the lowering to the intrinsics.
Negative tests are also added to check the error-handling of invalid
combinations.
PTX ISA Reference:
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvt
---------
Signed-off-by: DharuniRAcharya <dharunira at nvidia.com>
[Transforms] Remove AssumeSimplify pass (#241939)
This removes the AssumeSimplify pass, which is part of the
KnowledgeRetention framework and not enabled by default.
Our general direction has been to instead simplify assumes directly as
part of other passes like InstCombine instead, and we generally don't
plan to further pursue the KnowledgeRetention framework in its current
form, so this deletes the pass.
If we wanted to have a dedicated assume simplification pass, we would
reimplement it from scratch without using KnowledgeRetention APIs
anyway.
X86: Reuse the last subtarget for functions with same attributes
Add a utility for caching subtarget lookups. This returns the last
subtarget without building the subtarget key if the function has the
same attributes or same subtarget-relevant attributes as the last
query. RISCV and AArch64 already do something similar, and this
utility should be adopted across the targets (customized to the
relevant attributes). Also find the subtarget attributes in one
scan.
CTMark instructions executed, geomean: O3 -0.26%, ThinLTO -0.26%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[APFloat] Support user defined bit conversions (#240920)
[APFloat] Support user provided conversion to/from bits
This change allows users to provide custom functions to convert to/from
bits.
- fltSemantics has function pointers for conversion and user provided
values of it are supported
- built-in semantics also use these instead of chained if, making the
code less repetitive and slightly faster
- APFloat/IEEFloat internals like types and ranges of significand,
mantissa etc. can only be accessed using FloatRepr interface so only
user defined bitcast functions will be affected by changes
Resubmitted #233961 with fixes for GCC 7