[InstCombine] SimplifyDemandedVectorElts - add llvm.vector.shuffle handling (#245249)
Simplify the demanded elements of the mask operand using DemandedElts,
and use the mask's constant range to limit the demanded source elements.
This is the InstCombine equivalent of #244921.
Part of #244310
AI Note: I've used Claude Code to help me understand `InstCombine`
concepts and the codebase. The implementation and tests are my own.
[LangRef][llubi] Fix nsz handling for FP min/max intrinsics (#245117)
For FP min/max intrinsics and reductions, nsz only makes the order of
+0.0 and -0.0 non-deterministic and must not flip same-sign zeros. Clear
nsz before handleFMFFlags on inputs and handle opposite-sign zeros in
applyFPMinMax instead. Also clarify in LangRef that
llvm.vector.reduce.{fmaximum,fminimum} follow the same nsz semantics.
Fixes https://github.com/llvm/llvm-project/issues/233676
LLM used for test cases.
[AMDGPU] Don't unroll memcpy loops with sub-dword split accesses
If dword accesses aren't allowed at the copy's alignment, the unrolled
<64 x i32> loop is split into bytes, which causes heavy spilling. Only
unroll when dword accesses are allowed, and pick residual types the
alignment allows.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[BOLT][AArch64] Enable clustered branch relaxation by default (#234932)
Use clustered relaxation by default when code relocations are available,
and keep --relax-exp as a hidden alias. Without relocations, fall back to
local branch relaxation or stub-insertion pass unless clustered relaxation
was explicitly requested, in which case exit with an error message.
Allow clustered relaxation to handle short-range branches without
requiring the --compact-code-model option.
Move tests that are exclusive to stub-insertion pass into a separate folder.
Link with test/Inputs/stub.c in eh-frame-hdr.test and eh-frame-overwrite.test
to avoid external-call thunks, whose FDEs would prevent the unwind sections
from being rewritten in place when using clustered relaxation.
[AMDGPU][Clang] Support the RF inline asm constraint (#244752)
Accept the AMDGPU-specific "RF" (flat memory address) inline asm
constraint in clang and lower it to "^RF" in IR. The backend support was
added in #241996. The "m" constraint needs no clang change since it is
handled by the generic TargetInfo code.
Add Sema tests for valid and invalid uses of "RF", and CodeGen tests
checking the IR constraint strings for "RF" and "m". Document "RF" in
the AMDGPU section of LangRef.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Test byte conversion through an i16 funnel shift
Keep both byte conversions and a store of the funnel-shift result to exercise the combine through both shift directions.
[AMDGPU] Look through any_extend in cvt_f32_ubyteN combine
Fold a shift through an any-extend when the selected byte is within the width of the shift result. This avoids an extra shift when converting elements of an unaligned vector load expanded into smaller pieces.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Dispatch va_arg lowering via target CIRABIRewriteContext subclasses (#244977)
#244116 included `clang/CIR/Dialect/Passes.h` from
`TargetLowering/CIRABIRewriteContext.h` for `cir::CallConvTarget`,
pulling
in the generated `Passes.h.inc` (`MLIRCIRPassIncGen`) from a
higher-level
library and breaking builds when `CIRABIRewriteContext.cpp` compiles
first.
Keep `CallConvTarget` out of `TargetLowering` by dispatching non-ignored
`cir.va_arg` lowering through a virtual `expandVAArg` hook on
`CIRABIRewriteContext`, implemented by X86_64 and AMDGPU subclasses
selected in `CallConvLoweringPass` (matching the structure of #244729).
Fixes build failure on
https://lab.llvm.org/buildbot/#/builders/sanitizer-windows.
Assisted-by: Gemini
[SystemZ] Select WCEFB/WCELFB/WCFEB/WCLFEB for vector-element conversions
On z15, use the scalar-in-vector convert instructions when one side of
an i32<->f32 conversion already lives in a vector register:
* (s|u)itofp of an extracted <4 x i32> element -> WCEFB/WCELFB, using
VREPF first for elements 1-3.
* fptosi/fptoui whose i32 result goes into element 0 of a vector
(scalar_to_vector, insert into undef, or splat) -> WCFEB/WCLFEB.
This avoids the GPR round trip (vlgvf + cefbr, cfebr + vlvgf). GPR<->FPR
conversions and variable-index extracts are unchanged.
Also fix the dest/source operand types of VCFEB/VCLFEB/WCFEB/WCLFEB
(which were reversed) and VCEFB/VCELFB (v128g -> v128f).
Add vec-conv-04.ll and vec-strict-conv-04.ll, including negative and
z14 checks.
[RISCV][GISel] Add G_ORC_B opcode and reuse SelectionDAG isel pattern. (#245331)
Eventually, we should also add computeKnownBits support to match SDAG.
Assisted-by: Claude
libkern: Bitfield extraction: Stick to standard, separate sign extension
Rename signed_extend32() and signed_extend64() to
extract_signed_bitfield_32() and extract_signed_bitfield_64()
respectively, as these names more clearly describe what these functions
are doing and to make room for functions really doing sign extension.
Change implementation of extract_signed_bitfield_32() and
extract_signed_bitfield_64() to stop relying on GCC/clang-specific
implementation-defined behavior on right shifts of negative integers.
They now rely on two-complement arithmetic, which all machines we
support do, and which is the future direction for C (it is a requirement
since C23).
While here, separate the sign bit extension into sign_extend_32() and
sign_extend_64() respectively, as these could be useful on their own in
addition to serving to implement extract_signed_bitfield_32() and
extract_signed_bitfield_64().
[4 lines not shown]
[SandboxVec][LoadStoreVec] Support mixed-type load vectorization (#236647)
- Allow reinterpretation of same sized values in load vectorization. A
chain of mixed types such as {i32, float} or {double, i32, i32} is
loaded as a vector of integers (as chosen by
`VecUtils::getWidenedType())`, each original load is unpacked from the
lanes it occupies, and then reinterpreted back to its own type with
`SameSizeReinterpret::reinterpretValue()`.
- Chains involving a non-integral pointer are left alone, since such a
pointer cannot be recovered from an integer lane.
Stacked on #243765.
Co-authored-by: Cursor <cursoragent at cursor.com>
---------
Co-authored-by: Cursor <cursoragent at cursor.com>
[NFC][VPlan] More tests for VPlan-based stride speculation
For #182595.
`@predicate_simplification_unknown_to_scev` has been added to #182595
quite some time ago and likely can be considered reviewed already.
Two other `@*might_trigger_ub_if_not_guarded` are for the latest review
round.
[GlobalOpt] Copy byval arguments when evaluating calls (#241675)
Fixes #241245.
The Evaluator bound the actual argument of a byval parameter directly to
the caller's object. The callee should get a private copy, so a later
store to the global changed the parameter. In the issue, GlobalOpt
evaluated the static constructor and committed a wrong value.
getFormalParams now copies the pointee of a byval argument byte by byte
into a temporary global and binds the parameter to it, the same way the
Evaluator models allocas. A byte-wise copy keeps the padding and does
not depend on the layout of the type. If a byte cannot be read, for
example when the object holds pointers, or the object is larger than 256
bytes, it gives up on the call as before.
The test is reduced from the issue and its checks are added with
update_test_checks.py. The lit tests under Transforms/GlobalOpt pass.
NAS-145321 / 27.1.0 / Resolve container etc paths within the rootfs when setting the hostname
Read an existing etc/hosts relative to the container's rootfs, resolving
symlinks as the container itself would, and only if it is a regular file
of a reasonable size. atomic_write already refuses a symlink in the path
of the files it writes.
(cherry picked from commit f5093d9b4c8fe94c5bb88cfe40bc4f7747eaa685)
(cherry picked from commit 9d53b3c6f263908b5dc4c4d6d0d46ca611ad015b)
NAS-145323 / 27.1.0 / Only accept a report file name in audit.download_report
audit.export creates each report directly in the user's report
directory, so report_name must be a single file name. Refuse a name
that is empty, is "." or "..", or contains "/" or a NUL byte.
Open the report with safe_open, which refuses a symlink anywhere in
the path, and serve it from that file once it is confirmed to be a
regular file. This replaces the separate existence and file type
checks on the path.
(cherry picked from commit 73b9dd025a1d75ed63fd21491629804e3107af6a)
(cherry picked from commit f4adfef8346e919b5b65d8ccccf3f501ef3f53a1)
NAS-145324 / 27.1.0 / Check the resolved path in filesystem permission changes
filesystem.stat set realpath from the absolute path for anything that
was not itself a symlink, so it kept ".." components and symlinked
parent directories. Resolve the whole path, as the field's description
says. NFS share validation and vm.device.convert, which also use
realpath, now see the fully resolved path.
The path checks of filesystem.chown, filesystem.setperm and
filesystem.setacl matched that realpath by string prefix, without a
component boundary. Compare whole path components instead. The S3
bucket check no longer resolves the path a second time.
Also fix the schema name in the "Must be an absolute path" error.
(cherry picked from commit c0250bb7913c6d4b569d4536ec97f5938317894f)
(cherry picked from commit 66226d0b2af2c272f24e1f4cb67af27e1ab74974)
clk_fixed: partially revert and improve e495998e7c6d
Deferred initialization of the input clock was badly implemented and
did not work as expected. Resolve the parent clock eagerly during
attach (failing if it is not yet available) and keep deferred
initialization only for the optional GPIO and/or regulator used by
gated-fixed-clocks. Also clean up the softc layout, move GPIO
configuration into the getter, and make the file FDT-only.
Reported by: llm-postcr
Fixes: e495998e7c6d ("FDT, clk_fixed: add gated-fixed-clock support and deferred initialization")
MFC with: e495998e7c6d