Commit Graph

159 Commits

Author SHA1 Message Date
Jeppe Johansen
6861cbcf16 Allow FoldShiftLdrStr for all sizes of LDR/STR, and disable it for references that post/pre increment the base register on Thumb-2 targets.
git-svn-id: trunk@26671 -
2014-02-04 17:29:13 +00:00
Jeppe Johansen
07b2982e77 Don't do ARM FoldShiftLdrStr peephole optimization if there's an offset in the reference.
Use UXTH+UXTB instructions instead of two shifts on processors that supports that.
Eliminate internalerror when constant pointers are typecast as arrays.

git-svn-id: trunk@26647 -
2014-02-01 13:29:35 +00:00
masta
3f8549365a Don't schedule LDRD on ARM
The load scheduler does not handle LDRD correctly right now, but it does
not prevent A_LDR with PF_D set from beeing scheduled.

git-svn-id: trunk@26637 -
2014-01-30 21:53:03 +00:00
Jeppe Johansen
257b1affaa Fixed previous fix of LsrAnd2Lsr optimization.
Added an extra condition for <ARMv6 processors in MLA/MLS optimization.

git-svn-id: trunk@26620 -
2014-01-29 22:22:58 +00:00
Jeppe Johansen
f773334374 Fixed LsrAnd2Lsr peephole optimization for ARM.
git-svn-id: trunk@26619 -
2014-01-29 21:35:28 +00:00
Jeppe Johansen
3b4f59c316 Fixed MLA/MLS peephole optimization and moved it to the generic ARM peephole optimizer.
git-svn-id: trunk@26613 -
2014-01-29 17:28:13 +00:00
Jeppe Johansen
184baa3f99 Fixed invalid peephole optimization of ADD/SUB(SP) instructions for ARMv7*M targets.
git-svn-id: trunk@26612 -
2014-01-29 17:12:57 +00:00
masta
9e0af11ad8 Rerun the peephole optimizer after removing the current instruction.
This lets the optimizer pickup on more possible optimizations.

git-svn-id: trunk@26606 -
2014-01-28 16:00:51 +00:00
masta
57ff589ec7 Always set p to the next instruction after removing p from asml.
Some time ago we introduced GetNextInstructionUsingReg, which might
return an instruction a couple of instructions away from our current
location. Most of the code then just returned the new instruction (hp1)
instead of the instruction following p. This could prevent the peephole
optimizer from finding possible optimizations.

git-svn-id: trunk@26605 -
2014-01-28 16:00:47 +00:00
masta
c644503daf Add MovLdr2Ldr peephole optimizer for ARM
The existing LdrLdr2LdrMov optimizer will generate a lot of
sequences like this:

ldr regA, [...]
mov regB, regA
ldr regB, [regB, ...]

this now gets changed to

ldr regA, [...]
ldr regB, [regA, ...]

this saves an instruction and might open up more possibilities for the load scheduler.

git-svn-id: trunk@26603 -
2014-01-28 13:20:35 +00:00
masta
77d12f61a2 Handle LDRD and STRD correctly in RegInInstruction for ARM
LDRD and STRD only have the first even numbered register in their instruction operands,
this additional code will also check for the register following it.
Example:
  ldrd r0, [r13]

The old code will only detect r0 as in use, not the implicit r1.

git-svn-id: trunk@26602 -
2014-01-28 13:20:26 +00:00
Jeppe Johansen
d24cbbf9f5 Changed debug information to dwarf for ARM_embedded, and set local minimum alignment to 4.
Fixed a bug where ARMv7M targets would not use the DIV instructions.
Moved many size-optimizing Thumb2 peephole optimizations to PostPeepHoleOptsCpu. Previously those optimizations could make it impossible to reuse the shared arm peephole optimizations.
Reenabled a fixed MLA/MLS peephole optimization.
Refactored some FindRegDealloc+regLoadedWithNewValue into RegEndOfLife calls.
Fixed some broken UXTB/UXTH optimizations. Previously they would also match UXT* instructions with ROR shifter ops.

git-svn-id: trunk@26198 -
2013-12-08 16:50:15 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
Jonas Maebe
10ae87f11c * fixed LdrLdr2LdrMov optimisation in case the first and second ldr have
a different size (disable it in that case) + test

