[AArch64][CodeGen] Fold tbx(splat(0), table, idxs) to tbl(table, idxs) (#214268)
When the destination/background vector of a TBX instruction is a splat
of zero, the operation is equivalent to a TBL instruction. TBL
implicitly zeroes out any elements where the index is out of bounds,
matching the behavior of TBX with a zero background vector.
This patch adds a DAG combine to optimize this case, reducing
instruction latency and register pressure.
Fixes #214077
[X86][AsmParser] Support parentheses around scale and index register in Intel syntax (#211003)
Old patterns and why they broke
- Decisions matching (CurrState, PrevState) tuples (e.g. CurrState ==
IES_REGISTER && PrevState != IES_MULTIPLY)
to gate committing a register to Base/Index aren't paren-transparent:
any (...) turns CurrState into IES_RPAREN, so the tuple stops matching
and
`[reg + (reg)]`, `[reg + (reg*2)]`, `[reg + 2*(reg)]` fell through the
guards.
- Duplicated commit blocks. Recognizing whether a register is Base or
Scale was placed in four
handlers (onPlus, onMinus, onRBrac, onRParen), forcing onRParen to
replay it just to catch (reg).
- Scale was committed immediately in onInteger; a parenthesized scale
like (2) * 4 or 2 * (4)
had nowhere to accumulate.
[19 lines not shown]
[analyzer] Fix -analyzer-output=html assert on reversed and macro ranges
HTMLDiagnostics::HighlightRange guarded against a reversed range by
comparing line numbers, so a same-line reversal - which is what the piece for
an implicit copy constructor carries - reached html::HighlightRange.
Its scan walks from begin to end, ran off the end of the buffer, and asserted:
https://godbolt.org/z/sTb5qfjjd
Invalid position to insert! (RewriteRope.h)
It also added the end token's length itself and then passed a token range to
html::HighlightRange, which measured the token again, this time from the
interior. For most tokens the two cancel, but where the tail re-lexes longer
the highlight reached past the end of the range, e.g. over a trailing ';'.
Use getExpansionRangeInFile(), which rejects reversed and cross-file ranges,
then convert once and tell html::HighlightRange the range is already
char-granular.
[4 lines not shown]
[NFC] Add missing <cmath> and <limits> includes across llvm, mlir, lldb, flang, and bolt (#214410)
This is basically a continuation of
https://github.com/llvm/llvm-project/pull/214349...
This change adds missing `#include <cmath>` and `#include <limits>`
headers to several files across `llvm`, `mlir`, `lldb`, `flang`, and
`bolt`.
In commit
https://github.com/llvm/llvm-project/commit/ada3786e91ca2058f3ac8255a024c12ae7d263ee,
`<random>` stopped transitively pulling in the top-level `<cmath>`
header in favor of internal granular `<__math/...>` headers.
Multiple files across the codebase were implicitly relying on transitive
`<cmath>` inclusions from headers like
`llvm/Support/RandomNumberGenerator.h` and other headers that pull in
`<random>`. I'm explicitly adding the missing dependency.
### Affected Files
[16 lines not shown]
[AMDGPU][GlobalISel] Pre-commit tests for readanylane merge regbank combine (NFC)
Add regbank-combiner tests covering a copy to vgpr whose source is a
merge or build_vector of G_AMDGPU_READANYLANE results and uniform
values. These currently keep the round trip through sgprs, and also
cover the cases where the merge has another user and where all merge
sources are uniform.
Co-authored-by: Cursor <cursoragent at cursor.com>
[analyzer] Fix -analyzer-output=sarif crash on macro-expanded ranges
A path piece whose range ends inside a macro expansion aborted the whole
document: https://godbolt.org/z/61vWYcsWj
Cannot create a physicalLocation from invalid SourceRange!
convertTokenRangeToCharRange() built the end with
Lexer::getLocForEndOfToken(), which returns an invalid location for a macro
ID that is not at the end of its expansion, and used it unchecked. The
analyzer's own test corpus hits this in nine files; text and plist output
were unaffected because both already map such ranges to the expansion.
- Use getExpansionRangeInFile(), so the region covers the macro use like the
other two outputs.
- Fall back to a caret when the range is unusable. A thread flow needs a
location per piece, so dropping one would truncate the reported path. This
also stops reversed ranges producing regions with endColumn < startColumn.
[4 lines not shown]
[clang] Reject ranges getExpansionRangeInFile cannot represent
getExpansionRangeInFile was extracted verbatim and inherited two shortcomings
of the original loop, fixed here before the analyzer's SARIF and HTML consumers
depend on it:
- It mapped the end with getExpansionRange(SourceLocation), which always
reports a token range, so a char-range input was widened by a whole token.
Now using the getExpansionRange(CharSourceRange) overload, which keeps the flag.
- It passed reversed ranges through. Consumers walk begin->end; now returning
nullopt for those, as Lexer::makeFileCharRange already does.
Separate from the extraction so that stays NFC, and out of the consumer fixes
because it changes the shared helper's contract rather than one output.
Both contract changes, plus the invalid- and cross-file-range guards, are
covered by a GetExpansionRangeInFile unit test in
clang/unittests/Frontend/TextDiagnosticTest.cpp.
Assisted-By: claude
[Hexagon] Do not sign extend the unsigned comparison of short integers. (#212914)
HexagonTargetLowering::LowerSETCC widens i8/i16 SETCC operands to i32
with a sign extension when the extension is free, or when the compared
constant is negative in the narrow type. That is what the compare
instructions want for equality comparisons, since they can encode small
negative immediates, but for unsigned comparisons a constant with the
sign bit of the narrow type set becomes a large 32-bit value that has to
be materialized in a register or use a constant extender. For
%v = load i16, ptr %p
%c = icmp ult i16 %v, 65524
we generated
r1 = #-12
r0 = memh(r0+#0)
p0 = cmp.gtu(r1,r0)
[14 lines not shown]
[clang][NFC] Extract getExpansionRangeInFile out of the diagnostic renderers
Prep for the following commits, which fix crashes in the analyzer's SARIF and
HTML output on ranges that end inside a macro expansion. Fixing them means
mapping such a range into the reported file - the normalization the frontend
text and SARIF renderers already do, and that the two analyzer consumers each
do differently and incorrectly.
Hoist that logic into getExpansionRangeInFile, beside the DiagnosticRenderer
base both frontend renderers derive from, so the fixes reuse one
implementation instead of adding two more copies. TextDiagnostic and
SARIFDiagnostic move onto it here with no behavior change; the analyzer
consumers follow in later commits.
getFileID() replaces SARIFDiagnostic's getDecomposedLoc(...).first - equivalent
here, and what TextDiagnostic has used since c113cbb51005.
Assisted-By: claude
[AMDGPU][LibCallSimplify] Use target type's float-semantics in `ConstantFP::get` (#213721)
Compiler was crashing with:
```
Constants.cpp:1124: static llvm::ConstantFP* llvm::ConstantFP::get(llvm::Type*, const llvm::APFloat&):
Assertion `Ty->getScalarType() == Type::getFloatingPointTy(Cont ext, V.getSemantics()) &&
"ConstantFP type doesn't match the type implied by its value!"' failed.
```
Since the code was quite similar to `getConstantFloatVector`, I've ended
up modifying its implementation to also handle scalars and renamed it.
vmd(8): reject empty IMSG_VMDOP_LOAD messages from clients.
Reject empty values (either zero bytes or a single NUL) to prevent
zero-sized allocations, out-of-bounds write of a NUL byte, and
incorrectly triggering a reload event.
Report and original diff by Andrew Griffiths.
ok hshoexer@, mlarkin@