23890 Commits

Author SHA1 Message Date
chenglin.bi
10c3df728c [Instcombine] Canonicalize ~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
https://alive2.llvm.org/ce/z/JHN2p4

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D139299
2022-12-07 23:52:07 +08:00
Chenbing Zheng
463e9be1d4 [InstCombine] Add tests for (X << Z) / (X * Y) -> (1 << Z) / Y. nfc 2022-12-07 17:06:11 +08:00
Nikita Popov
ed76074173 [LICM] Remove custom isInstInList() implementation (PR59324)
We already collect all instructions that need to be promoted. The
custom isInstInList() implementation could provide incorrect
results if a new use of the original pointer was introduced as
part of promotion. This probably cannot happen with normal code,
because of the pointer capture, but it can happen with a null
pointer.

Fixes https://github.com/llvm/llvm-project/issues/59324.
2022-12-07 09:51:35 +01:00
Roman Lebedev
ea7ad8b365
[NFC][SimplifyCFG] Add more fold-branch-to-common-dest tests 2022-12-07 03:32:42 +03:00
Florian Hahn
9eda78107c
[ConstraintElim] Fix sort order to not comparing insts in different bbs.
Update the sort order to make sure that comesBefore is never used from
conditional facts, which are instructions but may use DFS numbers from
different blocks.

This fixes a crash in the added test on some platforms.
2022-12-06 23:47:24 +00:00
Felipe de Azevedo Piovezan
62b27f893e [CodeExtractor] Correctly propagate scope information post extraction
When a new function "NewF" is created with instructions extracted from
another function "OldF", the CodeExtractor only preserves debug
line/column of the extracted instructions. However:

1. Any inlinedAt nodes are dropped.
2. The scope chain is replaced with a single node, the Subprogram of NewF.

Both of these are incorrect: most of the debug metadata from the
original instructions should be preserved. We only need to update the
Subprogram found at the scope of the last node of the inline chain; this
Subprogram used to be OldF but now should be NewF.

Differential Revision: https://reviews.llvm.org/D139217
2022-12-06 14:26:06 -05:00
Sanjay Patel
71df24dd39 [InstCombine] fold add-carry of bools to logic
((zext BoolX) + (zext BoolY)) >> 1 --> zext (BoolX && BoolY)
https://alive2.llvm.org/ce/z/LvZFKj

This was noted as a missing fold in D138814.
2022-12-06 13:42:42 -05:00
Sanjay Patel
924233c784 [InstCombine] add tests for bool math; NFC
This pattern came up in D138814.
2022-12-06 13:42:42 -05:00
Mircea Trofin
4c97745bf0 Reapply "[mlgo] Dependency-free training mode logger"
This reverts commit 8abe7b11f74bea63d3134c144137b72146da0c7b.

Added the missing cast which was causing a build problem on certain compilers.
2022-12-06 10:29:50 -08:00
Roman Lebedev
46db90cc71
[SCEV] MatchBinaryOp(): try to recognize or as add-in-disguise (w/ no common bits set)
LLVM *loves* to convert `add` of operands with no common bits
into an `or`. But SCEV really doesn't deal with `or` that well,
so try extra hard to recognize this `or` as an `add`.

I believe, previously this wasn't being done because of the recursive
of this, but now that the `createSCEV()` is not recursive,
this should be fine. Unless this is *too* costly compile-time wise...

https://alive2.llvm.org/ce/z/EfapCo
2022-12-06 20:26:53 +03:00
Florian Hahn
8abe7b11f7
Revert "[mlgo] Dependency-free training mode logger"
This reverts commit c5ff6f72342e0a4b0ba2ec9f603bedca86721e80.

This breaks building on macOS:

FAILED: lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/Analysis -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/include -I/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14  -fno-exceptions -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TensorSpec.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp
In file included from /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp:16:
In file included from /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Analysis/TensorSpec.h:16:
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Support/JSON.h:354:29: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'int64_t' (aka 'long long') in initializer list [-Wc++11-narrowing]
    create<int64_t>(int64_t{I});
                            ^
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/lib/Analysis/TensorSpec.cpp:55:18: note: in instantiation of function template specialization 'llvm::json::Value::Value<unsigned long, void, void, void>' requested here
        OS.value(D);
                 ^
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/llvm/include/llvm/Support/JSON.h:354:29: note: insert an explicit cast to silence this issue
    create<int64_t>(int64_t{I});
                            ^
                            static_cast<int64_t>( )
1 error generated.

