Commit Graph

324 Commits

Author SHA1 Message Date
James Molloy
bd7c3fb3bf [LSR] Don't try and create post-inc expressions on non-rotated loops
If a loop is not rotated (for example when optimizing for size), the latch is not the backedge. If we promote an expression to post-inc form, we not only increase register pressure and add a COPY for that IV expression but for all IVs!

Motivating testcase:

    void f(float *a, float *b, float *c, int n) {
      while (n-- > 0)
        *c++ = *a++ + *b++;
    }

It's imperative that the pointer increments be located in the latch block and not the header block; if not, we cannot use post-increment loads and stores and we have to keep both the post-inc and pre-inc values around until the end of the latch which bloats register usage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278658 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-15 07:53:03 +00:00
Ron Lieberman
26d2a23314 Fix unsupported relocation type R_HEX_6_X' for symbol .rodata
LowerTargetConstantPool is not properly setting the TargetFlag to indicate
desired relocation. Coding error, the offset parameter was omitted, so the
TargetFlag was used as the offset, and the TargetFlag defaulted to zero.

This only affects -fpic compilation, and only those items created in a
Constant Pool, for example a vector of constants. Halide ran into this issue.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278614 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-13 23:41:11 +00:00
Krzysztof Parzyszek
4110644365 [Hexagon] Allow non-returning calls in hardware loops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 21:14:25 +00:00
Krzysztof Parzyszek
3c99845d54 If-conversion incorrectly calculates liveness of redefined registers
Differential Revision: https://reviews.llvm.org/D23207


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 18:42:06 +00:00
Krzysztof Parzyszek
cf9748d82d [Hexagon] Skip byval arguments when checking parameter attributes
From the point of view of register assignment, byval parameters are
ignored: a byval parameter is not going to be assigned to a register,
and it will not affect the assignments of subsequent parameters.
When matching registers with parameters in the bit tracker, make sure
to skip byval parameters before advancing the registers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278375 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 18:15:16 +00:00
Kyle Butt
c04b985f53 Codegen: Tail Merge: Be less aggressive with special cases.
This change makes it possible for tail-duplication and tail-merging to
be disjoint. By being less aggressive when merging during layout, there are no
overlapping cases between tail-duplication and tail-merging, provided the
thresholds are disjoint.

There is a remaining TODO to benchmark the succ_size() test for non-layout tail
merging.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278265 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 18:36:18 +00:00
Krzysztof Parzyszek
30725941e1 [Hexagon] Simplify the SplitConst32/64 pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278256 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 18:05:47 +00:00
Krzysztof Parzyszek
570eecd0be [Hexagon] Add extra patterns for single-precision min/max instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278252 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 17:56:24 +00:00
Krzysztof Parzyszek
3b54bd1701 [Hexagon] Use integer instructions for floating point immediates
Floating point instructions use general purpose registers, so the few
instructions that can put floating point immediates into registers are,
in fact, integer instruction. Use them explicitly instead of having
pseudo-instructions specifically for dealing with floating point values.

Simplify the constant loading instructions (from sdata) to have only two:
one for 32-bit values and one for 64-bit values: CONST32 and CONST64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278244 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 16:46:36 +00:00
Krzysztof Parzyszek
e19c2467cc [Hexagon] Add pattern for 64-bit mulhs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278040 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-08 19:24:25 +00:00
Krzysztof Parzyszek
24c0d9d17f [Hexagon] Validate register class when doing bit simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277740 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 17:56:19 +00:00
Krzysztof Parzyszek
14ae142500 [Hexagon] Clear kill flags from modified registers in peephole optimizer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 14:17:16 +00:00
Krzysztof Parzyszek
8ff1935865 [Hexagon] Generate COPY/REG_SEQUENCE more aggressively for vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03 18:35:48 +00:00
Krzysztof Parzyszek
c3332e48f0 [Hexagon] Do not check alignment for unsized types in isLegalAddressingMode
When the same base address is used to load two different data types, LSR
would assume a memory type of "void". This type is not sized and has no
alignment information. Checking for it causes a crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277601 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03 15:06:18 +00:00
Krzysztof Parzyszek
8d96db9629 [Hexagon] Recognize vcombine in copy propagation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277528 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 21:49:20 +00:00
Krzysztof Parzyszek
1b1291fbbb [Hexagon] Prefer _io over _rr for 64-bit store with constant offset
Identify patterns where the address is aligned to an 8-byte boundary,
but both the base address and the constant offset are both proper
multiples of 4. In such cases, extract Base+4 into a separate instruc-
tion, and use S2_storerd_io, instead of using S4_storerd_rr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277497 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 18:50:05 +00:00
Ron Lieberman
16082a39ea [Hexagon] Generate vector printing instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 19:36:39 +00:00
Krzysztof Parzyszek
c765d85307 [Hexagon] Check for offset overflow when reserving scavenging slots
Scavenging slots were only reserved when pseudo-instruction expansion in
frame lowering created new virtual registers. It is possible to still
need a scavenging slot even if no virtual registers were created, in cases
where the stack is large enough to overflow instruction offsets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277355 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 17:15:30 +00:00
Michael Kuperstein
9d2d4392e4 [Hexagon] Fix test that uses -debug-only to require asserts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277218 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 21:44:33 +00:00
Krzysztof Parzyszek
83fd8feb00 [Hexagon] Testcase for not merging stores into a misaligned store
The DAG combiner will try to merge consecutive stores into a bigger
store, unless the resulting store is not fast. Misaligned vector stores
are allowed on Hexagon, but are not fast. Add a testcase to make sure
this type of merging does not occur.

