[AggressiveInstCombine] Guard memset with length in [0, 1] (#213240)
Use computeKnownBits to identify nonconstant memset lengths whose
possible values are limited to zero and one. The check is integrated
into the existing instruction loop in foldUnusualPatterns via the
dedicated helper foldMemSetZeroOrOneLength.
Insert a conditional branch around the memset and specialize the
executed path to a constant length of one. A following InstCombine
pass can then replace it with a byte store, including for a
nonconstant fill value.
Do not transform wider ranges such as [0, 2].
Fixes #213027.
Assisted by GPT-5
[ARM] Emit llvm.clear_cache for __clear_cache() (#223398)
It looks like the ARM-specific __clear_cache() builtin emits different
IR than the generic __builtin___clear_cache() builtin (added later),
which uses the llvm.clear_cache intrinsic (which will typically lower to
a __clear_cache libcall, of course).
Use llvm.clear_cache for __clear_cache() as well, for consistency and to
slightly simplify the code.
snd_uaudio: Read the UAC2 sample rate back after setting it
Some devices only apply a new sample rate once it has been read back,
and produce no sound at all otherwise.
PR: 294803
Reported by: tatsuki_makino at hotmail.com
Tested by: tatsuki_makino at hotmail.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D59616
[ARM] Add Neon costs for vrev shuffles (#223310)
This, like for AArch64 and MVE, allows some of the legal vrev shuffle
masks to be costed as if they are a single instruction, which can help
prevent the mid end from deoptimizing the code.
[CMake] Prune dead and unnecessary try_compiles from config.h (#223600)
Several config-ix checks either have no consumer or can be performed
directly by the source that needs the feature. Remove six compiler
invocations from a typical Linux configure:
* HAVE_PTHREAD_MUTEX_LOCK has been unused since LLVM switched its mutex
implementation to std::recursive_mutex in 2019.
* The Linux magic-header results have never been propagated to config.h,
so CMake builds already use Path.inc's fallback constants.
* FE_ALL_EXCEPT and FE_INEXACT can be tested directly after including
cfenv.
* The Valgrind and CrashReporter headers can be detected with
__has_include in their only consuming translation units.
Also remove the obsolete definitions from the GN and Bazel
configurations.
In a fresh minimal LLVM configure, CMake profiling attributed 2067.1 ms
[3 lines not shown]
[X86] Move ISD::FP_TO_*INT_SAT actions to be with a Subtarget's other ops. (#223657)
Don't treat them differently to the general pattern we try to keep to
based on grouping each Subtarget abilities - they shouldn't allow
soft-float either.
Cleanup to reduce diff in #199416
Reject recursive permissions changes on S3 bucket mountpoints
filesystem.chown, filesystem.setperm and filesystem.setacl now refuse
a recursive change whose path is the mountpoint of a dataset consumed
by an S3 bucket, or that would traverse into one from above. The error
points the caller at the bucket's s3data directory instead, since a
recursive change over the whole bucket may have undefined behavior and
expose security risks.
[AArch64] Reuse SUBS results for conditional subtraction (#223391)
For C++ code such as:
uint64_t conditional_subtract(uint64_t x, uint64_t q) {
return x - (x >= q ? q : 0);
}
AArch64 currently uses three instructions for the conditional
subtraction (omitting the return):
cmp x0, x1
csel x8, x1, xzr, hs
sub x0, x0, x8
The comparison already computes x - q to set the condition flags, but
its arithmetic result is discarded. Preserve that result with SUBS and
select between it and x, reducing the sequence to two instructions:
[9 lines not shown]
[LLVM] Add llvm.[su]mulh intrinsics. (#220293)
These intrinsics correspond to (un)signed multiply-high operations. The
motivation for introducing them is to allow more accurate costing
(particularly for vectorisation) and to simplify code generation for
chained multiply-high operations.
Together with subsequent patches to combine and cost the intrinsics,
this gives an 8% speedup on 750.sealcrypto_r on Neoverse V2.
[VPlan] Append recipes created via builder to worklist
The previous PR appended the top most created recipe to the worklist, and this PR extends it to any other nested recipes that were created, similar to InstCombine.
This removes the header mask in a good few more places on RISC-V as measured on SPEC CPU 2017, e.g. for the following loop:
```c
long f(const int *p, const int *q, long n) {
long a = 0, b = 0;
for (long i = 0;; i++) {
if (p[i] && q[i]) { a += i; b += i; }
if (i + 1 == n) break;
}
return a + b;
}
```
Before:
[49 lines not shown]
Switch to SmallVector with space on stack
SmallVector allows for much larger small sizes than SetVector, so use 256 to match InstructionWorklist.
We don't need to worry about duplicate worklist entries until we add users to the worklist.
[VPlan] Process simplifyRecipes in a worklist
This brings simplifyRecipes further in line with InstCombine, and asides from unlocking more simplifications it also helps avoid spurious test churn whenever passes are moved around simplifyRecipes.
For now just push the new recipe onto the worklist, not its users.
This uses a post order traversal so we maintain the same simplification order as before.
I've gone through and checked every simplification we do is a canonicalisation that converges, and I checked on llvm-test-suite + SPEC CPU 2017 in various configurations that we don't hit any cycles.