[x86] Teach the vector shuffle lowering to make a more nuanced decision
between splitting a vector into 128-bit lanes and recombining them vs.
decomposing things into single-input shuffles and a final blend.

This handles a large number of cases in AVX1 where the cross-lane
shuffles would be much more expensive to represent even though we end up
with a fast blend at the root. Instead, we can do a better job of
shuffling in a single lane and then inserting it into the other lanes.

This fixes the remaining bits of Halide's regression captured in PR21281
for AVX1. However, the bug persists in AVX2 because I've made this
change reasonably conservative. The cases where it makes sense in AVX2
to split into 128-bit lanes are much more rare because we can often do
full permutations across all elements of the 256-bit vector. However,
the particular test case in PR21281 is an example of one of the rare
cases where it is *always* better to work in a single 128-bit lane. I'm
going to try to teach the logic to detect and form the good code even in
AVX2 next, but it will need to use a separate heuristic.

Finally, there is one pesky regression here where we previously would
craftily use vpermilps in AVX1 to shuffle both high and low halves at
the same time. We no longer pull that off, and not for any really good
reason. Ultimately, I think this is just another missing nuance to the
selection heuristic that I'll try to add in afterward, but this change
already seems strictly worth doing considering the magnitude of the
improvements in common matrix math shuffle patterns.

As always, please let me know if this causes a surprising regression for
you.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221861 91177308-0d34-0410-b5e6-96231b3b80d8
Update \param(s) in MemoryObject::readBytes(). [-Wdocumentation]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221863 91177308-0d34-0410-b5e6-96231b3b80d8
Read 64 bits at a time in the bitcode reader.

The reading of 64 bit values could still be optimized, but at least this cuts
down on the number of virtual calls to fetch more data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221865 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: Clean up formatting in hasExtendedRelocations

No functionality changed intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221867 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: Fix some theoretical bugs

getObject didn't consider the case where a pointer came before the start
of the object file.  No test is included, trying to come up with
something reasonable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221868 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: Cleanup some code in getSectionName

Use StringRef::startswith to tidy up some code, no functionality change
intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221869 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: getRelocationSymbol shouldn't assert

lib/Object is supposed to be robust to malformed object files.  Don't
assert if we don't have a symbol table.  I'll try to come up with a test
case later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221870 91177308-0d34-0410-b5e6-96231b3b80d8
llvm-readobj, COFF: Remove an unused variable

printRelocation doesn't use the section contents.  No functionality
change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221871 91177308-0d34-0410-b5e6-96231b3b80d8
llvm-readobj: relocAddressLess could potentially lie

On error conditions, relocAddressLess might claim that a value is less
than itself.  Instead, abort llvm-readobj.  No functionality change
intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221872 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: Increase code reuse

Split getObject's smarts into checkOffset, use this to replace the
handwritten check in getSectionContents.  Similarly, replace checks in
section_rel_begin/section_rel_end with getNumberOfRelocations.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221873 91177308-0d34-0410-b5e6-96231b3b80d8
Revert r219432 - "Revert "[BasicAA] Revert "Revert r218714 - Make better use of zext and sign information."""

Let's try this again...

This reverts r219432, plus a bug fix.

Description of the bug in r219432 (by Nick):

The bug was using AllPositive to break out of the loop; if the loop break
condition i != e is changed to i != e && AllPositive then the
test_modulo_analysis_with_global test I've added will fail as the Modulo will
be calculated incorrectly (as the last loop iteration is skipped, so Modulo
isn't updated with its Scale).

Nick also adds this comment:

ComputeSignBit is safe to use in loops as it takes into account phi nodes, and
the  == EK_ZeroEx check is safe in loops as, no matter how the variable changes
between iterations, zero-extensions will always guarantee a zero sign bit. The
isValueEqualInPotentialCycles check is therefore definitely not needed as all
the variable analysis holds no matter how the variables change between loop
iterations.

And this patch also adds another enhancement to GetLinearExpression - basically
to convert ConstantInts to Offsets (see test_const_eval and
test_const_eval_scaled for the situations this improves).

Original commit message:

This reverts r218944, which reverted r218714, plus a bug fix.

Description of the bug in r218714 (by Nick):

The original patch forgot to check if the Scale in VariableGEPIndex flipped the
sign of the variable. The BasicAA pass iterates over the instructions in the
order they appear in the function, and so BasicAliasAnalysis::aliasGEP is
called with the variable it first comes across as parameter GEP1. Adding a
%reorder label puts the definition of %a after %b so aliasGEP is called with %b
as the first parameter and %a as the second. aliasGEP later calculates that %a
== %b + 1 - %idxprom where %idxprom >= 0 (if %a was passed as the first
parameter it would calculate %b == %a - 1 + %idxprom where %idxprom >= 0) -
ignoring that %idxprom is scaled by -1 here lead the patch to incorrectly
conclude that %a > %b.

Revised patch by Nick White, thanks! Thanks to Lang to isolating the bug.
Slightly modified by me to add an early exit from the loop and avoid
unnecessary, but expensive, function calls.

Original commit message:

Two related things:

 1. Fixes a bug when calculating the offset in GetLinearExpression. The code
    previously used zext to extend the offset, so negative offsets were converted
    to large positive ones.

 2. Enhance aliasGEP to deduce that, if the difference between two GEP
    allocations is positive and all the variables that govern the offset are also
    positive (i.e. the offset is strictly after the higher base pointer), then
    locations that fit in the gap between the two base pointers are NoAlias.

Patch by Nick White!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221876 91177308-0d34-0410-b5e6-96231b3b80d8
This patch changes the ownership of TLOF from TargetLoweringBase to TargetMachine so that different subtargets could share the TLOF effectively

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221878 91177308-0d34-0410-b5e6-96231b3b80d8
OCAMLFLAGS can contain =, don't use = with sed

Like HOST_LDFLAGS, etc. OCAMLFLAGS can contain =, so use ! as the substitution
separator instead of = (otherwise, sed might error).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221879 91177308-0d34-0410-b5e6-96231b3b80d8
Object, COFF: Refactor code to get relocation iterators

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221880 91177308-0d34-0410-b5e6-96231b3b80d8
AVX-512: SINT_TO_FP cost model and some bugfixes
Checked some corner cases, for example translation
of <8 x i1> to <8 x double>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221883 91177308-0d34-0410-b5e6-96231b3b80d8
IR: Create the Metadata class

This will become the root of a new class hierarchy separate from
`Value`.  As a first step, stick it between `Value` and `MDNode`.

This is part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221886 91177308-0d34-0410-b5e6-96231b3b80d8
Fixing some sign comparison warnings from MSVC; NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221887 91177308-0d34-0410-b5e6-96231b3b80d8
Fixing -Wtype-limits warnings with the asserts (the expression would always evaluate to true). Also fixing a -Wcast-qual warning, where the cast expression isn't required.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221888 91177308-0d34-0410-b5e6-96231b3b80d8
Small optimization: once the size is know, we don't have to call fillCurWord.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221891 91177308-0d34-0410-b5e6-96231b3b80d8
Simplify code a bit. NFC.

Thanks to Sean Silva for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221892 91177308-0d34-0410-b5e6-96231b3b80d8