Patch by Pranav Bhandarkar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277182 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 17:55:37 +00:00
Krzysztof Parzyszek
227b764c52 Revert r277178, the actual change had already been applied
Will submit another patch with the testcase only.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 17:50:47 +00:00
Krzysztof Parzyszek
36b1b46f1c [Hexagon] Misaligned loads and stores are not fast
The DAG combiner tries to merge stores to adjacent vector wide memory
locations by creating stores which are integral multiples of the vector
width. Discourage this by informing it that this is slow. This should
not affect legalization passes, because all of them ignore the "Fast"
argument.

Patch by Pranav Bhandarkar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277178 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 17:45:16 +00:00
Brendon Cahoon
c1359c9fbb MachinePipeliner pass that implements Swing Modulo Scheduling
Software pipelining is an optimization for improving ILP by
overlapping loop iterations. Swing Modulo Scheduling (SMS) is
an implementation of software pipelining that attempts to
reduce register pressure and generate efficient pipelines with
a low compile-time cost.

This implementaion of SMS is a target-independent back-end pass.
When enabled, the pass should run just prior to the register
allocation pass, while the machine IR is in SSA form. If the pass
is successful, then the original loop is replaced by the optimized
loop. The optimized loop contains one or more prolog blocks, the
pipelined kernel, and one or more epilog blocks.

This pass is enabled for Hexagon only. To enable for other targets,
a couple of target specific hooks must be implemented, and the
pass needs to be called from the target's TargetMachine
implementation.

Differential Review: http://reviews.llvm.org/D16829


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 16:44:44 +00:00
Krzysztof Parzyszek
a6ad276d07 [Hexagon] Custom lower VECTOR_SHUFFLE and EXTRACT_SUBVECTOR for HVX
If the mask of a vector shuffle has alternating odd or even numbers
starting with 1 or 0 respectively up to the largest possible index
for the given type in the given HVX mode (single of double) we can
generate vpacko or vpacke instruction respectively.

E.g.
  %42 = shufflevector <32 x i16> %37, <32 x i16> %41,
                      <32 x i32> <i32 1, i32 3, ..., i32 63>
  is %42.h = vpacko(%41.w, %37.w)

Patch by Pranav Bhandarkar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277168 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 16:44:27 +00:00
Krzysztof Parzyszek
1f44345f2c [Hexagon] Improve balancing of address calculation
Rebalances address calculation trees and applies Hexagon-specific
optimizations to the trees to improve instruction selection.

Patch by Tobias Edler von Koch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277151 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29 15:15:35 +00:00
Krzysztof Parzyszek
5559171657 [Hexagon] Implement MI-level constant propagation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277028 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 20:01:59 +00:00
Krzysztof Parzyszek
18fcd7fd21 [Hexagon] Insert CFI instructions before throwing calls
Normally, CFI instructions should be inserted after allocframe, but
if allocframe is in the same packet with a call, the CFI instructions
should be inserted before that packet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 19:13:46 +00:00
Krzysztof Parzyszek
ca740c1356 [Hexagon] Find speculative loop preheader in hardware loop generation
Before adding a new preheader block, check if there is a candidate block
where the loop setup could be placed speculatively. This will be off by
default.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276919 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 21:20:54 +00:00
Krzysztof Parzyszek
6d5ee09dd7 [Hexagon] Do not optimize volatile stack spill slots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276916 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 20:50:42 +00:00
Krzysztof Parzyszek
43492b2a7a [Hexagon] Post-increment loads/stores enhancements
- Generate vector post-increment stores more aggressively.
- Predicate post-increment and vector stores in early if-conversion.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276800 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 20:30:30 +00:00
Krzysztof Parzyszek
a628d047d1 [Hexagon] Gracefully handle reg class mismatch in HexagonLoopReschedule
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276793 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 19:17:13 +00:00
Krzysztof Parzyszek
aa3e2e6820 [Hexagon] Rerun bit tracker on new instructions in RIE
Consider this case:
  vreg1 = A2_zxth vreg0   (1)
  ...
  vreg2 = A2_zxth vreg1   (2)

Redundant instruction elimination could delete the instruction (1)
because the user (2) only cares about the low 16 bits. Then it could
delete (2) because the input is already zero-extended. The problem
is that the properties allowing each individual instruction to be
deleted depend on the existence of the other instruction, so either
one can be deleted, but not both.
The existing check for this situation in RIE was insufficient. The
fix is to update all dependent cells when an instruction is removed
(replaced via COPY) in RIE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276792 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 19:08:45 +00:00
Krzysztof Parzyszek
17a42256ee [Hexagon] Bitwise operations for insert/extract word not simplified
Change the bit simplifier to generate REG_SEQUENCE instructions in
addition to COPY, which will handle cases of word insert/extract.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276787 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 18:30:11 +00:00
Krzysztof Parzyszek
b450d54a80 [Hexagon] Add support for proper handling of H and L constraints
H -> High part of reg pair.
L -> Low part of reg pair.

