[AMDGPU] Read TTMP6 only if clusters are enabled
The hardware only initializes TTMP6 when clusters are enabled, but
`llvm.amdgcn.cluster.workgroup.{id,max.id}.{x,y,z}` and
`llvm.amdgcn.cluster.workgroup.max.flat.id` read it without a check, so they
could potentially return stale values without clusters. The programming model
treats a launch without clusters as an implicit 1x1x1 cluster, so all of these
values are 0.
Fixes LCOMPILER-3241.
This PR was assisted by AI but I reviewed all the changes.
[AArch64] Use 64-bit registers for wide FP and vector "r" operands
An fp128 or a 128-bit vector, such as a <2 x double>, in an "r" operand
was still given 32-bit registers, so half of its bits were lost, as with
an i128 before. Give it 64-bit registers too.
Assisted-by: Claude Opus 5.5
[Clang][AArch64] Don't warn about a 128-bit "r" operand
Clang warned that a 128-bit value in an "r" operand didn't fit its
register and suggested %w. But the value takes two X registers, and %H
names the second, so don't warn about it.
Assisted-by: Claude Opus 5.5
[AArch64] Add the H modifier for the second register of a 128-bit operand
A 128-bit integer in an "r" operand takes two X registers, but an asm
could name only the first, so it couldn't use the other half. GCC has
the H modifier for this, so support it too.
Assisted-by: Claude Opus 5.5
[VPlan] Don't look through FOR splices in isUsedByLoadStoreAddress. (#233141)
isUsedByLoadStoreAddress incorrectly looked through recurrence splices.
This lead to makeVPlanMemOpDecision incorrectly replicating loads
(instead of widening), while the address is converted to a single-scalar
by legacy decision.
This fixes a miscompile in the added test.
(cherry picked from commit 22a203c0a2120105eaa78f45305f8f04a363cf14)
[LV] Add test for miscompiles with histograms and scalarization. (#233135)
Add 2 additional tests for miscompile with stores to invariant addresses
and histograms and incorrectly scalarizing loads feeding a first-order
recurrence.
Also modernize check lines while touching the tests.
(cherry picked from commit 25fc6f0b7ca9f01d94c0e2fa9f469a47e463c675)
[InstCombine] Fold exp(subnormal) and exp(+inf) to x + 1.0 (#243862)
Fixes #243132
- Folds `exp(subnormal)` to `1.0` in `SimplifyDemandedUseFPClass` since
any subnormal floating-point value evaluated with `exp`, `exp2`, or
`exp10` rounds to `1.0` in default rounding mode.
- Folds `exp(zero | subnormal | +inf | nan)` to `x + 1.0` (`fadd x,
1.0`). Note that `-inf` is excluded because `-inf + 1.0 = -inf !=
exp(-inf) = 0.0`.
- Adds test coverage across `exp`, `exp2`, and `exp10` in
`simplify-demanded-fpclass-exp.ll`.
[CIR] Implement PromotableRegionOpInterface for `cir.if`,`cir.scope` and `cir.ternary` (#215780)
mem2reg gives up on a slot if any use lives in a nested region whose
parent op doesn't implement PromotableRegionOpInterface. No CIR op
implements it. So this doesn't promote:
```mlir
%a = cir.alloca "a" align(4) : !cir.ptr<!s32i>
%c = cir.const #cir.int<42> : !s32i
cir.store %c, %a : !s32i, !cir.ptr<!s32i>
cir.if %cond {
%v = cir.load %a : !cir.ptr<!s32i>, !s32i
cir.call @use(%v) : (!s32i) -> ()
}
```
You have to run -cir-flatten-cfg first, which is why mem2reg.cir does.
That's a lot of destruction for a value that never leaves the region.
This implements the interface for cir.if and cir.scope. Both regions are
entered straight from before the op, so they see the reaching definition
[20 lines not shown]
RuntimeLibcalls: Add attributes to __kmpc_alloc_shared and __kmpc_free_shared (#244499)
Match the attributes OpenMPIRBuilder gives these declarations.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV] Make clang's -mcpu=help and -mtune=help accurate for RISC-V. (#243697)
Clang has multiple -mtune only CPU names like -mtune=sifive-7-series.
These should not be printed by -mcpu=help. There also RV32 and RV64 only
CPUs.
Previously we used the -mcpu=help from LLVM's MC layer to print the
names, but it doesn't have this granularity of information.
This patch special cases RISC-V in the clang driver to get the lists
from RISCVTargetParser. A new -print-supported-tune-cpus option is added
to request the tune CPU list. -mtune=help aliases this option.
The behavior for other targets is unchanged. Though X86 has similar issues
and should probably use X86TargetParser.
Assisted-by: Claude
RuntimeLibcalls: Add attributes to __kmpc_alloc_shared and __kmpc_free_shared
Match the attributes OpenMPIRBuilder gives these declarations.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[ARM] Split vector store of constantpool loads (#242865)
Given a store(buildvector(constants)) it can be more efficient to
materialize the constants and store individually with stm / strd, to
avoid the extra constant pool load. The SLP vectorize will generate such
a pattern and instead of adjusting the cost, this adds a combine to
scalar to address all examples where this can be generated. Loop
invariant loads can be excluded, and whilst the cost model isn't perfect
but can be improved in the future if needed.
[NFC][Attributor] Move fptrunc_round Attributor tests to their own file. (#244492)
Also renamed the tests since I plan to refine the KnownFPClass based on
the rounding mode.