Commit Graph

159 Commits

Author SHA1 Message Date
florian
e88248d453 + comment to explain last commit 2024-03-31 22:33:22 +02:00
florian
bf1c674672 * don't remove align directives before case jump tables (they have the type alt_addr) 2024-03-31 22:15:08 +02:00
J. Gareth "Curious Kit" Moreton
d7d4b446c1 * FindRegAllocBackward will now return nil if it hits a dealloc for the register first 2024-02-11 21:39:19 +00:00
J. Gareth "Curious Kit" Moreton
1fafcbc125 * New "TryRemoveRegAlloc" optimisation utility 2024-02-11 21:39:19 +00:00
J. Gareth "Curious Kit" Moreton
3882066f23 * Speed optimisations for peephole register tracking functions 2024-02-03 20:30:46 +00:00
J. Gareth "Curious Kit" Moreton
3a2342fec4 * GetFinalDestination now calls SkipLabels on an alignment field 2023-12-29 14:17:08 +00:00
J. Gareth "Curious Kit" Moreton
7080bcc160 * UpdateUsedRegsAndOptimize improved to clear aligns that don't have
any live labels after them, and to better handle non-jump labels.
2023-11-25 20:47:44 +00:00
J. Gareth "Curious Kit" Moreton
da47c509df * Label and align optimisation is now only done in the post-peephole
stage rather than passes 1 and 2.
2023-11-25 20:47:44 +00:00
J. Gareth "Curious Kit" Moreton
47825610b8 * Pass 2 can now be run multiple times when
under -O3 and above.
2023-11-05 10:03:52 +00:00
J. Gareth "Curious Kit" Moreton
9ee672f9eb * New UpdateUsedRegsBetween utility subroutine 2023-02-24 19:39:39 +00:00
Jinyang He
12c4290ffe Add loongarch64 architecture support to compiler 2023-02-05 19:18:48 +00:00
J. Gareth "Curious Kit" Moreton
bab60d819f * x86: Refactored CMOV optimisations and permitted the use of constants in some cases. 2023-01-10 22:23:58 +00:00
J. Gareth "Curious Kit" Moreton
6af886c2b9 * Removed foolish inline from StripLabelFast 2023-01-10 22:23:58 +00:00
florian
4778973492 * further look ahead for temp. deallocation for FstpFldFstp2Fstp and FstpFld2<Nop> 2022-11-19 21:05:22 +01:00
J. Gareth "Curious Kit" Moreton
e7e4044bf0 * CollapseZeroDistJump no longer updates registers or strips dead labels, instead just setting p to p.Next 2022-11-18 17:20:20 +00:00
J. Gareth "Curious Kit" Moreton
627fb9a25b * x86: New jump/label tracking in CrossJump optimisations 2022-04-24 16:42:35 +00:00
J. Gareth "Curious Kit" Moreton
50a37d00e7 Debugging code in AllocRegBetween is now safer and more accurate, and p2 can no longer be nil 2022-01-04 12:18:34 +00:00
J. Gareth "Kit" Moreton
79f60923ba Bug fix to XMM block move optimisation 2021-09-26 14:09:29 +00:00
J. Gareth "Curious Kit" Moreton
6b26fa0f9a Added correction to AllocRegBetween 2021-09-16 20:34:22 +00:00
florian
94a15faa7f * patch by J. Gareth Moreton to fix faulty conditional jump logic, resolves #38985
git-svn-id: trunk@49576 -
2021-07-03 21:05:27 +00:00
florian
53effea0f5 + X86: JccMovJmpMov2MovSetcc optimization
git-svn-id: trunk@48993 -
2021-03-16 22:19:21 +00:00
pierre
0061301dbb Fix compilation with -dALLOCREGDEBUG
git-svn-id: trunk@48112 -
2021-01-08 11:13:43 +00:00
pierre
0189276a12 Raise internalerror inside RemoveCurentP is called with p=hp1, because it leads to using a class instance after it has been freed
git-svn-id: trunk@47689 -
2020-12-05 21:22:18 +00:00
florian
8fa62752d4 * patch by J. Gareth Moreton: minor refactor of reduced iterations of pass 1 of the assembler optimizer, resolves #37972
git-svn-id: trunk@47163 -
2020-10-23 20:05:18 +00:00
florian
91a6223281 * (slight modified) patch by J. Gareth Moreton to reduce number of assembler optimizer passes, resolves #37959
git-svn-id: trunk@47146 -
2020-10-20 20:03:25 +00:00
florian
112f8a41ad * Xtensa: set is_jmp flag so branch optimization works
git-svn-id: trunk@46960 -
2020-09-26 20:12:27 +00:00
florian
2c54477807 * patch by J. Gareth Moreton: introduce RemoveInstruction and make as much as possible use of RemoveCurrentP, resolves #37399
git-svn-id: trunk@46862 -
2020-09-13 19:35:09 +00:00
yury
2d8873d085 * Fixed TAOptObj.CollapseZeroDistJump to properly handle delay slots.
git-svn-id: trunk@45874 -
2020-07-28 23:27:42 +00:00
yury
2b86651914 * Re-enabled safe generic jump optimizations for mips.
git-svn-id: trunk@45873 -
2020-07-28 23:16:21 +00:00
florian
a172064767 * patch by J. Gareth Moreton: fix for incorrect alignment removal, resolves #37420
git-svn-id: trunk@45864 -
2020-07-26 14:41:50 +00:00
pierre
0e9fc31dd7 Also check that HP1 is a jump instruction with more than one operand to exit early
git-svn-id: trunk@45786 -
2020-07-15 08:34:18 +00:00
pierre
13afd5c6c7 Do not set value of stoploop to avoid infinite loop
git-svn-id: trunk@45785 -
2020-07-15 08:16:53 +00:00
pierre
cca536a86a * TAOptObj.MakeUnconditional: Set as internal error for MIPS cpu:
MIPS conditional instructions conntain the
     computation of the condition itself, so
     changing the instruction to unconditional
     should never be done.
  * TAOptObj.OptimizeConditionalJump: Return false early if
    the conditional instruction has more than one operand.