Patch by Sundeep Kushwaha.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276773 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 17:31:02 +00:00
Krzysztof Parzyszek
94d45176f8 [Hexagon] Add target feature to generate long calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276638 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 14:42:11 +00:00
Krzysztof Parzyszek
262370bdcc [Hexagon] Use loop data prefetch on Hexagon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276422 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 14:22:43 +00:00
Krzysztof Parzyszek
4cb51c5c01 [Hexagon] Handle returning small structures by value
This is compliant with the official ABI, but allows experimentation with
calling conventions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275822 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 17:30:41 +00:00
Krzysztof Parzyszek
a7c00b136c [Hexagon] Enable .cur formation in MISched for Hexagon V60
Schedule a load and its use in the same packet in MISched. Previously,
isResourceAvailable was returning false for dependences in the same
packet, which prevented MISched from packetizing a load and its use in
the same packet for v60.

Patch by Ikhlas Ajbar.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275804 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 16:05:27 +00:00
Krzysztof Parzyszek
56af121d06 [Hexagon] Use timing class info as tie-breaker in machine scheduler
Patch by Sirish Pande.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 15:17:10 +00:00
Krzysztof Parzyszek
98b655feba [Hexagon] HexagonMachineScheduler should account for resources
The machine scheduler needs to account for available resources
more accurately in order to avoid scheduling an instruction that
forces a new packet to be created.

This occurs in two ways: First, an instruction without an available
resource may have a large priority due to other metrics and be
scheduled when there are other instructions with available resources.
Second, an instruction with a non-zero latency may become available
prematurely. In both these cases, we attempt change the priority
in order to allow a better instruction to be scheduled.

Patch by Brendon Cahoon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275793 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 14:52:13 +00:00
Krzysztof Parzyszek
9547556e81 [Hexagon] Fix zero latency instructions with multiple predecessors
An instruction may have multiple predecessors that are candidates
for using .cur. However, only one of them can use .cur in the
packet. When this case occurs, we need to make sure that only
one of the dependences gets a 0 latency value.

Patch by Brendon Cahoon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275790 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 14:23:10 +00:00
Krzysztof Parzyszek
733cec8f05 [Hexagon] Improve patterns with stack-based addressing
- Treat bitwise OR with a frame index as an ADD wherever possible, fold it
  into addressing mode.
- Extend patterns for memops to allow memops with frame indexes as address
  operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275569 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 15:35:52 +00:00
Krzysztof Parzyszek
1a360b3be9 [Hexagon] Packetize function call arguments with tail call instructions
On Hexagon is it legal to packetize the instructions setting up call
arguments with the call instruction itself. This was already done,
except for tail calls. Make sure tail calls are handled as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 19:30:55 +00:00
Krzysztof Parzyszek
339dc3dc8f [Hexagon] Equally-sized vectors are equivalent in ISel (except vNi1)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273885 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 15:08:22 +00:00
Krzysztof Parzyszek
99719f40ee [Hexagon] Simplify (+fix) instruction selection for indexed loads/stores
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273733 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 21:27:17 +00:00
Krzysztof Parzyszek
c7a10fc5ed [Hexagon] Add SDAG preprocessing step to expose shifted addressing modes
Transform: (store ch addr (add x (add (shl y c) e)))
       to: (store ch addr (add x (shl (add y d) c))),
where e = (shl d c) for some integer d.
The purpose of this is to enable generation of loads/stores with
shifted addressing mode, i.e. mem(x+y<<#c). For that, the shift
value c must be 0, 1 or 2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 20:08:27 +00:00
Rafael Espindola
5e5a33df9e Start using shouldAssumeDSOLocal on Hexagon.
Include a token test showing that access to private is now the same as
to internal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273457 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 19:09:14 +00:00
Krzysztof Parzyszek
065537a5a0 [Hexagon] Handle expansion of cmpxchg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273432 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 16:07:10 +00:00
Krzysztof Parzyszek
fd1e14e505 [Hexagon] Enable the post-RA scheduler
The aggressive anti-dependency breaker can rename the restored callee-
saved registers. To prevent this, mark these registers are live on all
paths to the return/tail-call instructions, and add implicit use operands
for them to these instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270898 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 19:44:28 +00:00
Krzysztof Parzyszek
fa30381518 When looking for a spill slot in reg scavenger, find one that matches RC
When looking for an available spill slot, the register scavenger would stop
after finding the first one with no register assigned to it. That slot may
have size and alignment that do not meet the requirements of the register
that is to be spilled. Instead, find an available slot that is the closest
in size and alignment to one that is needed to spill a register from RC.

Differential Revision: http://reviews.llvm.org/D20295


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269969 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 18:16:00 +00:00