https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/33120/consoleFull#-145995569149ba4694-19c4-4d7e-bec5-911270d8a58c
2022-12-06 17:24:55 +00:00
Florian Hahn
1b1696b25e
[ConstraintElim] Add addition GEP tests with signed predicates. 2022-12-06 17:24:50 +00:00
Dmitry Makogon
b70807b340 [Test] Add test exposing crash in SimplifyCFG when hoisting llvm.deoptimize 2022-12-06 23:17:02 +07:00
Mircea Trofin
c5ff6f7234 [mlgo] Dependency-free training mode logger
This is the next step in dropping the dependency on protobuf.

The simple logger produces an output consisting of lines of json
strings. Tensor values - which should constitute the bulk of the data -
are serialized as raw byte buffers. This allows for light-weight reading
of the values.

The next step is to switch the training logic to the new logging format,
following which the protobuf-based logger will be dropped, together with
the training dependency on protobuf.

Subsequent changes will also stop buffering and stream, instead - the
buffering model is just as a convenient point-in-time.

Differential Revision: https://reviews.llvm.org/D139370
2022-12-06 08:12:45 -08:00
Nikita Popov
b04fc99c34 [ConstantRange] Fix nsw nowrap region for 1 bit integers (PR59301)
The special case for V=1 was incorrect for one bit types, where
1 is also -1. Remove it, and use getNonEmpty() to handle the full
range case instead.

Adjust the exhaustive nowrap tests to test both 5 bit and 1 bit
types.

Fixes https://github.com/llvm/llvm-project/issues/59301.
2022-12-06 16:37:43 +01:00
Florian Hahn
6b1396e31f
[ConstraintElim] Add tests for GEPs with signed predicates. 2022-12-06 15:27:57 +00:00
Matt Arsenault
7f4429c0e4 ValueTracking: Teach CannotBeOrderedLessThanZero about copysign 2022-12-06 09:01:39 -05:00
Matt Arsenault
e2f56debb3 InstCombine: Fold fabs (copysign x, y) -> fabs x 2022-12-06 08:29:14 -05:00
Matt Arsenault
84a8a57a86 InstCombine: Add baseline tests for copysign with fneg/fabs 2022-12-06 08:29:14 -05:00
chenglin.bi
3e4ae76d03 [Instcombine] Add baseline tests for logic-and/logic-or factorization; NFC 2022-12-06 17:35:35 +08:00
Mark Lacey
e96925ce0b [PartialInlining] Enable recursive partial inlining.
It seems unnecessarily limiting to disallow recursive partial
inlining, and there are clearly cases where it can benefit
code by avoiding a function call and potentially enabling
other transformations like dead argument elimination
in cases where an argument is only used prior to the early-out
test at the top of the function.

The pass already properly rewrites the recursive calls
within the body of the freshly cloned function, so the only
change here is removing the bail-out when recursion is
detected.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D136383
2022-12-05 23:10:37 -08:00
Matt Arsenault
0a67e771f6 CallGraph: Fix IgnoreAssumeLikeCalls option to Function::hasAddressTaken
This was added in 29e2d9461a91b and likely never worked in a useful
way.

The test added for it fails when converted to opaque pointers, since
the lifetime intrinsic now directly uses the address. The code was
only trying to handle a user indirectly through a bitcast
instruction. That would never have been useful; a bitcast of a global
value would be folded to a ConstantExpr cast.

I also don't understand why it was special casing use_empty on the
cast. Relax the check to be either BitCastOperator or
AddrSpaceCastOperator. In practice, BitCastOperator won't appear
today.