git-svn-id: trunk@45782 -
2020-07-14 05:52:54 +00:00
nickysn
edcc14a5ce * Z80: JR can be both conditional and uncoditional jump, just like JP
git-svn-id: trunk@45411 -
2020-05-17 23:38:23 +00:00
nickysn
b54d9cfecb * fixed IsJumpToLabelUncond for the Z80
git-svn-id: trunk@45397 -
2020-05-17 11:35:42 +00:00
florian
a084c8829f * patch by J. Gareth Moreton: refactor RemoveCurrentP
git-svn-id: trunk@45142 -
2020-04-27 19:27:16 +00:00
florian
991ce83a2b * patch by J. Gareth Moreton: conditional Jump Inversion stoploop variable, resolves #36680
git-svn-id: trunk@44144 -
2020-02-09 20:57:59 +00:00
yury
1b3a3a7983 * Removed lot of unused local vars. It is useful to turn on the notes in options. :)
git-svn-id: trunk@44053 -
2020-01-28 18:45:33 +00:00
Jeppe Johansen
7cfb87b325 - Handle jump optimizations on RISC-V
git-svn-id: trunk@43933 -
2020-01-13 22:42:39 +00:00
florian
872c22842e * do prefetching correctly
* more prefetching inserted
  * unnecessary/wrong UpdateUsedRegs removed

