Commit Graph

2297 Commits

Author SHA1 Message Date
Sanjay Patel 2ef4e14af3 [DAGCombiner] allow undef elts in vector fmul matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344534 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 16:54:07 +00:00
Sanjay Patel 9e0d834cc5 [DAGCombiner] refactor folds for fadd (fmul X, -2.0), Y; NFCI
The transform doesn't work if the vector constant has undef elements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344532 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 16:47:01 +00:00
Sanjay Patel 907565571c [DAGCombiner] allow undef elts in vector fma matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344528 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 15:56:39 +00:00
Sanjay Patel fb06745cac [DAGCombiner] allow undef elts in vector fma matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344525 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 15:38:38 +00:00
Sanjay Patel bd755d4e27 [DAGCombiner] rearrange extract_element+bitcast fold; NFC
I want to add another pattern here that includes scalar_to_vector,
so this makes that patch smaller. I was hoping to remove the
hasOneUse() check because it shouldn't be necessary for common
codegen, but an AMDGPU test has a comment suggesting that the
extra check makes things better on one of those targets.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344320 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 23:56:56 +00:00
Nirav Dave f5647cf249 [DAG] Fix Big Endian in Load-Store forwarding
Summary:
Correct offset calculation in load-store forwarding for big-endian
targets.

Reviewers: rnk, RKSimon, waltl

Subscribers: sdardis, nemanjai, hiraditya, jrtc27, atanasyan, jsji, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 18:28:59 +00:00
Sanjay Patel 7b42e95277 [DAGCombiner] move comment closer to the corresponding code; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344255 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 16:07:25 +00:00
Nirav Dave df002d74e3 [DAGCombine] Improve Load-Store Forwarding
Summary:
Extend analysis forwarding loads from preceeding stores to work with
extended loads and truncated stores to the same address so long as the
load is fully subsumed by the store.

Hexagon's swp-epilog-phis.ll and swp-memrefs-epilog1.ll test are
deleted as they've no longer seem to be relevant.

Reviewers: RKSimon, rnk, kparzysz, javed.absar

Subscribers: sdardis, nemanjai, hiraditya, atanasyan, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344142 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-10 14:15:52 +00:00
Nemanja Ivanovic 53979264b2 [DAGCombiner] Expand combining of FP logical ops to sign-setting FP ops
We already do the following combines:
(bitcast int (and (bitcast fp X to int), 0x7fff...) to fp) -> fabs X
(bitcast int (xor (bitcast fp X to int), 0x8000...) to fp) -> fneg X

When the target has "bit preserving fp logic". This patch just extends it
to also combine:
(bitcast int (or (bitcast fp X to int), 0x8000...) to fp) -> fneg (fabs X)

As some targets have fnabs and even those that don't can efficiently lower
both the fabs and the fneg.

Differential revision: https://reviews.llvm.org/D44548


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344093 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 23:20:11 +00:00
Sanjay Patel 780daee51e [DAGCombiner] simplify code for fmul with constant fold; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343997 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 21:17:20 +00:00
Sanjay Patel a2434c2657 [DAGCombiner] allow undef elts in vector fadd matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343945 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-07 16:30:42 +00:00
Sanjay Patel 199609a85f [DAGCombiner] allow undefs when matching vector splats for fmul folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343942 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-07 16:05:37 +00:00
Sanjay Patel 0620db4950 [DAGCombiner] allow undef elts in vector fabs/fneg matching
This change is proposed as a part of D44548, but we
need this independently to avoid regressions from improved
undef propagation in SimplifyDemandedVectorElts().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343940 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-07 15:32:06 +00:00
Sanjay Patel f681ac49ad [DAGCombiner] shorten code for bitcast+fabs fold; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343939 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-07 15:18:30 +00:00
Sanjay Patel 9d809925c6 [SelectionDAG] allow undefs when matching splat constants
And use that to transform fsub with zero constant operands.
The integer part isn't used yet, but it is proposed for use in
D44548, so adding both enhancements here makes that 
patch simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343865 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05 17:42:19 +00:00
Matthias Braun c2625345a6 DAGCombiner: StoreMerging: Fix bad index calculating when adjusting mismatching vector types
This fixes a case of bad index calculation when merging mismatching
vector types. This changes the existing code to just use the existing
extract_{subvector|element} and a bitcast (instead of bitcast first and
then newly created extract_xxx) so we don't need to adjust any indices
in the first place.

rdar://44584718

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343493 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 16:25:50 +00:00
Simon Pilgrim 435f54e464 [DAG] Don't perform SINT_TO_FP<->UINT_TO_FP custom conversion after legalization
The SINT_TO_FP<->UINT_TO_FP combines for non-negative integers should only occur for legal ops once LegalOperations = true

