Commit Graph

189 Commits

Author SHA1 Message Date
florian
9b18e39c81 * enable Lea2AddBase and Lea2AddIndex in TX86AsmOptimizer.PostPeepholeOptLea as we have flag tracking now
* some flag allocations fixed

git-svn-id: trunk@38501 -
2018-03-11 20:30:09 +00:00
florian
5fbecc5501 + use TX86AsmOptimizer.OptPass1SHLSAL on x86-64
git-svn-id: trunk@38499 -
2018-03-11 14:35:22 +00:00
florian
47927f053a * factored out TX86AsmOptimizer.OptPass1SHLSAL
git-svn-id: trunk@38498 -
2018-03-11 14:35:19 +00:00
florian
78878f59b1 + generic TAOptObj.AllocRegBetween
- removed x86 specific AllocRegBetween

git-svn-id: trunk@38445 -
2018-03-07 22:17:35 +00:00
florian
c5f8567ed7 * getsubreg => getsupreg
git-svn-id: trunk@38344 -
2018-02-25 15:34:14 +00:00
florian
fc6c0e8ef4 + AndShlToShl optimization
* moved topsize2memsize to cpubase

git-svn-id: trunk@38343 -
2018-02-25 15:34:12 +00:00
florian
6e811d057c * MovOpMov2Op cannot be applied for L, Q, Q as operand sizes
+ test

git-svn-id: trunk@38337 -
2018-02-25 10:19:52 +00:00
florian
e92422383a * compilation fixed
git-svn-id: trunk@38280 -
2018-02-18 09:29:36 +00:00
florian
91514da267 * factored out TX86AsmOptimizer.PostPeepholeOptCall
+ use TX86AsmOptimizer.PostPeepholeOptCall on x86-64

git-svn-id: trunk@38278 -
2018-02-17 23:25:01 +00:00
florian
1b3627add1 + peephole optimization MovMov2Mov 5
git-svn-id: trunk@38273 -
2018-02-17 21:10:51 +00:00
florian
5eb59196d5 * remove sequential moves to the same register
+ test

git-svn-id: trunk@38267 -
2018-02-17 12:45:17 +00:00
florian
99f1fe54af * check for registers removed which is not needed anymore
git-svn-id: trunk@38265 -
2018-02-17 12:45:13 +00:00
florian
810acd82b2 * patch by J. Gareth Moreton that makes some improvements to the Peephole Optimizer for x86 and x86-64 code, as well as some cleanup with formatting, code syntax consistency, and debug messages.
- xorq %reg,%reg (identical registers) is now changed to xorl %reg,%reg if doing so removes the REX prefix.
  - movw %bx,%ax; andl $0xffff,%eax, for example, is now changed to movzwl %bx,%eax as long as a conditional operation doesn't follow 'and' (checks to see if the CPU flags are in use).
  - movzbq and movzwq get optimised to movzbl and movzwl respectively if doing so removes the REX prefix.
  - Removal of optimisation code that zero-extends from 32-bit to 64-bit, because there isn't actually a valid combination of opcodes for MOVZX that allows that (for registers,
    just use  MOV). This is not the case with MOVSX.
  - movq is now optimised to movl even if the CPU flags are in use (this stops mov %reg,0 from being optimised to xor %reg,%reg if doing so breaks an algorithm that relies on them).
  - Fixed typo in peephole message regarding movq to movl (it said movd instead).
  - Made the peephole debug messages more consistent in formatting, some of which now have more detail.
* small fixes of the patch

git-svn-id: trunk@38070 -
2018-01-28 14:41:54 +00:00
florian
10ea652493 * fix for #32576
+ test case

git-svn-id: trunk@38069 -
2018-01-28 13:26:49 +00:00
florian
93353d8d79 * typo
git-svn-id: trunk@38068 -
2018-01-28 13:26:47 +00:00
florian
674398c5a5 * i8086 compilation fixed after r37572
git-svn-id: trunk@37573 -
2017-11-11 13:25:02 +00:00
florian
73fda1ccb6 * factored out OptPass1Sub
+ make use of OptPass1Sub on x86_64 and i8086 as well

git-svn-id: trunk@37572 -
2017-11-10 20:55:22 +00:00
florian
4da4b768ec * factored out PostPeepholeOptTest
+ use PostPeepholeOptTest on x86-64

git-svn-id: trunk@37551 -
2017-11-04 19:10:14 +00:00
florian
3097eaf8ee * made PostPeepholeOptMov a function
git-svn-id: trunk@37550 -
2017-11-04 19:10:12 +00:00
florian
a7ea7fb569 * factored out PostPeepholeOptCmp
+ use PostPeepholeOptCmp for x86_64

