|
From: | Christian Jullien |
Subject: | Re: [Tinycc-devel] Simple peephole optimization |
Date: | Sun, 24 May 2020 07:15:24 +0200 |
Hi, there is certainly a tradeoff between compilation time and execution time. A possible way to add this peephole optimization and possibly others we’ll find later it to include this code only if –O2 is supplied. Now, removing 400 similar sequences like this is certainly something we would like to have and on other backend if it applies. How long it makes tcc slower when compiling with and without this option? Wdyt? From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=address@hidden] On Behalf Of Samir Ribic Tcc was never intended to be a real optimizing compiler, because it is focused on compilation speed and memory savings. However, it seems that some improvements on generated code can be done, without significant compiler speed degradation.As tcc generates machine code, rather than assembly, pattern searching for peephole optimization might be quite fast. I remarked that sequences in 386 generated code like this (Intel syntax) MOV ECX,[memory location] ADD EAX,ECX appear quite often, and they can be replaced with ADD EAX, [memory location] which saves two bytes. Together with variants using AND, OR, XOR, ADC, SUB and SBB instructions, ]iIn a generated code from tcc.c there are about 400 similar sequences. To do the replacement In a file i386-gen.c I have changed the function void gen_opi(int op) about 20 lines below the label gen_op8:. ..... } else { // op with global var if (peep[-8] == 0x8B && /* MOV reg,regm */ |
[Prev in Thread] | Current Thread | [Next in Thread] |