No test case to hand, noticed when investigating PR38226 + PR38970

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343405 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-30 12:46:42 +00:00
David Bolvansky 1b5fe4e637 [DAGCombiner] [NFC] Improve X div/rem 1 fold
Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343349 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 18:40:30 +00:00
Fangrui Song 3b35e17b21 llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb

Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343163 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:13:45 +00:00
Craig Topper f048c66f45 [DAGCombiner] Remove unnecessary check for visitSDIVLike/visitUDIVLike returning a UDIVREM or SDIVREM node.
This shouldn't be possible and is a leftover from when we used to recursively call combine here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343049 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 23:52:07 +00:00
Nirav Dave 07f8b17dd3 [DAGCombine] Improve Predecessor check in SimplifySelectOps. NFCI.
Reuse search space bookkeeping across multiple predecessor checks
qdone to avoid redundancy. This should cut search cost by ~4x.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342984 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 15:29:30 +00:00
Nirav Dave ea11fa660d [DAGCombine] Share predecessor bookkeeping in CombineToPostIndexedLoadStore. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342983 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 15:29:04 +00:00
Nirav Dave 64957db18b [DAGCombine] Don't fold dependent loads across SELECT_CC.
DAGCombine will try to fold two loads that feed a SELECT or SELECT_CC
after the select, resulting in a select of an address and a single
load after.

If either of the loads depend on the other, this is not legal as it
could introduce cycles. However, it only checked this if the opcode
was a SELECT, and not for a SELECT_CC.

Unfortunately, the only reproducer I have for this is for our
downstream target. I've tried getting it to trigger on an upstream one
but haven't been successful.

Patch thanks to Bevin Hansson.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342980 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 14:43:05 +00:00
Sanjay Patel 86317355d3 [DAGCombiner] use UADDO to optimize saturated unsigned add
This is a preliminary step towards solving PR14613:
https://bugs.llvm.org/show_bug.cgi?id=14613

If we have an 'add' instruction that sets flags, we can use that to eliminate an
explicit compare instruction or some other instruction (cmn) that sets flags for 
use in the later select.

As shown in the unchanged tests that use 'icmp ugt %x, %a', we're effectively 
reversing an IR icmp canonicalization that replaces a variable operand with a
constant:
https://rise4fun.com/Alive/V1Q

But we're not using 'uaddo' in those cases via DAG transforms. This happens in 
CGP after D8889 without checking target lowering to see if the op is supported. 
So AArch already shows 'uaddo' codegen for the i8/i16/i32/i64 test variants with 
"using_cmp_sum" in the title. That's the pattern that CGP matches as an unsigned 
saturated add and converts to uaddo without checking target capabilities.

This patch is gated by isOperationLegalOrCustom(ISD::UADDO, VT), so we see only 
see AArch diffs for i32/i64 in the tests with "using_cmp_notval" in the title 
(unlike x86 which sees improvements for all sizes because all sizes are 'custom'). 
But the AArch code (like x86) looks better when translated to 'uaddo' in all cases. 
So someone that is involved with AArch may want to set i8/i16 to 'custom' for UADDO, 
so this patch will fire on those tests.

Another possibility given the existing behavior: we could remove the legal-or-custom 
check altogether because we're assuming that a UADDO sequence is canonical/optimal 
before we ever reach here. But that seems like a bug to me. If the target doesn't 
have an add-with-flags op, then it's not likely that we'll get optimal DAG combining 
using a UADDO node. This is similar justification for why we don't canonicalize IR to 
the overflow math intrinsic sibling (llvm.uadd.with.overflow) for UADDO in the first 
place.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342886 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-24 14:47:15 +00:00
Hans Wennborg 13deaadf27 Remove debug printf leftover from r342397
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342863 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-24 08:18:47 +00:00
Craig Topper 3303750bfb [DAGCombiner] Remove some dead code from ConstantFoldBITCASTofBUILD_VECTOR
This code handled SCALAR_TO_VECTOR being returned by the recursion, but the code that used to return SCALAR_TO_VECTOR was removed in 2015.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342856 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-24 02:03:11 +00:00
Craig Topper 92f6230379 [DAGCombiner] Clarify a comment. NFC
This comment was misleading about why we were restricting to before legalize types. The reason given would only apply to before legalize ops. But there is a before legalize types reason that should also be listed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342851 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 21:17:56 +00:00
Sanjay Patel ba4d9d9776 [DAGCombiner][x86] extend decompose of integer multiply into shift/add with negation
This is an alternative to https://reviews.llvm.org/D37896. We can't decompose 
multiplies generically without a target hook to tell us when it's profitable.

ARM and AArch64 may be able to remove some existing code that overlaps with
this transform.