git-svn-id: trunk@25778 -
2013-10-14 12:49:34 +00:00
Jonas Maebe
31a3122b91 * fixed LsrAnd2Lsr test by replacing the existing buggy check with comparing
the outcome of the original and the optimised sequence and seeing whether
    it's same + test

git-svn-id: trunk@25776 -
2013-10-14 12:49:28 +00:00
sergei
a5ae26da7e * Moved SkipEntryExitMarker method from ARM optimizer to the base one, since it is not target-dependent. Now it can be reused by other targets.
git-svn-id: trunk@25738 -
2013-10-10 21:12:49 +00:00
florian
cb1f38b0af * strd/ldrd are not supported by thumb
git-svn-id: trunk@25406 -
2013-09-03 21:09:13 +00:00
masta
ff95d42216 Fix ShiftShift2Shift 1 ARM-peephole optimizer
The previous code deleted the newly inserted instruction instead of the
existing one, which obviously broke code.

Assembly:
  mov r0, r0, lsr #23
  mov r0, r0, lsr #23

transformed into:
  mov r0, r0, lsr #23

expected was:
  mov r0, #0

The problem only shows up in the very unlikely case of two LSR/ASR or
two LSL following on each other and having a total shift of more than 31
bits.

This fixes test/opt/tarmshift.pp

I've also removed the {%norun} directive from tarmshift.pp as this test
does only make sense when it also runs.

git-svn-id: trunk@25374 -
2013-08-26 17:41:54 +00:00
florian
d4968e054b + arm: tsettings.instructionset
* the selected instruction set is now independent from the cpu type: e.g. armv7-a can perfectly execute thumb(2) code

git-svn-id: trunk@25370 -
2013-08-25 21:56:12 +00:00
florian
7cef301e84 * disable optimization LdrbAnd2Ldrb for arm thumb as it is currently done
git-svn-id: trunk@25356 -
2013-08-23 18:41:26 +00:00
florian
d5ddf39f73 * do not do the RedundantMovProcess optimization when the involved registers are r13 or r15 and if the target is arm thumb(2)
git-svn-id: trunk@25348 -
2013-08-23 15:22:53 +00:00
florian
8884f1c0bf * arm thumb2 supports only left shifted index registers up to 3 bits
git-svn-id: trunk@25346 -
2013-08-23 15:22:49 +00:00
Jonas Maebe
8ffb704b8c * don't split address labels from the instruction they belong with when
rescheduling (needed for GOT-less PIC)

git-svn-id: trunk@25324 -
2013-08-22 08:14:18 +00:00
florian
2806947a8f + FindRegAllocBackward
* search reg. allocations backward in RemoveSuperfluousMove because the changed instruction could be the first one in a list

git-svn-id: trunk@25289 -
2013-08-18 18:56:56 +00:00
Jeppe Johansen
fdcc68cfd7 Disabled preindex/postindexed peephole optimizations for Thumb and Thumb2
git-svn-id: trunk@25156 -
2013-07-21 14:21:16 +00:00
Jeppe Johansen
f3273fa87d Optimize Add/Sub+Ldr/Str by using preindexed references
git-svn-id: trunk@24789 -
2013-06-02 21:51:12 +00:00
Jeppe Johansen
2d823452b7 The scheduler pass of the ARM optimizer left markers in the instruction list, which could prevent further peephole optimizations
git-svn-id: trunk@24781 -
2013-06-02 16:37:41 +00:00
masta
8c32802fcf Added LdrbAnd2Ldrb Peephole optimizer for arm
Changes the following code:
  ldrb dst1, [REF]
  and  dst2, dst1, #255
  # dealloc dst1
to
  ldrb dst2, [REF]

git-svn-id: trunk@24672 -
2013-05-31 17:36:54 +00:00
masta
073cab8d86 Optimize FoldShiftLdrStr in ARM Peephole optimizer
The optimizer now juggles around the base and index register if that opens
up the possibility of folding the shift into the instruction.

This can only be done in the case of addressmode=AM_OFFSET, in case of
[AM_POSTINDEXED, AM_PREINDEXED] we can not move the base register, as this
would cause havoc and destruction.

