[InstCombine][NFC] Add test for existing fold (#181555)
Resolves #73417.
The fold described in #73417 is already present in LLVM `main`, but it
isn't tested for specifically. This PR adds a test for this fold, based
on the IR in the topmost comment of that issue.
[Github][libc] Use a container for fullbuild tests (#181436)
This avoids needing to set up deps every time and avoids failures due to
failed dependency installation.
Closed #150490.
[llubi] Add basic support for icmp, terminators and function calls (#181393)
Note: icmp with integers is also introduced in this patch, as it is
needed to compute branch conditions.
[RFC][IR] Remove `Constant::isZeroValue` (#181521)
`Constant::isZeroValue` currently behaves same as
`Constant::isNullValue` for all types except floating-point, where it
additionally returns true for negative zero (`-0.0`). However, in
practice, almost all callers operate on integer/pointer types where the
two are equivalent, and the few FP-relevant callers have no meaningful
dependence on the `-0.0` behavior.
This PR removes `isZeroValue` to eliminate the confusing API. All
callers are changed to `isNullValue` with no test failures.
`isZeroValue` will be reintroduced in a future change with clearer
semantics: when null pointers may have non-zero bit patterns,
`isZeroValue` will check for bitwise-all-zeros, while `isNullValue` will
check for the semantic null (which
may be non-zero).
[clang][Python] Use str.format instead of string concatenations (#173861)
This PR replaces string concatenations and the older `%` string
interpolation with `str.format`. Changes along those lines were
originally a part of #173845, but they were moved to a new PR,
where it was decided that `str.format` is preferable over
f-strings.
Changes in this commit are identical to
abf1d0bea04ab5d5ed1be3708ce1cd86707d5c8f, but commit title and
description were changed to correctly reflect the changes.
Revert "[clang][Python] Use fstrings instead of string concatenations (#173861)"
This reverts commit abf1d0bea04ab5d5ed1be3708ce1cd86707d5c8f,
because its title and description are entirely wrong.
f-strings is what was initially proposed, but then it was decided
to go with `str.format`.
[clang] Add explicit std::move(...) to avoid a few copies (#180478)
Moving an std::shared_ptr is always profitable (marginally).
Moving a clang::LayoutOverrideSource::Layout may be profitable depending
on the size of the underlying llvm::SmallVector.
Changes suggested by performance-use-std-move from #179467
[VPlan] Add VPSymbolicValue for UF. (NFC)
Add a symbolic unroll factor (UF) to VPlan similar to VF & VFxUF that
gets replaced with the concrete UF during plan execution, similar to how VF
is used for the vectorization factor. This is a preparatory change that
allows transforms to use the symbolic UF before the concrete UF is
determined.
Note that the old getUF that returns the concrete UF after unrolling has
been renamed to getConcreteUF.
Split off from the re-commit of 8d29d093096
(https://github.com/llvm/llvm-project/pull/149706) as suggested.
[AArch64] Decompose FADD reductions with known zero elements
FADDV is matched into FADDPv4f32 + FADDPv2f32p but this can be relaxed
when one element (usually the 4th) or more are known to be zero.
Before:
movi d1, #0000000000000000
mov v0.s[3], v1.s[0]
faddp v0.4s, v0.4s, v0.4s
faddp s0, v0.2s
After:
mov s1, v0.s[2]
faddp s0, v0.2s
fadd s0, s0, s1
[VPlan] Use VPlan::getConstantInt in a few more cases (NFC).
VPlan::getConstantInt() allows for slightly more compact creation of
VPIRValues wrapping ConstantInts.
[DAG] isKnownToBeAPowerOfTwo - add DemandedElts, OrZero arguments and support for zero constants (#181485)
Update the signature for isKnownToBeAPowerOfTwo methods to take
DemandedElts and OrZero arguments.
So far all I've done is add OrZero support for constants
(scalars/buildvector/splat), with the intention to incrementally extend
support in the future (or spread the work as beginner GFI patches).
Similarly the DemandedElts argument is currently only used for constant
build vector tests but support can be extended in future patches.
Fixes #178938
[TableGen] Combine FactorNodes and FactorScope. NFC
These were separated in 31db7afacf4dae051fcd0da22e440813663b61f3
due to the complexity of the rebindable unique_ptr. With the
switch to MatcherList, the code is not as complicated.
Reapply "[TableGen] Introduce MatcherList to manage a linked list of Matchers. NFC (#177875)"
With fixes to the slice_after functions to avoid dereferencing the
before_begin() iterator. Deferencing the iterator casts a pointer
to the BeforeBegin object to Matcher*, but the BeforeBegin object
is not a Matcher. This caused a failure when built with gcc.
Original commit message:
The previous memory management involved passing around references to the
std::unique_ptr next pointer in each Matcher. Scopes and
SwitchOpcode/SwitchType did not use std::unique_ptr internally, but
would sometimes need to have the pointers to their children moved to
temporary std::unique_ptrs that may be modified and then put back into
the Scope/Switch. Other code used manual deletion.
This patch introduces a MatcherList object that encapsulates list
management and ownership. The interface is based on std::forward_list
using the libcxx implementation for reference.
[15 lines not shown]
[ELF,PPC64] Inline toAddr16Rel and TLS remapping into the main relocate switch
Delete the toAddr16Rel helper and the GOT_TLS-to-GOT16 remapping switch,
inlining their val adjustments as fallthrough cases in the main switch.
This reduces relocate() from 4 switches on type to 2 (TLS relaxation
pre-switch with early returns, and the unified write switch).
[ADT] Fix RadixTree singular iterator use in findOrCreate (#181510)
The root node's Key is initialized with default-constructed (singular)
iterators. When findOrCreate calls llvm::mismatch(Key, Curr->Key) on the
first loop iteration where Curr is the root, these singular iterators
are passed to std::mismatch. _GLIBCXX_DEBUG correctly rejects them as
not forming a valid iterator range.
Skip the mismatch when Curr is the root node since its key is
conceptually empty, making the mismatch a no-op.
Fixes a test failure in ADTTests/RadixTreeTypeTest introduced by
5fda2a5d9c1a ("[NFC][ADT] Add RadixTree (#164524)").
[LV] Fix strict weak ordering violation in handleUncountableEarlyExits sort (#181462)
The sort comparator used VPDT.dominates() which returns true for
dominates(A, A), violating the irreflexivity requirement of strict weak
ordering. With _GLIBCXX_DEBUG enabled (LLVM_ENABLE_EXPENSIVE_CHECKS=ON),
std::sort validates this property and aborts:
Error: comparison doesn't meet irreflexive requirements, assert(!(a <
a)).
Use properlyDominates() instead, which correctly returns false for equal
inputs while preserving the intended dominance-based ordering.
This fixes a crash introduced by ede1a9626b89 ("[LV] Vectorize early
exit loops with multiple exits.").
[clang-tidy] Fix false positive for generic lambda parameters in readability-non-const-parameter (#179051)
Fixes #177354
### Summary
The `readability-non-const-parameter` check produces false positives on
generic lambda parameters, not fully resolved by #177345.
### Problem
Generic lambdas with explicit template parameters create dependent
contexts that cannot be analyzed at parse time:
```cpp
auto lambda = []<typename T>(int *p) {
T x(*p); // No longer warns
};
```