Commit Graph

373739 Commits

Author SHA1 Message Date
Benjamin Kramer 107e92dff8 [DAG] Remove unused variable. NFC. 2020-12-01 16:29:02 +01:00
David Green eedf0ed63e [ARM] Mark select and selectcc of MVE vector operations as expand.
We already expand select and select_cc in codegenprepare, but they can
still be generated under some situations. Explicitly mark them as expand
to ensure they are not produced, leading to a failure to select the
nodes.

Differential Revision: https://reviews.llvm.org/D92373
2020-12-01 15:05:55 +00:00
Sanjay Patel 9f60b8b3d2 [InstCombine] canonicalize sign-bit-shift of difference to ext(icmp)
icmp is the preferred spelling in IR because icmp analysis is
expected to be better than any other analysis. This should
lead to more follow-on folding potential.

It's difficult to say exactly what we should do in codegen to
compensate. For example on AArch64, which of these is preferred:
	sub	w8, w0, w1
	lsr	w0, w8, #31

vs:
	cmp	w0, w1
	cset	w0, lt

If there are perf regressions, then we should deal with those in
codegen on a case-by-case basis.

A possible motivating example for better optimization is shown in:
https://llvm.org/PR43198 but that will require other transforms
before anything changes there.

Alive proof:
https://rise4fun.com/Alive/o4E

  Name: sign-bit splat
  Pre: C1 == (width(%x) - 1)
  %s = sub nsw %x, %y
  %r = ashr %s, C1
  =>
  %c = icmp slt %x, %y
  %r = sext %c

  Name: sign-bit LSB
  Pre: C1 == (width(%x) - 1)
  %s = sub nsw %x, %y
  %r = lshr %s, C1
  =>
  %c = icmp slt %x, %y
  %r = zext %c
2020-12-01 09:58:11 -05:00
Raphael Isemann 64f04629aa [lldb][NFC] Modernize and cleanup TestClassTemplateParameterPack
* Un-inline the test.
* Use expect_expr everywhere and also check all involved types.
* Clang-format the test sources.
* Explain what we're actually testing with the 'C' and 'D' templates.
* Split out the non-template-parameter-pack part of the test into its own small test.
2020-12-01 15:53:40 +01:00
Simon Pilgrim 1b209ff9e3 [DAG] Move vselect(icmp_ult, 0, sub(x,y)) -> usubsat(x,y) to DAGCombine (PR40111)
Move the X86 VSELECT->USUBSAT fold to DAGCombiner - there's nothing target specific about these folds.
2020-12-01 14:25:29 +00:00
Florian Hahn 7a4f1d59b8 [ConstraintElimination] Decompose GEP %ptr, ZEXT(SHL()).
Add support to decompose a GEP with a ZEXT(SHL()) operand.
2020-12-01 14:23:21 +00:00
Nico Weber 4431c212a0 lld/ELF: Make three rarely-used flags work with --reproduce
All three use readFile() for their argument so their argument file is
already copied to the tar, but we weren't rewriting the argument to
point to the path used in the tar file.

