24 Commits

Author SHA1 Message Date
Craig Topper
9768804628 [X86] Add test cases for masked store and masked scatter with an all zeroes mask. Fix bug in ScalarizeMaskedMemIntrin
Need to cast only to Constant instead of ConstantVector to allow
ConstantAggregateZero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362341 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-02 22:52:34 +00:00
Craig Topper
c1b79b3c59 [ScalarizeMaskedMemIntrin] Add support for scalarizing expandload and compressstore intrinsics.
This adds support for scalarizing these intrinsics as well the X86TargetTransformInfo support to avoid scalarizing them in the cases X86 can handle.

I've omitted handling special cases for constant masks for this first pass. Though CodeGenPrepare can constant fold the branch conditions and remove some of the control flow anyway.

Fixes PR40994 and is covers most of PR3666. Might want to implement constant masks to close that.

Differential Revision: https://reviews.llvm.org/D59180

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356687 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 17:38:52 +00:00
Craig Topper
e2493293d4 [ScalarizeMaskedMemIntrinsics] Reverse some if conditions to reduce indentations to remove curly braces.
Pre-commit for D59180

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356646 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 05:54:37 +00:00
Craig Topper
7c2c4642b9 [ScalarizeMaskedMemIntrin] Use IRBuilder functions that take uint32_t/uint64_t for getelementptr, extractelement, and insertelement.
This saves needing to call getInt32 ourselves. Making the code a little shorter.

The test changes are because insert/extract use getInt64 internally. Shouldn't be a functional issue.

This cleanup because I plan to write similar code for expandload/compressstore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355767 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-09 02:08:41 +00:00
Craig Topper
cc2caa3c8b [ScalarizeMaskedMemIntrin] Only set the ModifiedDT flag if new basic blocks were added.
There are special cases in the scalarization for constant masks. If we hit one of the special cases we don't need to reset the iteration.

Noticed while starting work on adding expandload/compressstore to this pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355754 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-08 23:03:43 +00:00
James Y Knight
6c00b3f35f [opaque pointer types] Pass value type to LoadInst creation.
This cleans up all LoadInst creation in LLVM to explicitly pass the
value type rather than deriving it from the pointer's element-type.

Differential Revision: https://reviews.llvm.org/D57172

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352911 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-01 20:44:24 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Craig Topper
a0a61c4250 [ScalarizeMaskedMemIntrin] Limit the scope of some variables that are only used inside loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345638 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-30 20:33:58 +00:00
Craig Topper
6752904763 [ScalarizeMaskedMemIntrin] Use MinAlign to calculate alignment for the scalar load/stores to handle element types that are byte-sized but not powers of 2.
This pass doesn't handle non-byte sized types correctly at all, but at least we can make byte sized types work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343294 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 03:35:37 +00:00
Craig Topper
bcbf6bc493 [ScalarizeMaskedMemIntrin] Fix the alignment calculation for the scalar stores of a masked store expansion.
It should be the minimum of the original alignment and the scalar size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343284 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 01:06:13 +00:00
Craig Topper
f947b53515 [ScalarizeMaskedMemIntrin] Ensure the mask is a vector of ConstantInts before generating the expansion without control flow.
Its possible the mask itself or one of the elements is a ConstantExpr and we shouldn't optimize in that case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343278 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 22:31:42 +00:00
Craig Topper
5c98f23227 [ScalarizeMaskedMemIntrin] Use cast instead of dyn_cast checked by an assert. Consistently make use of the element type variable we already have. NFCI
cast will take care of asserting internally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343277 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 22:31:40 +00:00
Craig Topper
2122d188d1 [ScalarizeMaskedMemIntrin] When expanding masked gathers, start with the passthru vector and insert the new load results into it.
Previously we started with undef and did a final merge with the passthru at the end.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343273 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:28:59 +00:00
Craig Topper
4f95400123 [ScalarizeMaskedMemIntrin] When expanding masked loads, start with the passthru value and insert each conditional load result over their element.
Previously we started with undef and did one final merge at the end with a select.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343271 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:28:52 +00:00
Craig Topper
4b75b6ed93 [ScalarizeMaskedMemIntrin] Handle the case where the mask is an all zero vector.
This shouldn't really happen in practice I hope, but we tried to handle other constant cases. We missed this one because we checked for ConstantVector without realizing that zero becomes ConstantAggregateZero instead.

So instead just check for Constant and use getAggregateElement which will do the dirty work for us.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343270 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:28:46 +00:00
Craig Topper
1a8d3258e3 [ScalarizeMaskedMemIntrin] Remove some temporary variables that are only used by a single if condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343268 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:28:41 +00:00
Craig Topper
3844ee81e3 [ScalarizeMaskedMemIntrin] Cleanup comments. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343267 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:28:39 +00:00
Craig Topper
b41c4e18ff [ScalarizeMaskedMemIntrin] Don't emit 'icmp eq i1 %x, 1' to check mask values. That's just %x so use that directly.
Had we emitted this IR earlier, InstCombine would have removed icmp so I'm going to assume using the i1 directly would be considered canonical.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343244 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 18:01:48 +00:00
Andrei Elovikov
cefae4fb96 [CodeGen] Do not allow opt-bisect-limit to skip ScalarizeMaskedMemIntrin.
Summary:
The pass is supposed to scalarize such intrinsics if the target does not support
them natively, so if the scalarization does not happen instruction selection
crashes due to inability to lower these intrinsics.

Reviewers: andrew.w.kaylor, craig.topper

Reviewed By: andrew.w.kaylor

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D45947

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330700 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-24 09:24:29 +00:00
David Blaikie
e3a9b4ce3a Fix a bunch more layering of CodeGen headers that are in Target
All these headers already depend on CodeGen headers so moving them into
CodeGen fixes the layering (since CodeGen depends on Target, not the
other way around).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318490 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-17 01:07:10 +00:00
Eugene Zelenko
5c883452a8 [CodeGen] Fix some Clang-tidy modernize-use-default-member-init and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314363 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27 23:26:01 +00:00
Reid Kleckner
6619121492 Sink some IntrinsicInst.h and Intrinsics.h out of llvm/include
Many of these uses can get by with forward declarations. Hopefully this
speeds up compilation after adding a single intrinsic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312759 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07 23:27:44 +00:00
Matthias Braun
94c4904dc5 CodeGen: Rename DEBUG_TYPE to match passnames
Rename the DEBUG_TYPE to match the names of corresponding passes where
it makes sense. Also establish the pattern of simply referencing
DEBUG_TYPE instead of repeating the passname where possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303921 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 21:26:32 +00:00
Ayman Musa
eadb58fda7 [X86] Relocate code of replacement of subtarget unsupported masked memory intrinsics to run also on -O0 option.
Currently, when masked load, store, gather or scatter intrinsics are used, we check in CodeGenPrepare pass if the subtarget support these intrinsics, if not we replace them with scalar code - this is a functional transformation not an optimization (not optional).

CodeGenPrepare pass does not run when the optimization level is set to CodeGenOpt::None (-O0).

Functional transformation should run with all optimization levels, so here I created a new pass which runs on all optimization levels and does no more than this transformation.

Differential Revision: https://reviews.llvm.org/D32487



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303050 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-15 11:30:54 +00:00