I believe the change in parallel_deletion_cg_update is a correct
improvement but I didn't fully follow it. .omp_outlined..0 is used in
a constant expression cast to a call which ends up getting deleted.
2022-12-05 21:41:59 -05:00
Roman Lebedev
571abdefd1
[NFC][SimplifyCFG] Add few more fold-branch-to-common-dest tests 2022-12-06 04:39:03 +03:00
Roman Lebedev
683b49b151
[NFC][LICM] Autogenerate checklines for one function to simplify update 2022-12-06 03:47:46 +03:00
Roman Lebedev
54649724df
[NFC][SimplifyCFG] Add one more fold-branch-to-common-dest test 2022-12-06 03:31:21 +03:00
Simon Pilgrim
f2bfe0f84a [InstCombine] Regenerate select-gep.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:43 +00:00
Simon Pilgrim
f9faf832a6 [InstCombine] Regenerate select-bitext.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:43 +00:00
Simon Pilgrim
531ef2cd24 [InstCombine] Regenerate select-cmpxchg.ll test checks 2022-12-05 21:19:42 +00:00
Simon Pilgrim
6f12fc2b82 [InstCombine] Regenerate select-masked_load.ll test checks 2022-12-05 21:19:42 +00:00
Simon Pilgrim
8c42da536c [InstCombine] Regenerate opaque-ptr.ll test checks
Fixes superfluous diffs identified in D139253
2022-12-05 21:19:42 +00:00
Nicolai Hähnle
34c0ed58d2 test/Transforms/Scalarizer: re-run update_test_checks.py
Goal is to get a cleaner diff in an upcoming functional change.
2022-12-05 21:24:48 +01:00
Roman Lebedev
be51fa4580
[NFC] Port all runlines for LoopVectorize pass tests to -passes syntax 2022-12-05 22:17:30 +03:00
Roman Lebedev
d1d1293569
[NFC] Port all runlines for SimplifyCFG pass tests to -passes syntax 2022-12-05 21:12:20 +03:00
Jamie Schmeiser
2b6683fd5f Expand loop peeling phi computation to handle binary ops and casts
Summary:
Expand the capabilities of the code for computing how many peels are
needed to make phis determined.  A cast gets the peel count for the
value being casted while a binary op gets the maximum of the operands.

Respond to review comments: remove redundant asserts.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By:mkazantsev (Max Kazantsev),syzaara (Zaara Syeda)
Differential Revision: https://reviews.llvm.org/D138719
2022-12-05 12:10:53 -05:00
Paul Walker
03b3017aef [InstCombine] Increase test coverage of vector.reverse ready for follow on work. 2022-12-05 17:03:00 +00:00
Florian Hahn
6887cfb982
[ConstraintElim] Queue facts and checks directly.
This allows interleaving facts and checks in a single block. In
particular this enables using facts from assumes for conditions in the
same block that come after the assume.

This could be extended to only try to simplify checks at the point where
a condition is used.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D138452
2022-12-05 16:44:20 +00:00
Matt Arsenault
be2ca02555 PGOProfile: Only keep opaque pointer tests
The typed pointer tests were already converted, these were identical
now.
2022-12-05 11:42:11 -05:00
Matt Arsenault
c6a5057453 PredicateInfo: Convert test to opaque pointers
Drops the "has predicate info" for the first block.
2022-12-05 11:42:11 -05:00
Florian Hahn
2501ab5e3f
[ConstraintElim] Add test subtracting SIGNED_MIN. 2022-12-05 16:32:45 +00:00
chenglin.bi
683e03d6d8 [Instcombine] Precommit tests for some or canonicalization; NFC
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
~(A & B) ^ (A | ?) -> (A & B) | ~(A | ?)
2022-12-06 00:32:10 +08:00
chenglin.bi
18cae673a4 [Instcombine] Precommit tests for D139080; NFC
Test pattern for
(C & X) | ~(C | Y) -> C ? X : ~Y
2022-12-06 00:23:28 +08:00
chenglin.bi
b966fb08a2 [InstCombine] Precommit tests for D139253; NFC 2022-12-06 00:00:54 +08:00
Sjoerd Meijer
1515308a54 [LoopFlatten] Precommit test for GH issue #59339. NFC. 2022-12-05 15:38:47 +00:00
Florian Hahn
eefd085843
[ConstraintElim] Add test with implicit/explicit GEP index truncate.
The implicit index truncate example is currently being miscompiled.
2022-12-05 15:25:08 +00:00
Matt Arsenault
51af4ddfc2 ValueTracking: Teach canCreateUndefOrPoison about more intrinsics
I tried to test the fallthrough to noundef callsite return attribute
case, but it seems that folds out as-is.
2022-12-05 10:04:13 -05:00
Matt Arsenault
dfa842e45a ValueTracking: Add some baseline intrinsic with freeze tests 2022-12-05 09:40:58 -05:00
Matt Arsenault
dbca874faa ValueTracking: Teach CannotBeOrderedLessThanZero about trivial ops
Handle canonicalize and arithmetic.fence
2022-12-05 08:39:07 -05:00
Matt Arsenault
db0f258479 ValueTracking: Teach isKnownNeverNaN about arithmetic_fence 2022-12-05 08:39:07 -05:00
Matt Arsenault
dac496fb1f ValueTracking: Teach isKnownNeverInfinity about arithmetic.fence 2022-12-05 08:39:07 -05:00
Matt Arsenault
7224cffd62 Intrinsics: Fix not speculating llvm.fptrunc.round
Move its definition to be with the other FP rounding intrinsics.
2022-12-05 08:39:07 -05:00