This extends D52195 and may resolve PR34474: 
https://bugs.llvm.org/show_bug.cgi?id=34474
(still an open question about transforming legal vector multiplies, but we
could open another bug report for those)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342844 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 18:41:38 +00:00
Craig Topper 695ea113fa [DAGCombiner] Simplify some code in visitBITCAST. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342826 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-22 23:12:34 +00:00
Craig Topper 5265fbe31e [DAGCombiner] Rewrite r331896 in a different way to address a FIXME. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342809 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-22 18:03:14 +00:00
Sanjay Patel 5748c47c62 [SelectionDAG] replace duplicated peekThroughBitcast helper functions; NFCI
x86 had 2 versions of peekThroughBitcast. DAGCombiner had 1. Plus, it had a 1-off implementation for the one-use variant.
Move the x86 versions of the code to SelectionDAG, so we don't have different copies of the code. 
No functional change intended.

I'm putting this next to isBitwiseNot() because I am planning to use it in there. Another option is next to the
helpers in the ISD namespace (eg, ISD::isConstantSplatVector()). But if there's no good reason for those to be 
there, I'd prefer to pull other helpers over to SelectionDAG in follow-up steps.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342669 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-20 17:34:08 +00:00
Sanjay Patel fe5554490a [SelectionDAG] allow vector types with isBitwiseNot()
The test diff in not-and-simplify.ll is from a use in SimplifyDemandedBits,
and the test diff in add.ll is from a DAGCombiner transform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342594 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 21:48:30 +00:00
Sanjay Patel dcc25258ae [DAGCombiner][x86] add transform/hook to decompose integer multiply into shift/add
This is an alternative to D37896. I don't see a way to decompose multiplies 
generically without a target hook to tell us when it's profitable. 

ARM and AArch64 may be able to remove some duplicate code that overlaps with 
this transform.

As a first step, we're only getting the most clear wins on the vector examples
requested in PR34474:
https://bugs.llvm.org/show_bug.cgi?id=34474

As noted in the code comment, it's likely that the x86 constraints are tighter
than necessary, but it may not always be a win to replace a pmullw/pmulld.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342554 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 15:57:40 +00:00
Amara Emerson 49ff058175 Revert "Revert r342183 "[DAGCombine] Fix crash when store merging created an extract_subvector with invalid index.""
Fixed the assertion failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342397 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 14:40:13 +00:00
Sanjay Patel 9d4952d6a5 [DAGCombiner] try to convert pow(x, 1/3) to cbrt(x)
This is a follow-up suggested in D51630 and originally proposed as an IR transform in D49040.

Copying the motivational statement by @evandro from that patch:
"This transformation helps some benchmarks in SPEC CPU2000 and CPU2006, such as 188.ammp, 
447.dealII, 453.povray, and especially 300.twolf, as well as some proprietary benchmarks. 
Otherwise, no regressions on x86-64 or A64."

I'm proposing to add only the minimum support for a DAG node here. Since we don't have an 
LLVM IR intrinsic for cbrt, and there are no other DAG ways to create a FCBRT node yet, I 
don't think we need to worry about DAG builder, legalization, a strict variant, etc. We 
should be able to expand as needed when adding more functionality/transforms. For reference, 
these are transform suggestions currently listed in SimplifyLibCalls.cpp:

//   * cbrt(expN(X))  -> expN(x/3)
//   * cbrt(sqrt(x))  -> pow(x,1/6)
//   * cbrt(cbrt(x))  -> pow(x,1/9)

Also, given that we bail out on long double for now, there should not be any logical 
differences between platforms (unless there's some platform out there that has pow()
but not cbrt()).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342348 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-16 16:50:26 +00:00
Reid Kleckner 388e636afb Revert r342183 "[DAGCombine] Fix crash when store merging created an extract_subvector with invalid index."
Causes 'isVector() && "Invalid vector type!"' assertion when building
Skia in Chrome.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342265 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14 19:39:40 +00:00
Amara Emerson 21390db360 [DAGCombine] Fix crash when store merging created an extract_subvector with invalid index.
Differential Revision: https://reviews.llvm.org/D51831

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342183 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-13 21:28:58 +00:00
Sanjay Patel 3478d12268 [DAGCombiner] improve formatting for select+setcc code; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342095 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-12 23:03:50 +00:00
Simon Pilgrim e14a443a2b [DAGCombiner] foldBitcastedFPLogic - Add basic vector support
Add support for bitcasts from float type to an integer type of the same element bitwidth.

There maybe cases where we need to support different widths (e.g. as SSE __m128i is treated as v2i64) - but I haven't seen cases of this in the wild yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341652 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 12:13:45 +00:00
Sanjay Patel 39f79ecf00 [DAGCombiner] try to convert pow(x, 0.25) to sqrt(sqrt(x))
This was proposed as an IR transform in D49306, but it was not clearly justifiable as a canonicalization. 
Here, we only do the transform when the target tells us that sqrt can be lowered with inline code.

