[SLP]Fix perfect diamond match for gather nodes with poison in the reuse mask
A poison constant in the gathered bundle leaves a poison lane in the
common mask; expanding the gather through that mask indexed the scalar
list with -1. Expand such lanes to poison instead.
Fixes #219833
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/219862
[ORC] Fix malformed Mach-O `__unwind_info` tables (#217781)
The malformed tables are produced by `JITLink` after compact-unwind
record merging.
`CompactUnwindManager::mergeRecords()` coalesces adjacent function
records with identical mergeable encodings. When the final raw record is
merged away, `writeIndexes()` generates the top-level index terminator
from the final remaining record instead of the final original function.
This truncates the final index range.
On macOS arm64, libunwind resolves a PC in the merged-away final
function through the terminator entry. Its second-level-page offset is
zero by design, causing libunwind to interpret the `__unwind_info`
header as a second-level page and report:
```
libunwind: malformed __unwind_info ... bad second level page
```
[20 lines not shown]
[RISCV] Lower vector i1-to-fp i1 to VSELECT 1.0/0.0 (#219426)
Previously, the i1 source was first extended to an integer type
whose width is half the destination floating-point width. The mask
extension was lowered by lowerVectorMaskExt to a VSELECT, or directly to
VMERGE_VL for fixed-length vectors, materializing an integer vector
containing 0 or 1.
Since an unsigned i1-to-floating-point conversion can only produce 0.0
or 1.0, recognize this operation earlier and lower it directly to a
VSELECT between the floating-point constants 1.0 and 0.0. This removes
the intermediate integer mask extension and the following widening
integer-to-floating-point conversion.
[SSAF][clang-reforge] Add end-to-end clang-reforge tests
- Make CppBoundedBuffers adapt to flattened WPA results;
- Let CppBoundedBuffers use qualified EntityNames so that it can
associate ASTNodes with WPA results;
- Add end-to-end tests
Final step of:
rdar://185840466
[SSAF] Flatten 'UnsafeBufferReachableAnalysisResult' to a plain set (#219041)
Previously, an 'UnsafeBufferReachableAnalysisResult' was organized as a
map from contributors to their mutually exclusive sub-results. Because
this extra layer of contributor information proved unnecessary, this
commit flattens the result into a plain set.
The source transformation expects the result to be a plain set, so this
is a prerequisite step for
rdar://185840466
[ADT] Use isComparableWith in StringMap (#219853)
This patch updates operator== in StringMap to use
DebugEpochBase::HandleBase::isComparableWith, bringing it in line
with DenseMap and FoldingSet.
Assisted-by: Antigravity
[mlir][affine] Update getSliceBounds to allow multi-result upper bound maps (#219369)
Resolve a long-standing TODO on supporting multi-result upper bound maps
on affine analysis utility getSliceBounds. This makes affine fusion more
powerful.
`getSliceBounds` threw away any upper bound that came out of more than
one inequality and put the constant bound in its place, under a TODO
saying it was conservative until `getConstDifference` in LoopFusion
could handle multiple bounds (b/126426796). Several inequalities is what
a destination loop clamped at the end of the data produces -- of a 1000
long dim tiled by 64, the region a tile reads is bounded by `min(%i * 64
+ 64, 1000)` -- and dropping that for the constant leaves `1000`, which
says only that the slice ends somewhere before the end of the data. A
slice of one 64-wide tile then costs as a slice of everything from the
tile onwards, and fusion refuses it as redundant computation that isn't
there.
Keep such a bound. It is already the min of its results, which is the
[12 lines not shown]
[ADT] Inline FoldingSetNodeID equality. NFC (#219856)
Every successful FoldingSet lookup pays the cost to call out-of-line
function, which calls memcmp. Just inline it.
[KnownFPClass] Refine known classes for `KnownFPClass::bitcast` (#215708)
`KnownFPClass::bitcast` should now be optimal (for ieee and bf16 types).
It is now able to correctly determine the `KnownFPClass` of any constant
value*. For non-constants, it is now able to rule out normal, and
subnormal results, in addition to ruling out specifically `qNaN`/`sNaN`
based off of the quiet bit.
I also added unit tests for `KnownFPClass::bitcast`.
AI Disclosure:
I used ChatGPT Codex (sol 5.6) to help generate the tests, which I
reviewed, built, and tested locally.
*Prior to this commit `KnownFPClass::bitcast` was unable to fully deduce
constants such as positive infinity:
```
/home/zerico/programming/llvm-project/llvm/unittests/Support/KnownFPClassTest.cpp:46: Failure
Expected equality of these values:
[6 lines not shown]
[KnownFPClass] Refine powi KnownFPClass deductions (#218581)
Adds deductions for when the `base` is known never negative-normal nor
negative-subnormal. Similar to the deductions added for `pow`
https://github.com/llvm/llvm-project/pull/215592.
AI Disclosure:
I used ChatGPT Codex (Sol-5.6) to help write tests, which I reviewed and
tested locally.
[ADT] Remove FoldingSet's void * insert position API (#219845)
FindNodeOrInsertPos/InsertNode/GetOrInsertNode/RemoveNode and the
encode/decode helpers behind them are gone; use
lookup/insert/getOrInsert/erase with FoldingSetInsertToken.
LLM-aided
[ORC] Drop redundant ExecutionSession& arg from lookupAndApply (#219797)
The ExecutionSession& can be retrieved from the first element of the
SearchOrder.
This changes behavior in a corner case: An empty SearchOrder always
fails on a non-empty PrepareFns list, even if all symbols added would
have been weakly referenced, because no ExecutionSession& is available
to intern the symbol names. An empty SearchOrder is pathological, so
this seems like a reasonable trade-off.
[RegAllocFast] Use getOneDef() in traceCopyChain(). NFC (#219850)
getUniqueVRegDef() finds one defining instruction, while getOneDef()
finds one def operand and is inlined.
(They differ for a register defined twice by one instruction but
RegAllocFast does not support that shape in defineVirtReg().)
[VPlan] Fold trivial bitcasts. (#219849)
Fold trivial bitcasts in VPlan. This avoids special handling when
constructing SCEV expressions (which folds such trivial casts), and
ensures we can close the gap between IR-based SCEV analysis and
VPlan-based SCEV analysis. This is important going forward to make sure
we can replace existing IR analysis without regressions.
[clang] Migrate remaining FoldingSet users to lookup/insert. NFC (#219844)
findSpecialization/AddSpecialization and their Decl.h wrappers stop
threading a `void *` through the AST, Sema, Serialization and CodeGen
callers. This is the last user of FoldingSet's `void *` insert position.
LLM-aided
[VPlan] Fix VPScalarIVStepsRecipe for FSub inductions. (#219214)
The lane offsets passed to the new VPScalarIVStepsRecipe always count
upwards (based on the canonical IV), independent of the induction
opcode.
Remove code incorrectly negating the lane offset for inductions with
FPSub opcode. The double negation caused incorrect results.
PR: https://github.com/llvm/llvm-project/pull/219214
[Clang][Driver] Revise Cygwin ToolChain to call linker directly (#147960)
...so that `libc++`, `compiler-rt`, and `libunwind` can be used by the
options: `-stdlib=libc++`, `-rtlib=compiler-rt`, and
`-unwindlib=libunwind` respectively. Along with this change, the test
for this driver is also trimmed a bit.
This is a followup patch for
https://github.com/llvm/llvm-project/commit/52924a2d7255cdd280b2b82dad8616e01fe065da.
---------
Signed-off-by: Takashi Yano <takashi.yano at nifty.ne.jp>
Co-authored-by: Jeremy Drake <github at jdrake.com>
Co-authored-by: Tomohiro Kashiwada <kikairoya at gmail.com>
[VPlan] Add tests for more address idioms not by VPlan's SCEV (NFC). (#219843)
Add tests gaps currently handled by IR based SCEV analysis, but not
VPlan-based SCEV analysis.
[ADT] Inline FoldingSet's equality dispatch (#219784)
FoldingSetBase compares nodes through a FoldingSetInfo table of function
pointers, which the compiler cannot inline through to the node's
Profile().
Add a probe() template taking the match test as a template parameter,
and build lookup, FindNodeOrInsertPos and getOrInsert on it in
FoldingSetImpl where the trait is known.
LLM-aided
[ValueTracking] Compute known bits for llvm.stepvector (#219779)
Teach ValueTracking to infer high zero bits for `llvm.stepvector` from
the
vector element count and a finite `vscale_range`.
Conservatively give up when the lane-count calculation overflows the
element
width, since `llvm.stepvector` truncates out-of-range lane indices.
This allows existing sign-bit reasoning to eliminate redundant
extensions for
bounded step vectors.
The regression tests cover scalable and fixed vectors, bounded and
unbounded
`vscale_range`, lane-index truncation, unconstrained inputs, and
signed-i32
boundary cases.
Fixes #219776.