No test because the change is trivial (several other flags in
createResponseFile() also aren't tested, likely for the same reason.)

Differential Revision: https://reviews.llvm.org/D92356
2020-12-01 09:20:29 -05:00
Alexey Baturo 17427ec3f3 [RISCV][crt] support building without init_array
Reviewed By: luismarques, phosek, kito-cheng

Differential Revision: https://reviews.llvm.org/D87997
2020-12-01 17:17:50 +03:00
Kazushi (Jam) Marukawa 10b164d2f7 [VE] Add vmul and vdiv intrinsic instructions
Add vmul and vdiv intrinsic instructions and regression tests.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92377
2020-12-01 23:03:49 +09:00
Simon Pilgrim 00f4269cef [X86] Add PR48223 usubsat test case 2020-12-01 13:57:08 +00:00
Bhramar Vatsa fd679107d6
[InstCombine] Optimize away the unnecessary multi-use sign-extend
C.f. https://bugs.llvm.org/show_bug.cgi?id=47765

Added a case for handling the sign-extend (Shl+AShr) for multiple uses,
to optimize it away for an individual use,
when the demanded bits aren't affected by sign-extend.

https://rise4fun.com/Alive/lgf

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D91343
2020-12-01 16:54:00 +03:00
Roman Lebedev 94ead0190f
[InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold, 2
If the shift amount was undef for some lane, the shift amount in opposite
shift is irrelevant for that lane, and the new shift amount for that lane
can be undef.
2020-12-01 16:54:00 +03:00
AndreyChurbanov 6bf84871e9 [OpenMP] libomp: add UNLIKELY hints to rarely executed branches
Added UNLIKELY hint to one-time or rarely executed branches.
This improves performance of the library on some tasking benchmarks.

Differential Revision: https://reviews.llvm.org/D92322
2020-12-01 16:53:21 +03:00
Sanjay Patel b2cdd776e3 [InstCombine] add tests for sign-bit-shift-of-sub; NFC 2020-12-01 08:01:00 -05:00
Hans Wennborg 2ca4785ac7 Remove rm -f cortex-a57-misched-mla.s; hopefully the bots have all cycled past it now 2020-12-01 13:50:49 +01:00
Roman Lebedev 52533b52b8
Revert "[InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold"
It seems i have missed checklines, temporairly reverting,
will reland momentairly..

This reverts commit aa1aa13509.
2020-12-01 15:47:04 +03:00
Roman Lebedev 55c06a3070
[NFC][InstCombine] sext.ll: @test9: avoid only differently-cased names for values and block names 2020-12-01 15:33:12 +03:00
Roman Lebedev aa1aa13509
[InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold
If the shift amount was undef for some lane, the shift amount in opposite
shift is irrelevant for that lane, and the new shift amount for that lane
can be undef.
2020-12-01 15:13:08 +03:00
Roman Lebedev 075faa8d40
[NFC][InstCombine] Improve vector undef test coverage for sext(ashr(shl(trunc()))) fold 2020-12-01 15:13:07 +03:00
Roman Lebedev 8e29e20e0d
[InstCombine] Evaluate new shift amount for sext(ashr(shl(trunc()))) fold in wide type (PR48343)
It is not correct to compute that new shift amount in it's narrow type
and only then extend it into the wide type:

----------------------------------------
Optimization: PR48343 good
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sext %Y
  %n1 = sub width(%o0), %n0
  %n2 = sub width(%X), %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 2016
Optimization is correct!

----------------------------------------
Optimization: PR48343 bad
Precondition: (width(%X) == width(%r))
  %o0 = trunc %X
  %o1 = shl %o0, %Y
  %o2 = ashr %o1, %Y
  %r = sext %o2
=>
  %n0 = sub width(%o0), %Y
  %n1 = sub width(%X), %n0
  %n2 = sext %n1
  %n3 = shl %X, %n2
  %r = ashr %n3, %n2

Done: 1
ERROR: Domain of definedness of Target is smaller than Source's for i9 %r

Example:
%X i9 = 0x000 (0)
%Y i4 = 0x3 (3)
%o0 i4 = 0x0 (0)
%o1 i4 = 0x0 (0)
%o2 i4 = 0x0 (0)
%n0 i4 = 0x1 (1)
%n1 i4 = 0x8 (8, -8)
%n2 i9 = 0x1F8 (504, -8)
%n3 i9 = 0x000 (0)
Source value: 0x000 (0)
Target value: undef


I.e. we should be computing it in the wide type from the beginning.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48343
2020-12-01 15:13:07 +03:00
Roman Lebedev 799626b111
[NFC][InstCombine] Add PR48343 miscompiled testcase 2020-12-01 15:13:07 +03:00
Roman Lebedev 0e11f3ade5
[NFC][InstCombine] Autogenerate sext.ll test checklines 2020-12-01 15:13:06 +03:00
Roman Lebedev 15f8060f6f
[SimplifyCFG] FoldBranchToCommonDest: don't require that cmp of br is last instruction
There is no correctness need for that, and since we allow live-out
uses, this could theoretically happen, because currently nothing
will move the cond to right before the branch in those tests.
But regardless, lifting that restriction even makes the transform
easier to understand.

This makes the transform happen in 81 more cases (+0.55%)
)
2020-12-01 15:13:06 +03:00
Roman Lebedev b52029224c
[NFC][SimplifyCFG] fold-branch-to-common-dest: add tests with cond of br not being the last op 2020-12-01 15:13:05 +03:00
Simon Pilgrim 6dbd0d36a1 [DAG] Move vselect(icmp_ult, -1, add(x,y)) -> uaddsat(x,y) to DAGCombine (PR40111)
Move the X86 VSELECT->UADDSAT fold to DAGCombiner - there's nothing target specific about these folds.

The SSE42 test diffs are relatively benign - its avoiding an extra constant load in exchange for an extra xor operation - there are extra register moves, which is annoying as all those operations should commute them away.

Differential Revision: https://reviews.llvm.org/D91876
2020-12-01 11:56:26 +00:00
Sven van Haastregt 523775f967 [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2
The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

Differential Revision: https://reviews.llvm.org/D92091
2020-12-01 11:33:10 +00:00
Cullen Rhodes cba4accda0 [LV] Clamp VF hint when unsafe
In the following loop the dependence distance is 2 and can only be
vectorized if the vector length is no larger than this.

  void foo(int *a, int *b, int N) {
    #pragma clang loop vectorize(enable) vectorize_width(4)
    for (int i=0; i<N; ++i) {
      a[i + 2] = a[i] + b[i];
    }
  }

However, when specifying a VF of 4 via a loop hint this loop is
vectorized. According to [1][2], loop hints are ignored if the
optimization is not safe to apply.

This patch introduces a check to bail of vectorization if the user
specified VF is greater than the maximum feasible VF, unless explicitly
forced with '-force-vector-width=X'.

[1] https://llvm.org/docs/LangRef.html#llvm-loop-vectorize-and-llvm-loop-interleave
[2] https://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations

Reviewed By: sdesmalen, fhahn, Meinersbur

Differential Revision: https://reviews.llvm.org/D90687
2020-12-01 11:30:34 +00:00
Simon Pilgrim c63799fc52 [InstCombine][X86] Fold addsub intrinsic to fadd/fsub depending on demanded elts (PR46277) 2020-12-01 11:27:40 +00:00
Caroline Concatto 4b0ef2b075 [NFC][CostModel]Extend class IntrinsicCostAttributes to use ElementCount Type
This patch replaces the attribute  `unsigned VF`  in the class
IntrinsicCostAttributes by `ElementCount VF`.
This is a non-functional change to help upcoming patches to compute the cost
model for scalable vector inside this class.

Differential Revision: https://reviews.llvm.org/D91532
2020-12-01 11:12:51 +00:00
Kadir Cetinkaya e98d3be11c
[clang] Enable code completion of designated initializers in Compound Literal Expressions
PreferedType were not set when parsing compound literals, hence
designated initializers were not available as code completion suggestions.

This patch sets the preferedtype to parsed type for the following initializer
list.

Fixes https://github.com/clangd/clangd/issues/142.

Differential Revision: https://reviews.llvm.org/D92370
2020-12-01 12:06:48 +01:00
Florian Hahn efa9728a50 [ConstraintElimination] Decompose GEP %ptr, SHL().
Add support the decompose a GEP with an SHL operand.
2020-12-01 10:58:36 +00:00
Kazushi (Jam) Marukawa c3fe6ea22e [VE] Add vadd and vsub intrinsic instructions
Add vadd and vsub intrinsic instructions and regression tests.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92332
2020-12-01 19:57:22 +09:00
Simon Pilgrim 551a20bad9 [InstCombine][X86] Add test coverage showing failure to simplify addsub intrinsics to fadd/fsub
If we only use odd/even lanes then we just need fadd/fsub ops
2020-12-01 10:49:43 +00:00
Sjoerd Meijer f44ba25135 ExtractValue instruction costs
Instruction ExtractValue wasn't handled in
LoopVectorizationCostModel::getInstructionCost(). As a result, it was modeled
as a mul which is not really accurate. Since it is free (most of the times),
this now gets a cost of 0 using getInstructionCost.

This is a follow-up of D92208, that required changing this regression test.
In a follow up I will look at InsertValue which also isn't handled yet.

Differential Revision: https://reviews.llvm.org/D92317
2020-12-01 10:42:23 +00:00
David Green 09d82fa95f [AArch64] Update pass pipeline test. NFC 2020-12-01 10:40:04 +00:00
David Green 7923d71b4a [ARM] PREDICATE_CAST demanded bits
The PREDICATE_CAST node is used to model moves between MVE predicate
registers and gpr's, and eventually become a VMSR p0, rn. When moving to
a predicate only the bottom 16 bits of the sources register are
demanded. This adds a simple fold for that, allowing it to potentially
remove instructions like uxth.

Differential Revision: https://reviews.llvm.org/D92213
2020-12-01 10:32:24 +00:00
Jay Foad 839c9635ed [AMDGPU] Simplify some generation checks. NFC. 2020-12-01 10:15:32 +00:00
Hans Wennborg 52f3fac224 [gn build] Manually merge 40659cd 2020-12-01 11:15:05 +01:00
Georgii Rymar ea8c8a5097 [obj2yaml] - Teach tool to emit the "SectionHeaderTable" key and sort sections by file offset.
Currently when we dump sections, we dump them in the order,
which is specified in the sections header table.

With that the order in the output might not match the order in the file.
This patch starts sorting them by by file offsets when dumping.

When the order in the section header table doesn't match the order
in the file, we should emit the "SectionHeaderTable" key. This patch does it.

Differential revision: https://reviews.llvm.org/D91249
2020-12-01 12:59:15 +03:00
Jan Svoboda 398b729243 [clang][cli] Port HeaderSearch option flags to new option parsing system
Depends on D83697.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83940
2020-12-01 10:52:00 +01:00
Georgii Rymar ade2fbbfb0 [llvm-readobj][test] - Merge 2 test cases together.
This merges `invalid-attr-section-size.test` and `invalid-attr-version.test`
into `invalid-attributes-sec.test`.

This allows to have a single place where other related test cases can be added.

Differential revision: https://reviews.llvm.org/D92316
2020-12-01 12:51:07 +03:00
David Chisnall d1ed67037d [GNU ObjC] Fix a regression listing methods twice.
Methods synthesized from declared properties were being added to the
method lists twice.  This came from the change to list them in the
class's method list, which missed removing the place in CGObjCGNU that
added them again.

Reviewed By: lanza

Differential Revision: https://reviews.llvm.org/D91874
2020-12-01 09:50:18 +00:00
Georgii Rymar 82d9fb0ac1 [llvm-readobj] - Introduce `ObjDumper::reportUniqueWarning(const Twine &Msg)`.
This introduces the overload for `reportUniqueWarning` which allows
to avoid using `createError` in many places.

Differential revision: https://reviews.llvm.org/D92371
2020-12-01 12:36:44 +03:00
Jan Svoboda 8e41a688a5 [clang][cli] Port DependencyOutput option flags to new option parsing system
Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83694
2020-12-01 10:36:12 +01:00
Eugene Zhulenev 9edcedf7f2 [mlir] AsyncRuntime: disable threading until test flakiness is fixed
ExecutionEngine/LLJIT do not run globals destructors in loaded dynamic libraries when destroyed, and threads managed by ThreadPool can race with program termination, and it leads to segfaults.

TODO: Re-enable threading after fixing a problem with destructors, or removing static globals from dynamic library.

Differential Revision: https://reviews.llvm.org/D92368
2020-12-01 01:12:16 -08:00
Jan Svoboda 2b84efa000 [clang][cli] Port Frontend option flags to new option parsing system
Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83697
2020-12-01 10:02:08 +01:00
Jan Svoboda 88ab38449b [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf
This makes the options API composable, allows boolean flags to imply non-boolean values and makes the code more logical (IMO).

Differential Revision: https://reviews.llvm.org/D91861
2020-12-01 09:50:11 +01:00
Jan Svoboda 973843681b [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)
Reviewed By: Bigcheese, dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83211
2020-12-01 09:24:04 +01:00
Kristof Beyls 424fdbc3de collect_and_build_with_pgo.py: adapt to monorepo
Differential Revision: https://reviews.llvm.org/D92328
2020-12-01 09:16:12 +01:00
Georgii Rymar 87481068fd [llvm-readelf] - Switch to using from `reportWarning` to `reportUniqueWarning` in `DynRegionInfo`.
This is a part of the plan we had previously to convert all calls to
`reportUniqueWarning` and then rename it to just `reportWarning`.

I was a bit unsure about this particular change at first, because it doesn't add a
new functionality: seems it is impossible to trigger a warning duplication currently.

At the same time I find the idea of the plan mentioned very reasonable.
And with that we will be sure that `DynRegionInfo` can't report duplicate
warnings, what looks like a nice feature for possible refactorings and further tool development.

Differential revision: https://reviews.llvm.org/D92224
2020-12-01 11:09:30 +03:00