[UTC] Handle x86 vectorcall labels on Win32 (#235424)
Fixes #31744
`update_llc_test_checks.py` was unable to correctly handle decorated
function labels for `x86_vectorcallcc` functions targeting 32-bit
Windows. These labels can contain suffixes such as `@@0` or `@@4`, while
the function name in the assembly comment does not include the suffix.
This patch fixes the x86 assembly function-label regex to handle these
decorated labels correctly. It also adds a regression test covering
Win32 vectorcall functions with and without integer arguments.
### AI Usage
The root-cause analysis and proposed fix are my own work. I used an AI
assistant to help understand parts of the existing code, review my
changes, and assist with testing and debugging.
[IR] Add `alwaysuniform` function attribute (#214644)
The attribute indicates that the function's result is always uniform,
even when its inputs are divergent. This is a stronger guarantee than
nodivergencesource (which only promises the function doesn't introduce
new divergence) and is intended to be emitted by front-end and used by
UniformityAnalysis.
Specifically it allows marking a downstream front-end ballot function such
that the guaranteed uniformity of the result (of the call to the function)
allow optimization of a subsequent consumer.
[X86] Avoid combineSub cycle when ~C2 does not constant fold (#246346)
The X86 fold `sub(C1, xor(X, C2)) -> add(xor(X, ~C2), C1+1)` builds
`~C2` with `getNOT`. When `C2` is a bitcast of a build vector with undef
lanes, `~C2` doesn't constant fold, and the generic xor/add combines
turn the result back into the original sub, so the DAG combiner never
terminates. This only does the fold when `~C2` constant folds. On the
issue's IR, `llc -O2` (default and `-mattr=+sse4.1`) went from killed
after 60s to about 13ms, with no other X86 CodeGen test changes.
Fixes #246312
Assisted-by: Grok Bot (AI coding agent)
[libc] Fix has_zeroes() function not working with long Word type (#244197)
The LOW_BITS constant in the has_zeroes() function is an unsigned int,
which means if Word is a type larger than the platform's int e.g. a
long, then the block parameter will be truncated during the subtraction
operation. This results in zero bytes in the higher-order half not being
detected.
[CIR] Mark LoweringPrepare init functions strictfp
Classic codegen's StartFunction makes a function that has no
FunctionDecl `strictfp` when the TU-wide default FP environment is
constrained: FP exceptions are not ignored or the rounding mode is
dynamic. Of those functions ClangIR creates `_GLOBAL__sub_I_*`,
`_GLOBAL__I_*`, the C++20 module initializer, `__cxx_global_var_init*`,
`__cxx_global_array_dtor*` and `__tls_init`. It marked only
`__cxx_global_var_init*`, through a `strictfp` attribute on `cir.global`,
so the other functions and the calls in them were not `strictfp`.
Classic also marks the `__dtor_*` stubs, `_GLOBAL__D_a` and
`__GLOBAL_cleanup_*`, which ClangIR does not emit.
LoweringPrepare creates these functions after CIRGen, so it reads the
TU-wide default from `#cir.lowering_options`. `no_trapping_math` already
records whether FP exceptions are ignored, and the new `rounding_math`
field mirrors `LangOptions::RoundingMath`. It is omitted when false, so
the module attribute prints as before without `-frounding-math`.
`buildRuntimeFunction` adds `strictfp` together with the other TU-wide
[8 lines not shown]
[AMDGPU] Remove R600 usage from llvm tests. NFC (#245924)
Tests that only cover R600 are deleted, including the tests of the
`llvm.r600.*` intrinsics. In tests shared with GCN, the r600 RUN lines
and their now unused EG, CM and R600 checks and comments are removed,
and autogenerated checks are regenerated. The R600 cases in the yaml,
TableGen, TargetParser, Triple and DataLayout upgrade tests are removed
too:
```
; RUN: llc -mtriple=r600 -mcpu=redwood < %s | FileCheck -check-prefixes=EG,FUNC %s
```
The `llvm.r600.read.local.size.y/z` checks in `amdgpu.private-memory.ll`
are kept, because AMDGPUPromoteAlloca still emits them for non HSA
targets. A follow up patch removes the R600 backend code.
RFC: https://discourse.llvm.org/t/rfc-amdgpu-deprecating-and-removing-llvm-s-r600-terascale-backend/92840
Assisted-by: Claude Opus 5.5
[SystemZ] Enable update_llc_test_checks.py for HLASM on z/OS (#246417)
This change adds the required regular expression to match the HLASM
output generated for z/OS.
Assisted by: IBM Bob
[SimplifyCFG] Optimize switches on constant globals loads
This introduces a new `SimplifyCFG` fold that transforms switches on loads from
constant tables into loads from a new table, eliminating the switch.
The motivating example is in the new test `switch-to-table-1.ll`.
The fold is deliberately tried in every `simplifycfg` run to allow more
inlining after early runs of `simplifycfg`. When run, the fold converts a
`switch` to (in the worst case) a single `load` per PHI at the destination of
the `switch`. When the destination doesn't have any other incoming edges other
than the `switch`, the PHIs disappear completely. In all cases, the function
usually gets smaller, which allows more inlining.
(This fold reuses the `SwitchReplacement` code from the existing `SimplifyCFG`
folds, so it can also replace a PHI at the destination with a sequence of
arithmetic instructions or with a register-sized bitmap lookup.)
Code size impact of this pass comes from new globals, which we limit as
[7 lines not shown]
[Offload][Omp] Use olMemCpy3D in omp_target_memcpy_rect
Implement olMemCpyRect more generically in DeviceTy using the
accelerated olMemCy3D if supported by the device.
Use it to reimplement omp_target_memcpy_rect.
Assisted by Claude.
[mlir][tosa] Support CONV2D and CONV3D with EXT-DYNAMIC in tosa-to-linalg-named (#243377)
Support non-constant input tensor zero point (`input_zp`) and weight
zero point (`weight_zp`) operands for CONV2D and CONV3D in the
`tosa-to-linalg-named` pass. EXT-DYNAMIC allows these operands to be
non-constant.
For each non-constant zero point:
- Use `tensor.extract` to get the scalar value from the zero point
tensor
- If the zero point's type is `i8`, sign-extend the scalar to `i32` for
the quantized convolution
- Otherwise, for non-`i8` types, emit `cf.assert` to check that the
value is zero
- If the quantized convolution is used, pass an `i32` constant zero for
that operand
Use the input zero point scalar as the padding value.
[100 lines not shown]
[JumpTableToSwitch] Use ConstGlobalIterator to read jump table entries
Replace JTTS's own jump table parsing with the `ConstGlobalIterator` helper,
which is also used by instcombine's `foldCmpLoadFromIndexedGlobal`.
As a result JTTS now also handles GEPs without nusw/nuw flags, by masking the
index the same way instcombine does.
Note that the helper requires the indices to be in canonical index type, so
JTTS only works with canonical index types now. This is not a problem in
practice as JTTS only runs after instcombine.
[ARM][ConstantIslands] Fix CloserWater heuristic to resolve convergence failure in large functions. (#245139)
Fix two bugs in the `CloserWater` heuristic in `findAvailableWater` that
cause
the ARM constant island pass to fail to converge for large functions
with many
constant pool entries, aborting with:
LLVM ERROR: Constant Island pass failed to converge!
This was observed during LTO linking of large translation units where
PGO-driven
inlining produces functions with thousands of basic blocks and over a
hundred
constant pool references. The constant island pass exceeds its
30-iteration
convergence limit due to a cascade effect: each CPE placement shifts
subsequent
block offsets, pushing one more entry out of range per iteration.
[37 lines not shown]
[CIR] Mark calls in strictfp functions strictfp
At -O1, ClangIR folded `erf(1.0)` to a constant under
`#pragma STDC FENV_ACCESS ON`, while classic codegen kept the call. The
difference is the call-site `strictfp` attribute. LangRef requires it on
every call in a function that uses constrained FP intrinsics, and LLVM's
libcall folders look at the call, not at the caller. Classic codegen
gets it from IRBuilder's constrained mode. ClangIR marked only the
function.
The CIR `strictfp` function attribute now lowers to the `strictfp`
attribute of `llvm.func` instead of a `passthrough` entry. After the
conversion, every `llvm.call`, `llvm.invoke`, `llvm.inline_asm` and
`llvm.call_intrinsic` in a `strictfp` function gets `strictfp` too, and
every named intrinsic op such as `llvm.intr.fabs` or `llvm.intr.memcpy`
gets `llvm.strictfp`. That includes indirect calls, constrained
intrinsics, and the calls LoweringPrepare and EH lowering create. CIR
itself does not change.
[7 lines not shown]
[mlir][LLVM] Add llvm.strictfp for intrinsic ops
In a function that uses constrained floating-point intrinsics, LLVM
requires every call to be `strictfp`, including calls of intrinsics such
as `llvm.fabs`, `llvm.memcpy` and `llvm.trap`. The call ops and
`llvm.func` have an inherent `strictfp` attribute, but the named
intrinsic ops have no call-site attributes, so a frontend could not mark
those calls.
This adds a discardable `llvm.strictfp` unit attribute. Export sets the
`strictfp` call-site attribute on the call the op translates to, the way
`llvm.memprof` attaches to the calls an op produces, and import sets it
on an intrinsic op whose call site is `strictfp`. A new
`IntrinsicOpTrait` marks the LLVM dialect's intrinsic ops, and the
verifier accepts `llvm.strictfp` only on them, so the call ops keep a
single spelling.
Assisted-by: Claude Code (Opus 5.5).
[CIR][NFC] Generate isBitIntType from an ODS constraint
Add CIR_AnyBitIntType and define CIR_IsNotBitIntPred as its negation, so the
positive and negative _BitInt checks share one predicate. ODS now generates
cir::isBitIntType, replacing the hand-written helper from #245456. Restore the
dyn_cast<IntType> sites that need the IntType itself, since the generated
function does not accept a null type.
Assisted-by: Claude Code (claude-sonnet-5-5).
[Mips] Use the constrained compare mask directly on R6 (#246087)
On R6, a constrained FP compare is lowered to (and Mask, 1), where Mask
is the 0 or -1 result of cmp.cond.fmt. Selects, branches and sign
extensions can use Mask without the 'and' when ComputeNumSignBits shows
that it is 0 or -1, as they already do for non-strict compares. For
constrained compares this was not known, since STRICT_FPCmpR6 and
STRICT_FPCmpsR6 were not handled in ComputeNumSignBitsForTargetNode and
the low word of an f64 mask came from an EXTRACT_SUBREG. So they got an
extra 'andi', and the sign extensions a 'negu' as well.
Handle the strict compare nodes in ComputeNumSignBitsForTargetNode, and
take the low word of an f64 mask with ExtractElementF64, which it can
look through. The code is now the same as for non-strict compares.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>