[NVPTX] Expand lrint and llrint for f32 and f64 (#242764)
marks `(l)lrint` as Expand for f32/f64 on NVPTX.
they defaulted to LibCall, since NVPTX has no libm, they crashed.
now they use the generic FRINT + FP_TO_SINT expansion.
from #240078
AMDGPU: Add named ArgRange classes for common builtin operands (#242552)
Name the ranges shared by many builtins after the operand they
constrain: byte/word select indexes, scale_sel, f8f6f4 matrix formats,
and wmma neg flags on variants that do not support negation. NFC.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Use ArgRange for prefetch cache policy bounds (#242551)
Only the reserved th value check remains in Sema.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libclc][spirv] Add double support to Vulkan vstore_half/vstorea_half (#242829)
Implement `double` overloads for `vstore_half` and `vstorea_half` under
`cl_khr_fp64`. Round each element with the Vulkan boundary checks, then
forward it as `float` to the existing `vstore_half_N` and
`vstorea_half_N` helpers.
Prerequisite for google/clspv#1752; end-to-end tests will be added there
since `libclc/test` currently targets only AMDGPU.
I used AI assistance to prepare and review this patch.
I reviewed the entire change and take full responsibility for this PR.
Assisted-by: Antigravity Gemini 4 Hydrogen Extra reasoning
Assisted-by: Claude Code Opus 5.5 Max reasoning
[KnownFPClass] improve deductions for fadd_self (#239257)
`fadd_self` is just multiplication by two. I removed the call to
`fadd_impl` and replaced it with the optimal conditions to rule out each
class, which improved deductions around NaN, infinity, and normal
classes. These refinements are valid for all rounding modes.
`fadd_impl` could not rule out NaN if both infinities were possible for
`fadd_self`: `fadd` produces NaN for `+inf + -inf` and `-inf + +inf`,
which are both impossible for `fadd_self`.
I avoided using `ldexp` so we do not have to pass in the `APFloat`
semantics into `fadd_self`.
[SLP] Keep original type for values with non-demoted vectorized users
A vectorized user, which stays in the original type, consumes the
extension of the demoted value with the wrong upper bits and may keep
poison-generating flags. Keep sext/zext nodes, demoted below their source
width, in the original type for such users, and check the flags of these
users for other demoted nodes.
Fixes #242864
Pull-request: https://github.com/llvm/llvm-project/pull/242915
[VPlan] Don't pack predicated values only used as scalars. (#242903)
When only scalars are used, avoid the vector round trip by skipping
packing the scalars in a vector, and instead using them via their scalar
phis.
Add a helper to determine whether only scalars are used, to be re-use in
follow-up.
[CodeGen] Stop trailing debug instructions from changing liveness queries (#235667)
When `computeRegisterLiveness` exhausts its bounded forward scan on the
block's last ordinary instruction, a trailing debug instruction or
pseudo
probe leaves the iterator short of `end()`. The end-of-block successor
live-in check is missed, so the fallback scan can return `LQR_Live` or
`LQR_Unknown` where `LQR_Dead` is expected. In `X86FixupLEAs`, this
keeps a
two-address LEA instead of converting it to ADD.
Skip trailing debug instructions and pseudo probes before the
end-of-block
check. Extend the existing X86FixupLEAs MIR test with the exact
ten-instruction boundary. A C reproducer emits `leaq (%rax,%rsi), %rax`
with
`-g` and `addq %rsi, %rax` with `-g0`; the patch makes both use ADD.
This issue was found by a non-AI automated testing tool. AI assisted
with the analysis and development of the fix.
[ARM] Preserve Thumb1 compare elimination across debug instructions (#237505)
A debug value between a Thumb1 multiply and compare prevents the
existing `MULS/MOVS/MOVS/CMP` reorder. As a result, debug builds retain
a redundant compare that is eliminated without debug information.
Move the intervening `MOVS` instructions before the multiply instead of
moving the multiply past the debug value. This keeps debug values after
the definitions they describe while allowing the compare to be
eliminated.
Fixes #227925
This issue was found by a non-AI automated testing tool. AI assisted
with the analysis and development of the fix.
[X86] Mark vXi64 int to fp undesirable without AVX512DQ
Without avx512dq there is no vector conversion from i64 elements to f32
or f64, so widening the conversion of a source truncated with nsw or nuw
back to i64 makes it slower.
avx512fp16 converts i64 elements to f16 directly, so the widening folds
now pass the node and the check sees the result type.
Assisted-by: Claude Code Opus 5.5
[DAGCombiner] Mark uint_to_fp widened through trunc nuw as nneg
The source of a trunc nuw fits in a strictly narrower type, so it is
non-negative. Without nneg x86 lowers the widened conversion through the
unsigned i64 expansion.
Assisted-by: Claude Code Opus 5.5
[NFC][X86] Add tests for int to fp of a trunc nuw or nsw source
Without avx512dq a vector i64 source truncated with nsw or nuw is
converted one element at a time or through the unsigned i64 expansion.
A scalar source truncated with nuw takes the expansion without avx512f.
avx512fp16 converts i64 to half directly even without avx512dq.
Assisted-by: Claude Code Opus 5.5
[VPlan] Support non-constant steps for VPScalarIVSteps in getSCEVExpr (#242896)
The IV operand of a VPScalarIVStepsRecipe already advances by the
recipe's step in each iteration, so its SCEV is the recipe's value for
the first lane of the current scalar iteration, independent of the step.
Return it for any step, instead of only constant steps.
Also return SCEVCouldNotCompute for recipes with a start index, which
add StartIndex * Step. Start indices are only set by unrolling and
replication, after the users of getSCEVExprForVPValue that pass a loop,
so this is defensive and does not change behavior.
The only use is the VPlan-based cost model, and VPRelpicateRecipes fall
back to legacy cost model in fewer places with the change.
[LV] Add tests for predicated udivs used by replicated recipes (NFC). (#242895)
Add tests where a predicated udiv with various uses in different regions
and cost tests
[LAA] Add tests for miscompiles and monotonic bounds (NFC). (#242898)
Add a number of tests for cases where LAA currently computes incorrect
results: access size ignored in isSafeDependenceDistance, unchecked
dependences between multiple stores through the same pointer, and header
phis with a loop-varying latch value treated as forks.
Also add tests for non-affine pointers clamped with umin/umax/smin/smax
and zext, including cases that must not be bounded.
[KnownFPClass] Refine deductions for trunc/floor/ceil (#231368)
Follow up to https://github.com/llvm/llvm-project/pull/229982
Also refactors `KnownFPClass::roundToIntegral` to use the
`applyInputDenormalMode` helper.
[ValueTracking][KnownFPClass] Support constrained fadd/fsub (#241060)
Adds a rounding mode parameter to `KnownFPClass::fadd` and
`KnownFPClass::fsub` to support `constrained_fadd`/`constrained_fsub`
and `G_STRICT_FADD`/`G_STRICT_FSUB`.
[LV] Add test with hoisted loads using an IV with non-const step (NFC) (#242871)
Add a test checking the cost of complementary predicated loads that are
hoisted and whose address is based on an induction with a non-constant
step, which cannot be versioned.
[mlir][AMDGPU] Add preferAgpr hint to MFMA operations
The AMDGPU backend accepts the `!amdgpu.mfma !{!"agpr"}` instruction
metadata on calls to the `llvm.amdgcn.mfma.*` intrinsics (including
`llvm.amdgcn.mfma.scale.*`). The metadata is a hint that asks the backend
to allocate the accumulator input (C) and the result (D) of the MFMA to
AGPRs. The backend can ignore the hint, and dropping it does not change
program behavior.
Add an optional `preferAgpr` unit attribute to the ROCDL MFMA intrinsic
operations, including the scaled MFMA operations, and to `amdgpu.mfma` and
`amdgpu.scaled_mfma`. When the attribute is present, the translation to
LLVM IR attaches `!amdgpu.mfma !{!"agpr"}` to the intrinsic call, and the
AMDGPUToROCDL conversion copies the attribute to the ROCDL operation. When
the attribute is absent, the printed operations and the translated LLVM IR
are the same as before.
The SMFMAC operations do not get the attribute because the backend ignores
the hint on `llvm.amdgcn.smfmac.*`.
[5 lines not shown]
[llvm-strings] Add --unicode option
This commit adds the --unicode option from GNU strings to llvm-strings.
The options from GNU strings are supported, plus an additional option
value --unicode=utf8 to explicitly request UTF-8 output, similar to how
we also add an --encoding=utf8 option value to explicitly specify the
input is UTF-8.