git-svn-id: trunk@37549 -
2017-11-04 19:10:09 +00:00
nickysn
80226e3af4 + added an optimization pass, that optimizes x86 references
git-svn-id: trunk@37494 -
2017-10-20 15:55:55 +00:00
florian
ce7487b7de o patch by J. Gareth "Kit" Moreton, resolves partially issue #32037
o improves readibility of TX86AsmOptimizer.OptPass1MOV and fixes some spelling mistakes
  + Optimization MovAnd2Mov 2
  + extended Optimization MovTestJxx2TestMov and MovTestJxx2ovTestJxx to take care of and as well
  + Peephole Optimization: movq x,%reg -> movd x,%reg

git-svn-id: trunk@37377 -
2017-10-01 18:40:11 +00:00
florian
15b617546e + call TX86AsmOptimizer.OptPass1VOP for logical operations as well
git-svn-id: trunk@37367 -
2017-10-01 14:40:21 +00:00
florian
05ecd784f2 * factored out OptPass1LEA and use it for x86-64 as well
+ LEAMov2LEA optimization

git-svn-id: trunk@37199 -
2017-09-13 20:40:32 +00:00
florian
22956c4393 + TX86AsmOptimizer.OptPass1OP
git-svn-id: trunk@36365 -
2017-05-28 13:49:43 +00:00
florian
c83e6991d5 * properly check number of operands
git-svn-id: trunk@36322 -
2017-05-25 12:44:30 +00:00
yury
884cb758e7 * Ensure the number of operands is 2 for MOVXX instructions in OptPass1MOVXX. Otherwise the classic MOVSD/W/B no-operand instructions (REP MOVSX) cause AV during checks of operands. The AV is thrown when trying to compile ucomplex.pp with -Cfsse3.
* Also fixed generation of debug comments in OptPass1MOVXX.

git-svn-id: trunk@36295 -
2017-05-22 15:20:18 +00:00
florian
3c5ec4e76c * allocate register correctly for "MovMov2Mov 2"
+ more debug messages
* debug message naming fixed

git-svn-id: trunk@36284 -
2017-05-21 15:06:22 +00:00
florian
1ffdf02b94 + Ch_*Op4
+ op_const_reg_reg_reg

git-svn-id: trunk@36279 -
2017-05-21 11:12:55 +00:00
florian
0f16f6d94d + OptPass1MOVXX
git-svn-id: trunk@36209 -
2017-05-14 20:59:10 +00:00
florian
535c990233 + OptPass1MOVAP
git-svn-id: trunk@36203 -
2017-05-13 21:48:44 +00:00
florian
3ade6ae9b8 + Mov2Nop optimization
git-svn-id: trunk@36201 -
2017-05-13 09:58:27 +00:00
florian
f4a29bb75d * moved InstructionLoadsFromReg and RegReadByInstruction from TCpuAsmOptimizer (i386) to TX86AsmOptimizer
git-svn-id: trunk@36200 -
2017-05-13 09:58:25 +00:00
florian
f93b784895 * make fullcycle for i8086 fixed
git-svn-id: trunk@36164 -
2017-05-09 19:53:06 +00:00
florian
52d3756c26 * factored out OptPass1Movx and merged i386 and x86-64 version
git-svn-id: trunk@36159 -
2017-05-08 20:44:27 +00:00
florian
06c4c651fd * factored out PrePeepholeOptSxx
+ x86-64 uses PrePeepholeOptSxx now as well

git-svn-id: trunk@36158 -
2017-05-08 20:44:24 +00:00
florian
74b338266d * ifdef cmov optimization, as i8086 has no cpu_capabilities
git-svn-id: trunk@36150 -
2017-05-07 16:18:44 +00:00
florian
f8d517be70 * make TX86AsmOptimizer.IsExitCode usable for x86-64 as well
git-svn-id: trunk@36148 -
2017-05-07 16:18:40 +00:00
florian
4a43d992f5 * unified usage of MatchOpType
* fixed generic MatchOpType

git-svn-id: trunk@36145 -
2017-05-07 16:18:33 +00:00
florian
7afe762d22 * factored out OptPass2Jcc assembler optimization
* OptPass2Jcc now used by x86-64 as well
* remove orphaned alignments if the label is not used anymore after cmov is used

git-svn-id: trunk@36143 -
2017-05-07 12:45:48 +00:00
florian
e3f0b338d4 * SkipLabels moved to aoptutils
* factored out OptPass2Jmp assembler optimization
* OptPass2Jmp now used by x86-64 as well