git-svn-id: trunk@24645 -
2013-05-30 16:13:58 +00:00
Jeppe Johansen
c4263ced51 Disable one peephole optimization for Thumb
git-svn-id: trunk@24635 -
2013-05-30 12:05:27 +00:00
florian
c0d4f189e9 * and takes three operands
git-svn-id: trunk@23775 -
2013-03-10 16:16:50 +00:00
florian
be81b89147 * fix bugs in previous commit
git-svn-id: trunk@23774 -
2013-03-10 14:33:10 +00:00
florian
086ae4b999 Merge r22905 and r22906
git-svn-id: trunk@23773 -
2013-03-10 10:45:34 +00:00
florian
1eeeb309c7 * intial armv6m support, it is not working yet, constant pool insertation and conditional branch fixup is not working yet
git-svn-id: trunk@23682 -
2013-03-03 12:20:10 +00:00
masta
96ed4e7932 Fixed access to freed memory in ShiftShiftShift2ShiftShift 1a on ARM
ShiftShiftShift2ShiftShift tried to access a wrong and already freed
instruction the find out whatever a shift will result in a 0 result.

For some reason this only resulted in a bug on x86_64 linux host
crosscompiler builds.

git-svn-id: trunk@23624 -
2013-02-17 00:01:00 +00:00
florian
ef1c848198 * fix constant calculation for the AndAnd2And optimization if the first and is removed, noticed by Nico Erfurth
git-svn-id: trunk@23541 -
2013-01-29 20:39:22 +00:00
florian
9d76168b57 * refactored Bl2B condition code to make it more readable
git-svn-id: trunk@23464 -
2013-01-20 15:38:38 +00:00
florian
7184306a4c + option -Wx to generate thumb interworking safe code on arm
git-svn-id: trunk@23463 -
2013-01-20 15:26:59 +00:00
florian
3fff969ced * take care of instruction in between when doing ShiftShiftShift2ShiftShift optimizations
git-svn-id: trunk@23462 -
2013-01-20 14:58:03 +00:00
florian
f1b8fad6dc * make AndAnd2And working with other instructions in between
git-svn-id: trunk@23461 -
2013-01-20 14:57:59 +00:00
florian
fcef2dc3df * refactored some code and introduced usage of new method RegEndOfLife
git-svn-id: trunk@23460 -
2013-01-20 14:57:55 +00:00
florian
82f3ec7922 * if cs_opt_level3 is not set, limit lookahead of GetNextInstructionUsingReg to one instruction:
only -O3 means do the really slow optimizations

git-svn-id: trunk@23459 -
2013-01-20 14:57:51 +00:00
florian
a78af5b8fe + AndLslXsr2And and AndLsl2Lsl optimization
git-svn-id: trunk@23458 -
2013-01-20 14:57:46 +00:00
florian
ff522d7e18 * improve ShiftShiftShift2ShiftShift to look further ahead
* check register usage so the destination register can be different

git-svn-id: trunk@23457 -
2013-01-20 14:57:43 +00:00
florian
12d0c05ede * remove bic instructions after lsr if possible
git-svn-id: trunk@23456 -
2013-01-20 14:57:38 +00:00
florian
abfa6c1b43 * redo LsrAnd2Lsr optimization
git-svn-id: trunk@23413 -
2013-01-16 20:24:07 +00:00
masta
fe520c215b New ARM Peephole optimizer FoldShiftLdrStr
This one folds
      mov r1, r2, lsl #2
      ldr/ldrb r0, [r0, r1]
into
      ldr/ldrb r0, [r0, r2, lsl #2]

There is still some room for improvement, maybe it would be better to do this before
the register allocator runs, as we'll currently waste a register (r1 in the above example)
in many cases. That would also allow to to fold more operations, because currently if r2
gets reused between the mov and ldr we'll not be able to do the optimization.

git-svn-id: trunk@23408 -
2013-01-16 14:37:28 +00:00
florian
47d43750e4 * remove unused units from uses statements
git-svn-id: trunk@23306 -
2013-01-03 23:07:09 +00:00
florian
903f18ea38 * get rid of calls which redirect the program flow only, Bl2B optimization
git-svn-id: trunk@23279 -
2013-01-01 19:31:52 +00:00
florian
ff98d2567c * don't crash on thumb instructions with only two operands when optimizing ADD, SUB, AND statements
git-svn-id: trunk@23272 -
2013-01-01 12:29:48 +00:00