llvm-project/llvm
Sanjay Patel 97a4e7b7ff [InstCombine] remove a buggy set of zext-icmp transforms
The motivating case is an infinite loop shown with a reduced test from:
https://llvm.org/PR51762

To solve this, I'm proposing we delete the most obviously broken part of this code.

The bug example shows a fundamental problem: we ask computeKnownBits if a transform
will be profitable, alter the code by creating new instructions, then rely on
computeKnownBits to return the same answer to actually eliminate instructions.

But there's no guarantee that the results will be the same between the 1st and 2nd
calls. In the infinite loop example, we get different answers, so we add
instructions that conflict with some other transform, and we're stuck.

There's at least one other problem visible in the test diff for
`@zext_or_masked_bit_test_uses`: the code doesn't check uses properly, so we can
end up with extra instructions created.

Last, it's not clear if this set of transforms actually improves analysis or
codegen. I spot-checked a few targets and don't see a clear win:
https://godbolt.org/z/x87EWovso

If we do see a regression from this change, codegen seems like the right place to
add a cmp -> bit-hack fold.

If this is too big of a step, we could limit the computeKnownBits calls by not
passing a context instruction and/or limiting the recursion. I checked that those
would stop the infinite loop for PR51762, but that won't guarantee that some other
example does not fall into the same loop.

Differential Revision: https://reviews.llvm.org/D109440
2021-09-09 08:49:39 -04:00
..
benchmarks
bindings [NFC][C API] Make LLVMSetInstrParamAlignment's index param type LLVMAttributeIndex 2021-09-07 15:13:45 -07:00
cmake [CMake] Don't add -Wnon-virtual-dtor if affected by GCC PR102168 2021-09-07 23:36:47 -07:00
docs [ObjC][ARC] Use the addresses of the ARC runtime functions instead of 2021-09-08 11:58:03 -07:00
examples [examples] Fix Kaleidoscope for Windows 2021-08-19 13:20:51 +10:00
include [OptParser] NFC: Remove unused template arg 'name' from bool opt 2021-09-09 12:04:40 +00:00
lib [InstCombine] remove a buggy set of zext-icmp transforms 2021-09-09 08:49:39 -04:00
projects
resources
runtimes [libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available 2021-08-30 17:32:11 +02:00
test [InstCombine] remove a buggy set of zext-icmp transforms 2021-09-09 08:49:39 -04:00
tools [yaml2obj][COFF] Allow variable number of directories 2021-09-09 11:16:56 +01:00
unittests [APInt.h] Reduce the APInt header file interface a bit. NFC 2021-09-08 18:17:07 -07:00
utils [gn build] Make lldb build on Windows 2021-09-09 08:13:50 -04:00
.clang-format
.clang-tidy
.gitattributes Fix: [MCParser] Correctly handle CRLF line ends when consuming line comments 2021-08-17 16:16:19 +01:00
.gitignore
CMakeLists.txt [CMake] Add targets for generating coverage reports 2021-09-03 10:45:55 -05: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.