[mlir][XeGPU] Fix parent permutation for sliced layout transposes (#245818)
When transposing a SliceAttr, the permutation over the visible dims was
lifted to the parent layout incorrectly: sliced (hidden) dims were
moved, but the slice dims were left unchanged, so the wrong parent dims
ended up hidden and the effective data distribution changed (even an
identity transpose altered the layout). Keep sliced dims fixed and
permute only the visible parent dims. Add a regression test for layout
propagation through a transpose and broadcast chain.
This change was created with the help of Claude.
---------
Co-authored-by: Claude <noreply at anthropic.com>
AMDGPU: Don't use PressureDiffs with implicit allocatable physregs (#230916)
canUsePressureDiffs skipped all implicit operands, so instructions
reading an allocatable physreg implicitly (e.g., vcc on v_cndmask_b32)
used the cached PressureDiff. PressureDiffs assume a single use for
physregs (see the FIXME in ScheduleDAGMILive::updatePressureDiffs), so
the pressure was added for each user. With several users in a region,
the SGPR pressure was overestimated and failed the expensive checks pressure
validation.
Fall back to the RegPressureTracker for implicit operands of
allocatable physregs, which are the ones it tracks.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
stdio: Fix negated wchar scansets
We were recording the start of the scanset before checking if it began
with a caret. We need to check for a caret first, then record whatever
comes next as the start of the scanset.
Note that scanf() did not have this bug, only wscanf(), but this adds
regression tests for both anyway.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D62328
(cherry picked from commit 71c723518d22b2ae9c9c7819aa2625af3532bba5)
stdio: Fix typo in scanset test
Fixes: 71c723518d22 ("stdio: Fix negated wchar scansets")
(cherry picked from commit c5917853354369d9537c5a5aee4f0d2854325ed4)
stdio: Handle unterminated scansets
In both vfscanf() and vfwscanf(), if the end of the format string was
reached before the closing bracket of a scanset, we treated the NUL as
the closing bracket and continued to read beyond the end of the format
string. Add an error check to catch this case.
MFC after: 1 week
Reported by: Nick L. Leppelmeier <nicklpmr at gmail.com>
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62199
(cherry picked from commit c5e0899d9908da5935cfaaade073d6911880fcb5)
stdio: Add test cases for scansets
Add test cases that exercise scanf() / wscanf() scansets, including
hyphenated ranges and the missing closing bracket bug we recently fixed.
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62201
(cherry picked from commit c24ab9f32d9bb63b426f346cb5f28c00e63922c2)
stdio: Implement ranges for wchar scansets
The C and POSIX standards allow but do not require hyphenated ranges to
be supported in scanf() / wscanf() scansets. We implemented them for
scanf() but not for wscanf(). Do so using similar logic as for scanf().
This is hard to do efficiently for wide characters, which can in theory
span the full 32-bit range (and even the actual range of about 1 million
Unicode codepoints is difficult to handle), so we don't try to be
efficient, but just focus on producing the same results for wscanf() as
for scanf().
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62200
(cherry picked from commit 50eb68efcb473c8c20c016d618a8cd674d3706dc)
stdio: Use correct comparison function
[2 lines not shown]
stdio: Fix negated wchar scansets
We were recording the start of the scanset before checking if it began
with a caret. We need to check for a caret first, then record whatever
comes next as the start of the scanset.
Note that scanf() did not have this bug, only wscanf(), but this adds
regression tests for both anyway.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D62328
(cherry picked from commit 71c723518d22b2ae9c9c7819aa2625af3532bba5)
stdio: Fix typo in scanset test
Fixes: 71c723518d22 ("stdio: Fix negated wchar scansets")
(cherry picked from commit c5917853354369d9537c5a5aee4f0d2854325ed4)
stdio: Implement ranges for wchar scansets
The C and POSIX standards allow but do not require hyphenated ranges to
be supported in scanf() / wscanf() scansets. We implemented them for
scanf() but not for wscanf(). Do so using similar logic as for scanf().
This is hard to do efficiently for wide characters, which can in theory
span the full 32-bit range (and even the actual range of about 1 million
Unicode codepoints is difficult to handle), so we don't try to be
efficient, but just focus on producing the same results for wscanf() as
for scanf().
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62200
(cherry picked from commit 50eb68efcb473c8c20c016d618a8cd674d3706dc)
stdio: Use correct comparison function
[2 lines not shown]
stdio: Handle unterminated scansets
In both vfscanf() and vfwscanf(), if the end of the format string was
reached before the closing bracket of a scanset, we treated the NUL as
the closing bracket and continued to read beyond the end of the format
string. Add an error check to catch this case.
MFC after: 1 week
Reported by: Nick L. Leppelmeier <nicklpmr at gmail.com>
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62199
(cherry picked from commit c5e0899d9908da5935cfaaade073d6911880fcb5)
stdio: Add test cases for scansets
Add test cases that exercise scanf() / wscanf() scansets, including
hyphenated ranges and the missing closing bracket bug we recently fixed.
MFC after: 1 week
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D62201
(cherry picked from commit c24ab9f32d9bb63b426f346cb5f28c00e63922c2)
[X86] Don't widen byte and word moves into reserved registers (#248669)
Upper bits of the 32-bit register can get clobbered by X86FixupBWInsts
widening a byte or word write for the stack pointer. For example,
```
%v = load volatile i16, ptr %p
call void asm sideeffect "", "{sp}"(i16 %v)
```
reaches the pass as a MOV16rm into $sp, which is widened to `movzwl
(%rdi), %esp` instead of `movw (%rdi), %sp`, overwriting bits 16-31 of
%rsp and clearing bits 32-63. Copies, loads, and 16-bit extends are all
affected.
getSuperRegDestIfDead now treats a reserved destination as live.
[X86] Add tuning for fast AVX2 vector FP division and sqrt (#219873)
Some microarchitectures have no significant performance penalty when using
256-bit `VDIVPS`/`VDIVPD` and `VSQRTPS`/`VSQRTPD` instructions instead
of their 128-bit counterparts.
Add the `fast-vector-fp256` tuning feature to model this behavior and
enable it for the C86-4G-M4 tuning configuration. The feature is also inherited by
the C86-4G-M6, C86-4G-M7, and C86-4G-M8 tuning configurations.
Other targets are intentionally left alone for now; they can be opted in
on a case-by-case basis as their tuning data becomes available.
## Changes
- Add the `TuningFastVectorFP256` subtarget feature.
- Add lower AVX2 TTI costs for 256-bit vector `fdiv`/`fsqrt` on targets with `fast-vector-fp256`:
- `fdiv v8f32`: throughput/latency from `14/21` to `7/13`.
- `fdiv v4f64`: throughput/latency from `28/35` to `14/20`.
- `fsqrt v8f32`: throughput/latency from `14/21` to `7/15`.
- `fsqrt v4f64`: throughput/latency from `28/35` to `14/21`.
clang/AMDGPU: Error on -mwavefrontsize64 for wave32-only targets
-mwavefrontsize64 was forwarded as +wavefrontsize64 regardless of the
support. Compiling rejected it later in the target setup, but the
assembler silently accepted it. Diagnose it in the driver instead.
Assisted-by: Claude
apex: add a driver for the Google Apex Edge TPU
The Apex is the accelerator on Coral PCI Express and M.2 modules,
appearing as 1ac1:089a
Google's Linux driver left staging in 5.16 and the out of tree
repository was archived; no BSD has had one.
Tested on: amd64, Coral M.2 Accelerator, running MobileNet v1
with the TensorFlow Lite 2.16 and LiteRT runtimes
Reviewed by: ziaee, adrian
Differential Revision: https://reviews.freebsd.org/D58563
gasket: add a framework for Google accelerator ASICs
Gasket is Google's name for the layer their accelerator drivers share:
Google ASIC Software, Kernel Extensions, and Tools. The chips differ,
but they present the same shape to the host. A control register BAR
with a few windows user space may map, an on-chip page table the host
fills in so the device can reach host memory, and a block of MSI-X
vectors.
Reviewed by: ziaee, adrian
Differential Revision: https://reviews.freebsd.org/D58561
[mlir][LLVM] Mark and/or/xor/fadd/fmul as Commutative (#248882)
LLVM IR treats Add, FAdd, Mul, FMul, And, Or and Xor as commutative
(Instruction::isCommutative()), but in the LLVM dialect only llvm.add
and llvm.mul carry the Commutative trait. As a result, CSE fails to
merge e.g. `llvm.and %a, %b` and `llvm.and %b, %a`.
Add the Commutative trait to the remaining ops.
Fixes: https://github.com/llvm/llvm-project/issues/248815