Revert "[Clang] Fix assertion "unsigned range includes negative?" in AnalyzeComparison during Sema of vector comparison with mismatched signed/unsigned types and __builtin_convertvector " (#225389)
Reverts llvm/llvm-project#182627
Post-commit CI found issues:
https://lab.llvm.org/buildbot/#/builders/225/builds/19103
[lit] Use text mode when opening text files on z/OS (#217434)
On z/OS, we rely on autoconversion to read files correctly, and this
requires files to be opened as text.
The following change https://github.com/llvm/llvm-project/pull/208024
changed the streams to be read and piped as binary resulting in some
test regressions due to unreadable output. This patch restores the
functionality of opening and reading as a text stream.
[Clang] Fix assertion "unsigned range includes negative?" in AnalyzeComparison during Sema of vector comparison with mismatched signed/unsigned types and __builtin_convertvector (#182627)
The ``TryGetExprRange`` function now checks if the operand is an unsigned
vector when computing the ranges.
Fixes #173614
[IR] Add ConstantExpr::getGetElementPtr() accepting DataLayout (#224652)
This overload takes GEP indices but produces a canonical i8 GEP in
ptradd representation. This is intended as a simple migration path for
places currently using `ConstantExpr::getGetElementPtr()` which cannot
be trivially replaced by `ConstantExpr::getPtrAdd()`.
This method is fallible, because something like `(getelementptr i32, ptr
@p, i64 CONST_EXPR)` can't be represented in ptradd form, because there
is no multiply constant expression. Not supporting this for constant
expressions is intentional, as we would not be able to emit a
relocatable expression for this anyway.
I have migrated a couple of sample usages in this PR. These are all
simple usages where the fallibility is not relevant.
The further plan here is to migrate everything (including IRBuilder) to
this new API, and then deprecated the one without the DataLayout
argument.
[AMDGPU][InstCombine] Fold zero dot operands to accumulator
Fold AMDGPU dot intrinsics when either operand is zero.
`dot(a, 0) = 0` and `dot(0, b) = 0`, so replace the intrinsic with its accumulator.
This avoids unrelated clamp and add/sub reassociation cases.
[AMDGPU][InstCombine] Canonicalize dot constant operands
Move constant dot product source operands to the right hand side
and add tests for signed and unsigned dot intrinsics.
[AMDGPU][InstCombine] Fold constant add/sub into the dot accumulator
`amdgcn.{s,u}dot{2,4,8}(a, b, C) +/- K -> dot(a, b, C +/- K)` when both the
accumulator C and K are constants. The new constant is computed with
wrapping APInt arithmetic to match the non-clamping accumulate.
Only applies when clamp is false (the saturating accumulate does not
reassociate) and the dot has a single use. K - dot is left alone since it
would need the dot product negated.
TargetParser: Move triple to CMake system name mapping into CMake
Reimplement the triple -> CMAKE_SYSTEM_NAME derivation added in #208773
entirely in CMake, dropping the Python script it introduced.
The previous mechanism widened TRIPLE_OS/TRIPLE_ENV in TripleName.def with
a CMake system name column and parsed it from a Python helper invoked by
CMake at configure time. Two problems motivated this rework:
- The CMake system name is a property of CMake (and can vary by CMake
version), not of llvm::Triple, so it does not belong in the shared
triple name table. The C++ never consumed the added column.
- Invoking Python from CMake at configure time is an unwanted build
dependency, and the Python-driven lit test broke Windows bots where the
interpreter path contains a space.
Revert the TripleName.def/Triple.cpp column back to the two-argument
macros, delete the Python script and its unittest, and reimplement the
mapping as a self-contained pure-CMake module. The classification still
[6 lines not shown]
[X86] Fix null dereference in optimizeCompareInstr after lzcnt/tzcnt (#224282)
#210069 added `LTZCNTInst` to the exit condition of the backward scan of
`optimizeCompareInstr()`:
```c++
if (MI || Sub || LTZCNTInst)
break;
```
but it assigns `MI = LTZCNTInst` only inside the *forward* scan's
"EFLAGS is
used by this instruction" branch. When the forward scan never reaches
that
branch, both `MI` and `Sub` stay null.
However later code was built on the idea that one of them is not null.
Added a MIR test that would crash before but gets fixed by this
additional check.
Used AI for code review and comment/PR/test formatting/writing
[SLP]Fix APInt assertion in emitReusedOps for narrow types
The repeat count of a reused scalar may not fit the reduction element
type (e.g. count 2 in i1), tripping the APInt isUIntN assertion when
building the to-mul scale constant. Truncate the count to the element
bitwidth; the modular reduction arithmetic keeps the result equivalent.
Fixes #225279
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/225376
[flang][cuda] Record implicit pinned attribution in module files
Under -gpu=mem:pinned an unattributed ALLOCATABLE is attributed as pinned by
the compiler, the same way -gpu=mem:managed attributes one as managed, but
only the latter recorded that it had done so. The module file therefore spelled
an implicitly applied PINNED the same as one the user wrote, and a reader
treated it as a user requirement: adding -gpu=mem:pinned to a module's build
rejected its OpenACC-only consumers over an attribute the user never wrote.
Record the attribution for pinned as well, so it is written as
PINNED(IMPLICIT) and consumers can tell the two apart.
[flang][cuda] Record implicit managed attribution in module files (#224601)
An implicit attribute the compiler applied under `-gpu=mem:managed` is
written into the module file the same way a user-written one is, so a
reader cannot tell them apart. It then treats the attribute as a user
requirement: allocating such a component in a DEVICE object is rejected,
and the memory space the user did ask for on the object no longer wins.
Spell the distinction in the module file as `MANAGED(IMPLICIT)`,
modelled on `INTENT(IN)`: CUDA-data-attr gains an optional parenthesized
qualifier, carried by a new CUDADataAttrSpec parse-tree node in AttrSpec
and ComponentAttrSpec. ATTRIBUTES(...) keeps the bare attribute, so the
qualifier cannot be written there.
The attribute itself is still written out, so a component keeps the same
memory space no matter which options a consumer is compiled with.
Also stop an implicitly applied attribute from making a module a definer
of CUDA symbols. Without this, adding `-gpu=mem:managed` to a module's
build rejects its OpenACC-only consumers over an attribute the user
never wrote.
[SLP]Fix SCEV type mismatch when a checked base crosses a cross-width addrspacecast
getUnderlyingObject strips addrspacecast, so a base object can have a
different address type than the access pointer, mixing SCEV types in the
bounds computation.
Fixes #225280
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/225374
[clang][bytecode] Add a bytecode RUN line for constant-builtins-2.c (#225305)
So changes to this file correctly trigger changes to the bytecode
interpreter.