llvm-project/llvm
Matt Arsenault 42098c4a30 GlobalISel: Fix legalization error where CSE leaves behind dead defs
If the conversion artifact introduced in the unmerge of cast of merge
combine already existed in the function, this would introduce dead
copies which kept the old casts around, neither of which were deleted,
and would fail legalization.

This would fail as follows:

The G_UNMERGE_VALUES of the G_SEXT of the G_BUILD_VECTOR would
introduce a G_SEXT for each of the scalars.

Some of the required G_SEXTs already existed in the function, so CSE
moves them up in the function and introduces a copy to the original
result register.

The introduced CSE copies are dead, since the originally G_SEXTs were
already directly used. These copies add a use to the illegal G_SEXTs,
so they are not deleted.

The artifact combiner does not see the defs that need to be updated,
since it was hidden inside the CSE builder.

I see 2 potential fixes, and opted for the mechanically simpler one,
which is to just not insert the cast if the result operand isn't
used. Alternatively, we could not insert the cast directly into the
result register, and use replaceRegOrBuildCopy similar to the case
where there is no conversion.

I suspect this is a wider problem in the artifact combiner.
2022-01-18 17:04:40 -05:00
..
benchmarks
bindings Fix forward for "signed version of createExpression" 2021-12-27 13:51:59 +01:00
cmake Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs." 2022-01-16 05:48:30 +00:00
docs [AMDGPU][NFC] Add DWARF extension support for SIMD execution 2022-01-18 17:36:39 +00:00
examples [llvm] Use `GNUInstallDirs` to support custom installation dirs 2022-01-08 00:47:31 +00:00
include GlobalISel: Fix legalization error where CSE leaves behind dead defs 2022-01-18 17:04:40 -05:00
lib [DAG] Extend SearchForAndLoads with any_extend handling 2022-01-18 21:03:08 +00:00
projects
resources
runtimes [runtimes] Remove LLVM_ENABLE_LLD 2021-12-17 15:03:57 -08:00
test GlobalISel: Fix legalization error where CSE leaves behind dead defs 2022-01-18 17:04:40 -05:00
tools Handle whitespace in symbol list 2022-01-18 14:34:40 -06:00
unittests [llvm] Remove uses of `std::vector<bool>` 2022-01-18 18:20:45 +01:00
utils [gn build] Port df51be85e4 2022-01-18 17:28:57 +00:00
.clang-format
.clang-tidy
.gitattributes Adding gitattributes for split-file tests 2022-01-18 15:37:18 -06:00
.gitignore
CMakeLists.txt Update LLVM CMakeFiles to include BOLT 2022-01-11 21:19:12 -08:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.