This is the basic case. Some potential enhancements are in the TODO comments:

1. Generalize the transform for other exponents (allow more than 2 sqrt calcs if that's really cheaper).
2. If we have less fast-math-flags, generate code to avoid -0.0 and/or INF.
3. Allow the transform when optimizing/minimizing size (might require a target hook to get that right).

Note that by default, x86 converts single-precision sqrt calcs into sqrt reciprocal estimate with 
refinement. That codegen is controlled by CPU attributes and can be manually overridden. We have plenty 
of test coverage for that already, so I didn't bother to include extra testing for that here. AArch uses 
its full-precision ops in all cases (not sure if that's the intended behavior or not, but that should 
also be covered by existing tests).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341481 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-05 17:01:56 +00:00
Craig Topper 0ea3261482 [DAGCombiner] Fix bad identation. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341103 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 19:35:40 +00:00
Simon Pilgrim 6065bc0769 [DAGCombiner] Add X / X -> 1 & X % X -> 0 folds
Adds more divrem folds to try and get in sync with InstructionSimplify

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340919 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 11:30:16 +00:00
Nirav Dave 7eda1917c3 [DAGCombine] Rework MERGE_VALUES to inline in single pass. NFCI.
Avoid hyperlinear cost of inlining MERGE_VALUE node by constructing
temporary vector and doing a single replacement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340853 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:13:26 +00:00
Craig Topper 00ca244b7d [DAGCombiner][AMDGPU][Mips] Fold bitcast with volatile loads if the resulting load is legal for the target.
Summary:
I'm not sure if this patch is correct or if it needs more qualifying somehow. Bitcast shouldn't change the size of the load so it should be ok? We already do something similar for stores. We'll change the type of a volatile store if the resulting store is Legal or Custom. I'm not sure we should be allowing Custom there...

I was playing around with converting X86 atomic loads/stores(except seq_cst) into regular volatile loads and stores during lowering. This would allow some special RMW isel patterns in X86InstrCompiler.td to be removed. But there's some floating point patterns in there that didn't work because we don't fold (f64 (bitconvert (i64 volatile load))) or (f32 (bitconvert (i32 volatile load))).

Reviewers: efriedma, atanasyan, arsenm

Reviewed By: efriedma

Subscribers: jvesely, arsenm, sdardis, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, arichardson, jrtc27, atanasyan, jfb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340797 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 03:47:20 +00:00
Matt Arsenault bfb50d8dbc DAG: Check transformed type for forming fminnum/fmaxnum from vselect
Follow up to r340655 to fix vector types which are split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340766 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 18:11:31 +00:00
Sanjay Patel 4f83e0c2a4 [SelectionDAG] add helper query for binops; NFC
We will also use this in a planned enhancement for vector insertelement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340741 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 14:20:15 +00:00
Sanjay Patel 79923d92c5 [SelectionDAG][x86] turn insertelement into undef with variable index into splat
I noticed this along with the patterns in D51125, but when the index is variable, 
we don't convert insertelement into a build_vector.

For x86, that means these get expanded at legalization time into the loading/spilling 
code that we see in the tests. I think it's always better to avoid going to memory on 
these, and we get the optimal 'broadcast' if it's available.

I suspect other targets may want to look at enabling the hook. AArch64 and AMDGPU have 
regression tests that would be affected (although I did not check what would happen in 
those cases). In the most basic cases shown here, AArch64 would probably do much 
better with a splat.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340705 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 18:20:41 +00:00
Matt Arsenault 936b78d214 DAG: Allow matching fminnum/fmaxnum from vselect
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340655 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 21:24:18 +00:00
Craig Topper cd6221355b [DAGCombiner][Mips] Don't combine bitcast+store after LegalOperations when the store is volatile, if the resulting store isn't Legal
Previously we allowed the store to be Custom. But without knowing for sure that the Custom handling won't split the store, we shouldn't convert a volatile store. We also probably shouldn't be creating a store the requires custom handling after LegalizeOps. This could lead to an infinite loop if the custom handling was to insert a bitcast. Though I guess isStoreBitCastBeneficial could be used to block such a loop.

The test changes here are due to the volatile part of this. The stores in the test are all volatile and i32 stores are marked custom, So we are no longer converting them

This is related to D50491 where I was trying to allow some bitcasting of volatile loads

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340626 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 17:48:25 +00:00
Sam Parker 48cb502069 [DAGCombiner] Reduce load widths of shifted masks
During combining, ReduceLoadWdith is used to combine AND nodes that
mask loads into narrow loads. This patch allows the mask to be a
shifted constant. This results in a narrow load which is then left
shifted to compensate for the new offset.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340261 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 10:26:59 +00:00