florian
02289d1f5b
+ fold "a shl n1 shl n2" and "a shr n1 shr n2" into "a shl (n1+n2)" and "a shr (n1+n2)", resolves #39629
2022-04-20 22:16:32 +02:00
florian
34630c2ef9
* properly set types for currency divisions, resolves #38717
2022-02-13 22:47:38 +01:00
florian
5abfe21f39
+ apply unary minus optimizations also to /
...
* test extended
2021-09-23 22:44:16 +02:00
florian
69d5d648a9
+ more unary minus optimizations
...
* test extended
2021-09-21 23:09:33 +02:00
florian
3e760b33c7
+ more unary minus optimizations
...
* test extended
2021-09-20 22:31:16 +02:00
florian
2ce34f7bd3
* do constant folding on div <const. int> div <const. int>, resolves #39301
2021-09-02 22:04:42 +02:00
florian
272a0e3e26
+ apply excess precision also to unary minus nodes
...
* made excess precision really working
git-svn-id: trunk@48840 -
2021-02-28 10:52:11 +00:00
florian
9af9f140a5
* do an unsigned division if one operand is unsigned an the other
...
one a constant in its range, resolves #38180
git-svn-id: trunk@47797 -
2020-12-16 21:55:05 +00:00
florian
637976e83f
* patch by Marģers to unify internal error numbers, resolves #37888
...
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
florian
42f2e5f8ad
+ simplify "x mod -1", resolves #37449
...
git-svn-id: trunk@45969 -
2020-07-30 20:35:34 +00:00
svenbarth
60345366f2
* fix for Mantis #35140 : apply patch by Ryan Joseph together with some further changes by me to add support for constant parameters in generics
...
+ added tests
git-svn-id: trunk@45080 -
2020-04-25 22:12:35 +00:00
svenbarth
89434f0124
* extract calculation of a NOT value to a separate function
...
git-svn-id: trunk@45050 -
2020-04-24 14:08:58 +00:00
florian
04f3784af5
* better setting of expectloc
...
git-svn-id: trunk@44619 -
2020-04-06 20:44:31 +00:00
Jonas Maebe
ff919184d8
* restored original behaviour of shl/shr constant evaluation outside
...
inline statements
o fixes compilation of pasjpeg with -Cr
git-svn-id: trunk@43560 -
2019-11-22 21:12:00 +00:00
Jonas Maebe
acbb456ae5
* fixed constant evaluation of shr of negative values after r43497
...
(tshlshr compiled with -O3)
git-svn-id: trunk@43504 -
2019-11-16 17:58:06 +00:00
Jonas Maebe
4fd670c6ec
* fixed missing masking of values after shifting them during inline
...
evaluation
o also only mask values when performing a constant evaluation of
"0 shl/shr x" during inline evaluation (just like when evaluating other
shl/shr operations)
git-svn-id: trunk@43497 -
2019-11-16 14:27:47 +00:00
Jonas Maebe
d23c7980aa
* properly perform (or not) range/overflow checking when performing constant
...
propagation into inlined routines, regardless of the range/overflow
checking state at the caller site
git-svn-id: trunk@43436 -
2019-11-10 12:00:05 +00:00
florian
4e33889a29
* cleanup tshlshrnode.pass_1
...
git-svn-id: trunk@43347 -
2019-11-01 18:39:14 +00:00
Jonas Maebe
281b3ad276
* fix case completeness and unreachable code warnings in compiler that would
...
be introduced by the next commit
git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
Jonas Maebe
04d295f186
* first step towards supporting 32 bit targets with the LLVM code generator:
...
use the generic code in more cases when cpuhighleveltarget is defined
git-svn-id: trunk@41133 -
2019-01-29 21:39:09 +00:00
Jonas Maebe
0b246f3dbd
* converted Boolean8 to an internal type, and mapped Boolean to the
...
new internal pasbool1(type) (part of mantis #34411 )
o apply the _Bool x86-64 parameter passing rules only to pasbool1
git-svn-id: trunk@39949 -
2018-10-16 21:14:18 +00:00
florian
96e92527e9
* constant folding of not must check if the deftype is really an orddef, resolves #33696
...
git-svn-id: trunk@39406 -
2018-07-07 14:17:41 +00:00
svenbarth
9b45f58c0b
+ add flags that allow checking for overloads with isbinaryoverloaded() and isunaryoverloaded() without modifying the passed in node or even checking for normally non-overloadable operators
...
git-svn-id: trunk@39258 -
2018-06-20 19:53:34 +00:00
florian
71e71ad267
* fix currency division on non x86 32 bit targets
...
* disable fix for #33439 during bootstrapping with 3.0.x, as 3.0.x cannot compile the currency division without the fix above
git-svn-id: trunk@38558 -
2018-03-17 22:44:44 +00:00
florian
8c5606b41d
+ support mmx shifting
...
git-svn-id: trunk@38367 -
2018-02-27 21:40:12 +00:00
nickysn
b41762d1bf
+ perform the optimization in tmoddivnode.firstoptimize also for div/mod by
...
negative powers of 2 as well
git-svn-id: trunk@36930 -
2017-08-17 15:56:20 +00:00
nickysn
910e1eccc8
* set the bit mask, used for modulus by power-of-2 in a way, that is independent
...
from the sign of the divisor (so that negative powers of 2 can be supported as
well in the future)
git-svn-id: trunk@36928 -
2017-08-17 15:19:37 +00:00
nickysn
ee79ff3635
* improved the optimization of signed modulus by power-of-2, so it uses less
...
operations. Previously generated code:
sign:=sar(left,sizeof(left)*8-1);
result:=((((left xor sign)-sign) and right) xor sign)-sign;
New code:
mask:=sar(left,sizeof(left)*8-1) and ((1 shl power)-1);
result:=((left+mask) and right)-mask;
git-svn-id: trunk@36847 -
2017-08-04 16:20:50 +00:00
nickysn
a1928859b3
* in the optimization of signed division by power-of-2 constant in
...
tmoddivnode.firstoptimize, replaced tordconstnode(right).value-1 with
tcgint((qword(1) shl power)-1), so that it becomes independent from the sign
of right, so that in the future, we can also apply this optimization for
negative power-of-2 divisors as well (only a unary minus node would have to
be inserted in this case).
git-svn-id: trunk@36845 -
2017-08-04 15:50:33 +00:00
nickysn
277026ffd4
* perform the high level signed division by power-of-2 optimization for all
...
int types, larger than the ALU of the CPU, instead of just for 64-bit ints on
32-bit or smaller CPUs.
git-svn-id: trunk@36842 -
2017-08-04 14:34:42 +00:00
nickysn
b9fdca6f49
+ better high level optimization for 64-bit signed division by 2 on 32-bit and
...
lower CPUs. Instead of the (sar(temp,sizeof(temp)*8-1) and 1) expression, use
the equivalent, but simpler (temp shr (sizeof(temp)*8-1))
git-svn-id: trunk@36839 -
2017-08-04 13:51:51 +00:00
nickysn
ee4c82f5f5
* in the high level optimization of signed division by power-of-2 constant, set
...
shiftval to left.resultdef.size*8-1, instead of 31, so that it shifts by 15 or
7 on 16-bit and 8-bit CPUs, when the integer type is small.
git-svn-id: trunk@36820 -
2017-08-03 16:02:27 +00:00
nickysn
efc5e339d0
* use an enum instead of integer constants to represent inline numbers
...
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
their enum name, instead of number
git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
b1dff29cbf
* removed unused units
...
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
nickysn
de1e0c405e
+ optimize '0 shl x' and '0 shr x' to 0
...
git-svn-id: trunk@36041 -
2017-05-01 18:16:38 +00:00
yury
0f9876effb
* Fixed a memory leak when div is replaced by shift.
...
git-svn-id: trunk@35540 -
2017-03-07 11:11:18 +00:00
pierre
1e5883b6d1
Avoid overflow error for single MinValue in rtl syshelph.inc for x86_64 CPU
...
git-svn-id: trunk@33012 -
2016-01-28 14:20:51 +00:00
Jonas Maebe
ed03286be5
* simplify "div -1" to unaryminusn, not just for performance reasons but
...
also because "div -1" is not handled correctly by the div-to-mul/shift
transformation on x86 (mantis #28702 )
git-svn-id: trunk@32619 -
2015-12-08 15:57:07 +00:00
yury
432248cbf1
* Removed lot of unused vars.
...
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
fbacf9682f
* rename WinCE softfp compilerproc names to lowercase, needed since r31404
...
(mantis #28598 )
git-svn-id: trunk@31478 -
2015-09-02 09:54:02 +00:00
florian
ba1297b1ab
+ provide also 8 and 16 bit div/mod helper
...
* tmoddivnode.first_moddivint does not force a 32 bit helper, the used helper depends now on the resultdef type set by tmoddivnode.pass_typecheck
git-svn-id: trunk@31195 -
2015-07-05 20:16:50 +00:00
florian
36e79a874e
* when creating code for an iso mod operator, use create_internal for the helper nodes
...
to avoid unnecessary warnings
git-svn-id: trunk@30270 -
2015-03-21 22:57:19 +00:00
sergei
5f2821ee5f
* Moved handling of emulated floating point negation into new virtual method tcgunaryminusnode.second_float_emulated. Also changed it into simple flipping of the sign bit, which is how it is defined by IEEE 754, and already done for ARM targets. Relevant ARM-specific parts can now be removed, and m68k code gets significantly better without further efforts.
...
git-svn-id: trunk@28528 -
2014-08-27 21:16:30 +00:00
sergei
c184d9740c
+ Implemented target-independent optimization of signed "mod 2**N" as
...
"sign:=left sar sizeof(left)*8-1; result:=(((left xor sign)-sign) and 2**N-1) xor sign)-sign;"
This solution yields larger code than one suggested by Mantis #21152 , however its speed on i386 is approximately the same, and it is also suitable for all operand sizes, all powers of two and all targets.
git-svn-id: trunk@27891 -
2014-06-07 22:19:10 +00:00
nickysn
a47ab44ec8
* unified the 8-bit and 16-bit alu handling in tshlshrnode.pass_typecheck
...
git-svn-id: trunk@27642 -
2014-04-23 12:53:31 +00:00
nickysn
7d8fb1833f
* 16-bit alu handling in tshlshrnode.pass_typecheck simplified via the use of
...
get_common_intdef
git-svn-id: trunk@27641 -
2014-04-23 12:43:48 +00:00
nickysn
a17797f3ca
* tshlshrnode.simplify: in the case of 16-bit or 8-bit shl/shr, AND the right
...
side constant with 31 (instead of 15 or 7), because that's how the 16-bit and
8-bit x86 shl/shr instructions behave (even on 16-bit CPUs like 286). The
change does not affect 32-bit and 64-bit platforms, because there the shift
is always done in at least 32 bits.
git-svn-id: trunk@27638 -
2014-04-23 00:23:27 +00:00
nickysn
aa3f450832
* 8/16-bit alu fixes in tnotnode.simplify
...
git-svn-id: trunk@27636 -
2014-04-22 22:04:31 +00:00
svenbarth
e85075de7f
Fix for Mantis #25604 .
...
nmat.pas:
* correctly disable type checks if one of the arguments for MOD, DIV, SHR, SHL, NOT, -X and +X is a generic type parameter
+ added tests
git-svn-id: trunk@27535 -
2014-04-11 16:43:53 +00:00
florian
6e1bf4d040
* properly simplify not(<const. cbool>), resolves #25255
...
git-svn-id: trunk@26803 -
2014-02-16 20:20:58 +00:00