git-svn-id: trunk@36141 -
2017-05-06 21:07:02 +00:00
florian
f985971a62 * apply mov reg1, mem1; cmp x, mem1 to mov reg1, mem1; cmp x, reg1 also for test
git-svn-id: trunk@36138 -
2017-05-06 18:47:47 +00:00
nickysn
b882ba5fd2 + also recognize sbb reg,reg as writing a new value in the register in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36119 -
2017-05-05 14:24:13 +00:00
nickysn
0e0e5c0caf + support the flags register and its subregisters in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36114 -
2017-05-05 12:17:50 +00:00
nickysn
85fbbec319 + recognize xor reg,reg (same register twice) and sub reg,reg as writing a new
value to reg in TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36112 -
2017-05-05 11:01:34 +00:00
nickysn
aa93259463 + support the lahf,fstsw and fnstsw instructions in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36087 -
2017-05-04 16:02:01 +00:00
nickysn
92cc447326 + support the aam instruction in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36083 -
2017-05-04 15:34:48 +00:00
nickysn
2431b1fa19 + support the lodsb,lodsw,lodsd and lodsq instructions in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36082 -
2017-05-04 15:12:37 +00:00
nickysn
6b7593d7d0 + support the SETcc instructions in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36081 -
2017-05-04 14:43:18 +00:00
nickysn
e10f184b74 + support lds,les,lfs,lgs and lss in TX86AsmOptimizer.RegLoadedWithNewValue
git-svn-id: trunk@36079 -
2017-05-04 14:08:36 +00:00
nickysn
eac74f5a81 + support the cwd,cdq,cqo and cbw instructions in
TX86AsmOptimizer.RegLoadedWithNewValue (cwde and cdqe don't need special
  support)

git-svn-id: trunk@36077 -
2017-05-04 12:15:40 +00:00
nickysn
1a139b951d + properly support the one operand version of imul and mul in
TX86AsmOptimizer.RegLoadedWithNewValue

git-svn-id: trunk@36068 -
2017-05-03 15:07:21 +00:00
nickysn
65960048c8 * fixed TX86AsmOptimizer.RegLoadedWithNewValue for 3-operand imul, where the
second operand is a memory reference

git-svn-id: trunk@36067 -
2017-05-03 13:43:16 +00:00
nickysn
1f5aec6d3d + make use of the Reg1WriteOverwritesReg2Entirely and Reg1ReadDependsOnReg2
instead of SuperRegistersEqual in TX86AsmOptimizer.RegLoadedWithNewValue, so
  it returns correct information for the 16-bit and 8-bit subregisters
  (including AH,BH,CH and DH)

git-svn-id: trunk@36066 -
2017-05-03 12:14:30 +00:00
nickysn
66c350d8d2 * fixed access violation bug in TX86AsmOptimizer.RegLoadedWithNewValue for the
A_MOVSD string instruction

git-svn-id: trunk@35995 -
2017-04-28 13:09:27 +00:00
nickysn
e6e55b3004 + added function TX86AsmOptimizer.Reg1ReadDependsOnReg2, which checks whether
two registers are independent (taking into account AH vs AL)

git-svn-id: trunk@35991 -
2017-04-28 09:24:48 +00:00
nickysn
33f9b36a54 + added and implemented function TX86AsmOptimizer.Reg1WriteOverwritesReg2Entirely,
which takes into account how 16-bit and 8-bit subregisters work on the x86
  (the new function is not used for now, but is probably going to replace
  SuperRegistersEqual in a few specific places (in RegLoadedWithNewValue),
  so that our register tracking becomes more accurate for 8-bit and 16-bit
  subregisters)

git-svn-id: trunk@35990 -
2017-04-27 22:30:47 +00:00
yury
94a65e99f1 * Removed unused var.
git-svn-id: trunk@35546 -
2017-03-09 13:49:46 +00:00
florian
f68558b88c * factored out TX86AsmOptimizer.OptPass2Imul
git-svn-id: trunk@35252 -
2017-01-06 22:25:24 +00:00
florian
ebb2b81f79 * FoldLea optimizes more cases
git-svn-id: trunk@35251 -
2017-01-06 22:25:22 +00:00
florian
781d6f31a8 * more getsupreg(...)<>/=getsupreg(...) replaced by SuperRegisterEqual which is more safe, the former could break as the register could have different register types
git-svn-id: trunk@34746 -
2016-10-20 18:32:23 +00:00
florian
cf2a3d8160 + new debug message
* turn off accidently turned on DEBUG_AOPTCPU