git-svn-id: trunk@43878 -
2020-01-06 20:59:24 +00:00
florian
599e2df71f o patch by J. Gareth Moreton, resolves r36371:
* This patch makes some minor improvements to the cross-platform code that deals with jump optimisations.
      More specifically, it attempts to do more in a single pass which has the nice side-effect of
      fixing a couple of minor mistakes (in some situations, it would erroneously remove an alignment entry).
      - Most improvements are with dealing with Jcc/JMP pairs and their equivalents on other platforms, by
      collapsing label clusters and stripping dead code as soon as it has enough information to do so, and being
      more intelligent before calling Continue to see if another optimisation can be performed in the same sitting.

      - RemoveDeadCodeAfterJump is now a function that returns True if a jump was found among the dead code,
      thus allowing the ability to flag the peephole optimizer for another iteration of Pass 1 - the
      destination label may have appeared earlier in the code and become dead as a result of the removal
      of the jump, thus opening up new optimisations with instructions that sat either side of the label.

      - Preliminary tests show that it does sometimes reduce the number of passes required to optimise a subroutine
      under -O3.

git-svn-id: trunk@43668 -
2019-12-09 20:58:31 +00:00
florian
7e6eeebdf0 o patch by J. Gareth Moreton, seeks to improve maintainability, safety and efficiency
in the peephole optimizer by slightly modifying some function headers based
    on their intended purpose, resolves #36353
    * Non-virtual methods and class methods that don't need to access any fields from
      the current object are now static methods, thus removing the hidden "Self"
      parameter and reducing overhead. This includes a large number of
      frequently-used functions such as SkipEntryExitMarker and SuperRegistersEqual.
    * GetNextInstruction, GetLastInstruction, SkipEntryExitMarker and
      SkipLabels have had their 'var' parameter changed to an 'out' parameter because
      they shouldn't depend on its input value. This will cause the compiler to throw warnings
      if you start using the value without initialising it first, and may open up optimisation
      opportunities in the future (e.g. storing written values in a temporary register
      and only writing it to the actual variable when the routine exits).

git-svn-id: trunk@43595 -
2019-11-26 22:09:33 +00:00
florian
af107ca8fe o patch by J. Gareth Moreton, resolves #36355
+ This patch serves to extend the JMP -> RET optimisation in OptPass2JMP by also doing the same
      for JMP -> MOV/RET, since there are often cases where the result (e.g. EAX) is set just
      prior to the function exiting.
    * RemoveDeadCodeAfterJump will now drop out if it detects SEH information -
      this stops exception information from being stripped if it is called on the final RET instruction.

git-svn-id: trunk@43592 -
2019-11-25 21:15:41 +00:00
pierre
17c422c3f2 Patch by Gareth Moreton.
* TAOptObj.CollapseZeroDistJump: Change hp1 to local variable,
     initialized as p.next, to avoid problems of dangling pointers
     revealed by use of "-CriotR -O2" compilation arguments.

git-svn-id: trunk@43554 -
2019-11-22 09:10:32 +00:00
florian
61bf55e0fe * define renamed
git-svn-id: trunk@43531 -
2019-11-21 19:58:48 +00:00
pierre
ff415ba39c Fixes by Gareth Moreton for problems exposed by use of -CriotR option
git-svn-id: trunk@43529 -
2019-11-21 10:00:20 +00:00
florian
6248a127ca * write assembler optimizer messages into output file if DEBUG_AOPTOBJ is set
git-svn-id: trunk@43521 -
2019-11-20 22:12:28 +00:00
florian
da54d0e8f7 + patch by J. Gareth Moreton: new method TAOptObj.CanDoJumpOpts and arm specific implementation
git-svn-id: trunk@43519 -
2019-11-20 22:12:27 +00:00
florian
f505822ab5 o patch by J. Gareth Moreton:
* fix jump optimizer for MIPS(EL).
    + New method called "MakeUnconditional" introduced that can do platform-specific changes

git-svn-id: trunk@43518 -
2019-11-20 22:12:26 +00:00
florian
d4f0658c02 * disable condition jump optimization on MIPS for now for the time being
git-svn-id: trunk@43486 -
2019-11-15 20:50:17 +00:00