[Mips][GlobalISel] Fix Big Endian lowering (#225972)
Flip on the big-endian switch in Mips call lowering. Fix split memory
piece placement, short-load bit extraction, and unaligned left/right
instruction offsets for big-endian targets.
Add BE/LE test coverage.
[AMDGPU] Simplify true16 SGPR folding (#226082)
Rewrite part of the SGPR folding "hack" from #128929 using
getChannelFromSubReg to avoid relying on the exact numbering of subreg
indices.
This also fixes a potential bug when folding a copy with no subreg on
the source operand like `%1:sgpr_lo16 = COPY %0:sgpr_lo16`. The old
implementation would have generated `%0.sub0:sgpr_lo16` which fails
machine verification.
Co-authored-by: Claude Opus 5 (1M context) <noreply at anthropic.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply at anthropic.com>
[flang] Lower loops whose branching is confined to their body structurally
Such a loop was classified separately by a previous change but still
lowered as a raw CFG, so its structured form was lost.
Lower it structurally instead, with its body folded into a region that can
hold the branching. The loop keeps its bounds on the op, so it remains
available to whatever transforms or parallelizes it. Only the body is
folded: the loop control statements are emitted as they are for any
structured loop, since a branch from outside may target either of them.
Loops an OpenACC or OpenMP directive owns are lowered the same way, so
they keep their form too.
[GlobalISel] Only narrow IEEE half in narrowScalarFPTOI (#223615)
narrowScalarFPTOI swaps a conversion for a narrower one plus an
extension, which is only valid if every finite value of the source fits
in the narrow type. The guard tests the width, so it also accepts
bfloat, which has float's exponent range.
Match LLT::float16() instead of LLT::scalar(16). Register types come
from LLT::floatingPoint(), which degrades to ANY_SCALAR without extended
LLTs, and an ANY_SCALAR LLT matches any scalar of the same size, so this
is unchanged on such targets. AArch64 and AMDGPU only narrow
LLT::float16() sources and WebAssembly does not narrow these at all, so
they are unaffected too.
[flang] Detect loops whose branching is confined to their body
A DO loop is classified as either structured or unstructured, and a single
raw branch anywhere in its body forces the loop -- and every construct
enclosing it -- onto the unstructured path.
That is stronger than necessary. A loop keeps its structured control flow
as long as its branching neither leaves its body nor enters it from
outside. Classify such a loop separately from a fully unstructured one.
This only classifies: lowering is unchanged. PFT dumps mark the new
classification with '~', which is what the tests key on.
[flang] Resolve an assigned GO TO's targets from the completed assign map
An assigned GO TO reaches any label ASSIGNed to its variable, and a label
list does not bound that: lowering allows a branch to any ASSIGNed label
whether or not the list names it. Branch analysis only sees the ASSIGNs
preceding the GO TO in program order, so the successors it records, and the
incoming branches derived from them, can be incomplete.
The symbol-to-labels map is complete once branch analysis has finished,
which is when the classification runs. Ask it for the full target set
instead of trusting the recorded successors, so a loop whose assigned GO TO
stays within its body is still recognised.
[flang] Record the evaluations that branch to each evaluation
The PFT records where each branch goes, but not where it comes from, so
asking whether anything branches into a construct means walking the whole
procedure.
Record the reverse edges beside the forward ones, and print them in PFT
dumps so both directions of the branch graph are visible.
[flang][NFC] Say which control successors are not incoming branches
The map records branches, not every control successor: a construct
transferring control between its own statements is not a branch
(F2023 11.2.1 p1), so the successors analyzeBranches sets directly are
absent from it. Say so, rather than calling the map a plain inverse.
[MC] Prevent multiplication overflow when calling `encodeULEB128` (#224647)
`encodeULEB128` takes its `Value` as a 64-bit integer but the
multiplication is done using 32 bits. This fixes two issues reported by
a CodeQL scan however it's unclear how realistic an overflow is in this
case.
[mlir] Fold interface-map trait packs without recursive templates (NFC) (#226084)
Count interface traits and insert their models with fold expressions.
This keeps insertion order and avoids two recursive template chains for
every registered operation.
Assisted-by: Codex
[clang][AArch64] Consolidate codegen tests for SVE's DUP intrinsics
This patch completes the migration of the tests from:
* clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_dup.c
to:
* clang/test/CodeGen/AArch64/sve/dup.c
`dup.c` covers all the cases previously tested by `acle_sve_dup.c`.
However, unlike `acle_sve_dup.c`, it was only tested as C. Add `-x c++`
RUN lines to provide the equivalent C++ coverage, including lowering
via CIR.
[mlir] Store OperationState property callbacks as function pointers (NFC) (#226083)
The property callbacks never capture state. Store their function
pointers directly instead of wrapping them in function_ref. This improve
slightly MLIR build time and generates slightly smaller binaries.
Assisted-by: Codex
[mlir] Fold operation trait lookup without a temporary array (NFC) (#226081)
Compare trait IDs directly in the generated pack expansion. This avoids
building and scanning a local array in every operation trait lookup.
Assisted-by: Codex
[mlir][ODS] Share optional operand and type parser logic (NFC) (#226066)
Move repeated optional operand and type parsing into out-of-line
helpers.
Generated parsers now reuse those helpers across operations.
This improves MLIR build time by avoid redundant compilation of these
helpers.
Assisted-by: Codex
[TargetFolder] Use getGetElementPtr() overload accepting DataLayout (#226068)
To directly construct the constant GEP in canonical ptradd form.
The test change is because this ends up canonicalizing the vector
GEP case as well, rather than just the scalar cases.
[WebAssembly] Remove per-invoke EH_LABEL handling (#226053)
Per-invoke `EH_LABEL`s are no longer emitted after #225903. This removes
code that handles per-invoke `EH-LABEL`s and removes them from mir
tests.
[flang][OpenMP] Fix crash in defaultmap(none) on structure constructors (#220994)
Fixes :
[https://github.com/llvm/llvm-project/issues/218929](https://github.com/llvm/llvm-project/issues/218929)
Flang was crashing when a target defaultmap(none:...) region contained a
structure constructor, like this:
```
program p
type t
end type
type(t) :: x
!$omp target defaultmap(none:aggregate)
x = t()
!$omp end target
end
```
The problem is in `IsOpenMPAggregate` and `IsOpenMPScalar`. When the
OpenMP attribute visitor walks the names in the region, it hits the t in
[7 lines not shown]
[AMDGPU] Look through readfirstlane/readlane in computeKnownBitsForTargetInstr. (#224275)
Currently, `computeKnownBitsForTargetInstr` in GISel and
`computeKnownBitsForTargetNode` in SDAG treats
`amdgcn.readfirstlane/readlane` as fully unknown, even though both just
return the data operand's value from some lane. This patch teaches it to
recurse into the data operand (operand 2) and reuse its known bits.
Thus, it unblocks known-bits combines (e.g. redundant_and) that see
these intrinsics while still generic.
[flang] Detect loops whose branching is confined to their body
A DO loop is classified as either structured or unstructured, and a single
raw branch anywhere in its body forces the loop -- and every construct
enclosing it -- onto the unstructured path.
That is stronger than necessary. A loop keeps its structured control flow
as long as its branching neither leaves its body nor enters it from
outside. Classify such a loop separately from a fully unstructured one.
This only classifies: lowering is unchanged. PFT dumps mark the new
classification with '~', which is what the tests key on.
[flang][NFC] Say which control successors are not incoming branches
The map records branches, not every control successor: a construct
transferring control between its own statements is not a branch
(F2023 11.2.1 p1), so the successors analyzeBranches sets directly are
absent from it. Say so, rather than calling the map a plain inverse.
[flang] Record the evaluations that branch to each evaluation
The PFT records where each branch goes, but not where it comes from, so
asking whether anything branches into a construct means walking the whole
procedure.
Record the reverse edges beside the forward ones, and print them in PFT
dumps so both directions of the branch graph are visible.
[libc++][docs] Mark LWG2727 Complete in LLVM 24 (#225606)
In 9853cb54d9d2684b27f0d0db89c00c2da7e31b88 and
672843a3f2ee2aaaed0463ec9064b6ccea2a5d4d, we implemented parallel
versions of `std::min_element`, `std::max_element`, and
`std::minmax_element` without adding incorrect `constexpr`. This
essentially implemented the resolution of LWG2727.
[flang] Lower loops whose branching is confined to their body structurally
Such a loop was classified separately by a previous change but still
lowered as a raw CFG, so its structured form was lost.
Lower it structurally instead, with its body folded into a region that can
hold the branching. The loop keeps its bounds on the op, so it remains
available to whatever transforms or parallelizes it. Only the body is
folded: the loop control statements are emitted as they are for any
structured loop, since a branch from outside may target either of them.
Loops an OpenACC or OpenMP directive owns are lowered the same way, so
they keep their form too.
[flang] Detect loops whose branching is confined to their body
A DO loop is classified as either structured or unstructured, and a single
raw branch anywhere in its body forces the loop -- and every construct
enclosing it -- onto the unstructured path.
That is stronger than necessary. A loop keeps its structured control flow
as long as its branching neither leaves its body nor enters it from
outside. Classify such a loop separately from a fully unstructured one.
This only classifies: lowering is unchanged. PFT dumps mark the new
classification with '~', which is what the tests key on.
[flang][NFC] Say which control successors are not incoming branches
The map records branches, not every control successor: a construct
transferring control between its own statements is not a branch
(F2023 11.2.1 p1), so the successors analyzeBranches sets directly are
absent from it. Say so, rather than calling the map a plain inverse.
[flang] Stop using Operation::getAttrs (NFC) (#223049)
Migrate FIR attribute copying and printing to the explicit inherent and
discardable attribute APIs.
Also upgrade the textual assembly to stop mixing inherent and
discardable attributes in the same dictionary.
This is part of a general migration to use the "new" properties-based
APIs and stop mixing discardable/inherent attributes, see #155475
Assisted-by: Codex
[Mips] Add sync instruction aliases (#225866)
These aliases are documented in the MIPS ISA Reference Manual. These
also exist in binutils and are declared to be part of the MIPS32R2 ISA.