git-svn-id: trunk@34731 -
2016-10-16 16:37:51 +00:00
florian
fe0ce2f456 * TX86AsmOptimizer.OptPass1MOV should be left, after an optimization has been carried out, instead the outer loop should call it again, resolves issue #30277
git-svn-id: trunk@34724 -
2016-10-15 19:36:18 +00:00
florian
239c6639d7 + additional debug message
git-svn-id: trunk@34722 -
2016-10-15 17:51:09 +00:00
florian
76961dbc70 * fixes MovOpMov2Op
git-svn-id: trunk@34721 -
2016-10-15 15:03:27 +00:00
florian
8e9f4af801 * fixed checking of operands of MovOpMov2Op
* MovOpMov2Op optimization got proper naming

git-svn-id: trunk@34719 -
2016-10-15 15:03:24 +00:00
florian
4109f88e08 * AllocRegBetween always extends the processed register to the whole super register and takes care of this while removing (de)/allocs
git-svn-id: trunk@34718 -
2016-10-15 15:03:23 +00:00
florian
57ca8647b3 * better peephole optimization tracing
git-svn-id: trunk@34698 -
2016-10-09 13:41:38 +00:00
Jeppe Johansen
348c373e9f Fixed two bugs in the x86 peephole optimizer.
git-svn-id: trunk@34497 -
2016-09-10 19:13:48 +00:00
florian
d31d24ed16 * r33995 was not complete
git-svn-id: trunk@33997 -
2016-06-16 19:26:43 +00:00
florian
1cbae41cab * proper fix for the issue detected in r33945
git-svn-id: trunk@33995 -
2016-06-15 20:43:52 +00:00
florian
2890927b10 * MovMov2MovMov1 requires that the allocation of the first register is extended
git-svn-id: trunk@33948 -
2016-06-11 19:54:18 +00:00
Jonas Maebe
cf6c7a0a1d * missing instruction type check
git-svn-id: trunk@33945 -
2016-06-10 17:59:18 +00:00
florian
7f44774852 * i386 uses OptPass1And from aoptx86
git-svn-id: trunk@33936 -
2016-06-07 20:01:13 +00:00
florian
ff506eb219 * enabled And2Test optimization
git-svn-id: trunk@33935 -
2016-06-07 20:01:11 +00:00
florian
a5fc8b629a * factored out OptPass1AND from x86-64 and moved it to aoptx86
git-svn-id: trunk@33934 -
2016-06-07 20:01:09 +00:00
florian
5e8e21c1be * factored out OpPass2MOV code, x86-64 uses it as well now
git-svn-id: trunk@33932 -
2016-06-06 21:18:24 +00:00
florian
6609e8def2 * correctly set the size of the operation when carrying out Mov Op Mov optimizations
git-svn-id: trunk@33930 -
2016-06-06 21:18:21 +00:00
florian
b274599a47 * made some assembler optimizer methods class methods
git-svn-id: trunk@33929 -
2016-06-06 21:18:20 +00:00
florian
e56147ac6e * integrated mov op mov -> op optimization in aoptx86
* isFoldableArithOp is in aoptx86 now

git-svn-id: trunk@33928 -
2016-06-06 21:18:18 +00:00
florian
9ed6638baa * moved MovAnd2Mov optimization to aoptx86
git-svn-id: trunk@33927 -
2016-06-06 21:18:16 +00:00
florian
dfe41db13f * call GetNextInstruction only once when carrying out mov optimizations
git-svn-id: trunk@33916 -
2016-06-05 12:40:41 +00:00
florian
ba54f7243e * moved all i386 mov peephole optimization code into OptPass1MOV
git-svn-id: trunk@33908 -
2016-06-04 19:34:18 +00:00
florian
20807f4148 * factored out V<Op> optimizations into OptPass1VOP
* call OptPass1VOP also for i386

git-svn-id: trunk@33878 -
2016-06-01 20:49:35 +00:00
florian
bd54a11f1c + TX86AsmOptimizer.OptPass1VMOVAP for i386 and x86-64
+ new unit aoptutils which helpers for the assembler optimizer

git-svn-id: trunk@33587 -
2016-05-01 09:37:21 +00:00
florian
ec92bc3390 * case of identifiers fixed
* x86-64 uses also the mov $0,... -> xor optimization

git-svn-id: trunk@33553 -
2016-04-24 20:01:43 +00:00
florian
3c2dab9878 * i386 peephole assembler uses largely the common peephole optimizer infrastructure, the resulting code is besides a few improvements the same
git-svn-id: trunk@33542 -
2016-04-21 20:14:01 +00:00
florian
c40240990e * popt386 uses now also all routines of aoptx86
git-svn-id: trunk@31894 -
2015-09-29 19:31:33 +00:00
florian
53ea4fb7d4 * unify x86 peephole optimizer helpers
git-svn-id: trunk@31843 -
2015-09-27 09:36:39 +00:00