florian
e0a1bc6675
+ optimize (a and b) or (c and not(b)) into c xor ((c xor a) and b)
...
+ test
git-svn-id: trunk@48841 -
2021-02-28 18:20:46 +00: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
yury
64c586b86d
* Removed/ifdefed lots of unused variables.
...
git-svn-id: trunk@48384 -
2021-01-24 12:24:01 +00:00
florian
12adb47d65
* clean up
...
git-svn-id: trunk@48011 -
2021-01-03 15:03:27 +00:00
florian
3109005791
+ fold also (string const+(string const+string var))
...
* string tree folding code moved into level 2 opt. block
git-svn-id: trunk@47986 -
2021-01-02 22:18:38 +00:00
florian
7de94e7a1d
* properly fold string+string const+string const., resolves #38267
...
git-svn-id: trunk@47977 -
2021-01-02 17:18:54 +00:00
florian
e6037961e3
* refactored constant folding code
...
git-svn-id: trunk@47935 -
2021-01-01 21:58:12 +00:00
florian
97abf6b495
* first part of fixing #38267 : do not bail out early during constant folding
...
if the constant is 1 or -1
git-svn-id: trunk@47933 -
2021-01-01 15:26:13 +00:00
florian
4f3a21eeec
* don't do x*x -> optimziation for xtensa as it causes a recursive call in sqr(...)
...
git-svn-id: trunk@47688 -
2020-12-04 22:43:55 +00:00
florian
6380df9b42
* correctly simplify tree transforms of (a+c1+c2) if a is a pointer, resolves #37671
...
git-svn-id: trunk@47437 -
2020-11-16 21:47:19 +00:00
florian
98eab07abd
* simplified and fixed code of (v1=const1) and (v2=const2) optimization, resolves #38066
...
git-svn-id: trunk@47423 -
2020-11-15 16:17:54 +00:00
florian
ff31d95a69
* excess precision should not be applied to comp or currency
...
git-svn-id: trunk@47246 -
2020-10-28 21:37:27 +00:00
florian
13f1fb60b4
* directly copy the result of set <op> set into the left side of an assignment
...
git-svn-id: trunk@47226 -
2020-10-27 21:42:51 +00:00
Jonas Maebe
0729340817
* try_make_mul32to64: restore original node order if transformation failed
...
o this gets called by taddnode.pass_1, which caches the left/right
node types/resultdefs
git-svn-id: trunk@47158 -
2020-10-23 13:34:24 +00:00
Jonas Maebe
099134b545
* fix try_make_mul32to64() if it's called with a constant node on the
...
left (mantis #37878 )
o can happen if use_generic_mul32to64 returns false
git-svn-id: trunk@47142 -
2020-10-19 19:10:16 +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
65047cecdb
+ optimize comparisons of constant pointers
...
git-svn-id: trunk@47031 -
2020-10-01 20:33:03 +00:00
florian
e124b07e86
+ evaluate typeinfo(<type1>)=/<>typeinfo(<type2>) at compile time, resolves #30260
...
git-svn-id: trunk@47008 -
2020-09-29 20:14:27 +00:00
Jonas Maebe
aa75d39ab5
* don't perform "(x=y) or (z=u)" -> "(x xor y) or (z xor u)" optimization
...
if z or u may raise exceptions (mantis #37780 )
git-svn-id: trunk@46905 -
2020-09-20 12:43:45 +00:00
yury
6878ffbf04
* In the TP mode for 16-bit CPUs uint8+uint8 is extended to sint16+sint16. This is TP compatible.
...
git-svn-id: trunk@46468 -
2020-08-17 09:25:45 +00:00
florian
18b8b9c566
* do not apply range test optimization if the variable is a string being compared against a char constants, resolves #37476
...
git-svn-id: trunk@46453 -
2020-08-15 18:29:26 +00:00
florian
d7ba09f543
* insert type casts when creating new unaryminus nodes during simplification, resolves #37508
...
git-svn-id: trunk@46309 -
2020-08-07 21:43:00 +00:00
florian
e14a3f17e6
* reverted r46220 as it is fixed now properly
...
git-svn-id: trunk@46276 -
2020-08-05 21:15:33 +00:00
yury
719220e8a4
* For 8/16 bit CPUs and TP mode, disable expansion to a larger integer type for subtract operations on unsigned integers. This is TP7 compatible.
...
git-svn-id: trunk@46233 -
2020-08-04 20:45:29 +00:00
svenbarth
c17ad509e2
* fix for Mantis #36775 : apply patch by J. Gareth Moreton
...
+ added tests
git-svn-id: trunk@46220 -
2020-08-03 21:53:29 +00:00
Jonas Maebe
346adf7f55
* replace explicit (sometimes incomplete) tests with calls to doshortbooleval()
...
* the c-style boolean evaluation of "and" is independent of short-circuit evaluation
(you always have to consider the complete values in case the first one is <> 0)
git-svn-id: trunk@45990 -
2020-08-02 14:39:50 +00:00
florian
5f118da600
* optimize a/a and a-a if fast math is on
...
git-svn-id: trunk@45630 -
2020-06-09 20:50:47 +00:00
florian
aafc22bd74
+ optimize real operations with 0 and 1 if fast math is turned on
...
git-svn-id: trunk@45627 -
2020-06-08 20:33:27 +00:00
florian
6d3b74f96e
* extended r45555 to take care of chars as well
...
git-svn-id: trunk@45565 -
2020-06-02 20:58:44 +00:00
florian
792cf056eb
* a nil node is also a constant pointer node
...
+ convert (v1=const1) and (v2=const2) into ((v1 xor const1) or (v2 xor const2))=0 if the expressions have no side effects
git-svn-id: trunk@45555 -
2020-06-01 20:50:38 +00:00
florian
7a60e044e3
* simplify constant expressions after re-ordering, resolves #37062
...
git-svn-id: trunk@45360 -
2020-05-13 20:26:04 +00:00
florian
e5e386f94a
* cosmetics
...
git-svn-id: trunk@45327 -
2020-05-10 18:41:10 +00:00
florian
ebcae70d72
* avoid unncessary conversions of constants in 64 bit ints when doing constant folding
...
git-svn-id: trunk@45326 -
2020-05-10 15:25:31 +00:00
florian
bdabf674e1
* propagate forinline
...
git-svn-id: trunk@45319 -
2020-05-09 17:36:36 +00:00
florian
43e6d84f33
* GetCopyAndTypeCheck forces correct type
...
* propagate forinline flag through simplify
git-svn-id: trunk@45213 -
2020-05-01 20:50:18 +00:00
nickysn
55254ff64b
+ set expectloc in the first pass of the addnode for small CPUs for procvardef comparisons
...
git-svn-id: branches/z80@45044 -
2020-04-23 16:05:23 +00:00
nickysn
96a714b20e
* set expectloc correctly for procvardef comparisons with nil for small CPUs
...
git-svn-id: branches/z80@45043 -
2020-04-23 15:52:22 +00:00
nickysn
073afe3735
+ set expectloc correctly for small CPUs in the first pass of the add node for classrefdefs
...
git-svn-id: branches/z80@45042 -
2020-04-23 15:48:59 +00:00
nickysn
2ee28809d8
* set expectloc correctly for small CPUs for implicit pointer object types in the first pass of the add nodes
...
git-svn-id: branches/z80@45041 -
2020-04-23 15:46:27 +00:00
nickysn
4ae5b81bff
* set expectloc correctly for enumdef comparisons on small CPUs
...
git-svn-id: branches/z80@45040 -
2020-04-23 15:31:50 +00:00
nickysn
c0ea4d826c
+ also support the 8-bit mul helpers in the generic code of nadd
...
git-svn-id: branches/z80@44990 -
2020-04-22 02:45:49 +00:00
florian
af8202be3d
* compilation for non-Xtensa targets fixed
...
git-svn-id: trunk@44543 -
2020-04-03 20:15:26 +00:00
florian
66cbee5e31
* factor out first_addfloat_soft
...
git-svn-id: trunk@44540 -
2020-04-03 20:15:24 +00:00
florian
f8339a43ea
* do not do full boolean evaluation on LOC_FLAGS
...
git-svn-id: trunk@44270 -
2020-03-06 16:16:37 +00:00
florian
93521ae8e8
* fold also pointer additions/subtractions
...
git-svn-id: trunk@44199 -
2020-02-16 20:14:28 +00:00
florian
27e89e07a3
* in case a 32x32 -> 64 multiplication is converted into shl, the type casts need to be restored
...
git-svn-id: trunk@44197 -
2020-02-16 20:14:27 +00:00
florian
251b18b966
* do not fold constants if the resulttypes do not match, improved fix for #tw26587
...
git-svn-id: trunk@44165 -
2020-02-13 20:34:27 +00:00
yury
39c48f0d01
* Fixed r43577 for cases when the size of the new result of a simplified node after typecheckpass is smaller than the size of the original node's result. This caused internal errors or invalid assembly in some cases. Issue #36587 .
...
git-svn-id: trunk@44151 -
2020-02-11 12:49:12 +00:00
florian
77b54f501f
* when optimizing boolean expressions, might_have_sideeffects is only relevant if the expression would be optimized away
...
git-svn-id: trunk@44084 -
2020-02-01 18:02:17 +00:00
florian
051b9840a5
* write a proper error message if <int>/<int> is encountered while no
...
floating point support is available, resolves #32006
git-svn-id: trunk@43794 -
2019-12-25 18:09:30 +00:00
florian
0cb85eef9b
* more currency fixes, should resolve #36176
...
git-svn-id: trunk@43635 -
2019-12-03 19:31:50 +00:00
pierre
c87facbae1
Use PInt64(@value_currency)^ construct to avoid internal error when starting from 3.0.4 ppcarm compiler
...
git-svn-id: trunk@43634 -
2019-12-03 16:05:30 +00:00
pierre
91e550edb6
Remove assigned but unused local variable i64 in taddnode.pass_typecheck_internal as suggested by Ondrej Pokorny
...
This also solves the "Invalid TypeCast Error" in rtl-objpas when compiled with -CriotR option.
git-svn-id: trunk@43631 -
2019-12-02 23:11:21 +00:00
florian
86d8e79e86
* fix some currency issues, resolves #33963 and #36179
...
git-svn-id: trunk@43620 -
2019-12-01 20:24:00 +00:00
florian
acdff47554
+ optimize integer expressions like 2*x*4; which were not found by the node simplifier yet
...
git-svn-id: trunk@43577 -
2019-11-24 20:21:33 +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
cb67577002
* fix length(<dyn. type>)=0 optimization, resolves #36215
...
git-svn-id: trunk@43343 -
2019-10-31 21:29:41 +00:00
florian
ee3258c0da
* optimizing length(<dyn. type>)=0 is not possible for jvm
...
git-svn-id: trunk@43280 -
2019-10-20 21:10:56 +00:00
florian
e80eee5da5
* generate better code for length(<dyn. type>)=0, resolves #36060
...
git-svn-id: trunk@43272 -
2019-10-20 13:03:45 +00:00
pierre
f82cc96cb9
Check that inserttypeconv really change node type to ttypeconvnode before setting convtype field (should fix taddbool.pp bytebool failure on powerpc)
...
git-svn-id: trunk@42692 -
2019-08-14 23:00:35 +00:00
Jonas Maebe
40082100e1
* fixed range test optimization for signed types and enabled it for them
...
git-svn-id: trunk@42332 -
2019-07-06 09:57:32 +00:00
Jonas Maebe
faf75095cd
* synchronised with trunk till r42189
...
git-svn-id: branches/debug_eh@42190 -
2019-06-07 18:24:38 +00:00
Jonas Maebe
eab079c7bd
* fixed cbool "and" with full boolean evaluation, and cbool "xor"
...
(mantis #35272 )
git-svn-id: trunk@42167 -
2019-06-02 20:04:06 +00:00
Jonas Maebe
1b6425176b
* synchronised with trunk till r42049
...
git-svn-id: branches/debug_eh@42050 -
2019-05-12 18:44:05 +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
florian
38be96e586
* allow pointer+ord. const always if the node is created internally
...
git-svn-id: branches/debug_eh@41381 -
2019-02-19 22:16:05 +00:00
Jonas Maebe
7af95cbf06
* LLVM does not support 128 bits arithmetic on 32 bit platforms, which we
...
need for overflow checking -> use RTL built-ins
git-svn-id: trunk@41205 -
2019-02-03 21:01:02 +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
d1361ca6ed
* fixed adjustments of lower/upper bounds in range test optimization in case
...
of strictly smaller/greater comparisons (mantis #34385 )
git-svn-id: trunk@40344 -
2018-11-17 22:38:31 +00:00
yury
4357caaad8
* Removed unused local vars.
...
git-svn-id: trunk@40183 -
2018-11-02 18:44:29 +00:00
florian
116f36fe56
* avoid range check errors
...
git-svn-id: trunk@39990 -
2018-10-20 10:17:34 +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
pierre
293973b306
Add missing setting of expectloc for multiplications
...
git-svn-id: trunk@39935 -
2018-10-14 22:18:50 +00:00
florian
352fb866ef
* is_range_test returns false if "lower" bound is greater than "upper" bound
...
git-svn-id: trunk@39837 -
2018-09-27 20:24:52 +00:00
florian
a34d4e715c
Merged riscv_new branch
...
git-svn-id: trunk@39813 -
2018-09-26 19:49:08 +00:00
florian
a21397e356
+ based on a patch by Laksen, optimize (v>=x) and (v<=y) into (v-x)<(y-x)
...
git-svn-id: trunk@39759 -
2018-09-16 13:09:36 +00:00
svenbarth
32c307e9ce
* fix for Mantis #34021 : if one of the two operators is an array constructor try to use an operator overload for that first before converting it to a set
...
+ added tests
git-svn-id: trunk@39554 -
2018-08-03 15:24:59 +00:00
florian
32a58ba7d1
* might_have_sideeffects gets flags: if mhs_exceptions is passed, nodes which might cause an exception are considered as having a side effect
...
git-svn-id: branches/laksen/riscv_new@39483 -
2018-07-22 13:11:21 +00:00
florian
52846df241
* fixed condition in getbestreal
...
git-svn-id: trunk@39446 -
2018-07-13 19:53:47 +00:00
florian
0c6cf12fbf
+ support for the directive $EXCESSPRECISION
...
git-svn-id: trunk@39443 -
2018-07-12 21:39:50 +00:00
svenbarth
fa78bb0e89
* warn if the compiler hides an eventual "+" operator overload if modeswitch ArrayOperators is active
...
git-svn-id: trunk@39261 -
2018-06-20 19:53:56 +00:00
svenbarth
97acf24290
+ add a new modeswitch ArrayOperators which is set by default in Delphi modes that enables the internal array operators (currently only "+")
...
git-svn-id: trunk@39259 -
2018-06-20 19:53:43 +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
svenbarth
199b5809a3
* optimize "dynarr := dynarr + [elem]" to "Insert(elem, dynarr, High(SizeInt))" and "dynarr := [elem] + dynarr" to "Insert(elem, dynarr, 0)" (we need to do this in the typecheck of taddnode as otherwise the array constructor is already converted)
...
+ added test
* adjusted test for Mantis #30463 as p1 triggers the optimization as well
git-svn-id: trunk@39119 -
2018-05-25 16:03:56 +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
b2825f2467
* scale constants if possible before currency multiplications to avoid overflows, resolves #33439
...
git-svn-id: trunk@38555 -
2018-03-17 21:33:07 +00:00
florian
c230f81719
+ support for <dyn. array>+<dyn. array>, resolves #30463
...
git-svn-id: trunk@38406 -
2018-03-04 16:12:43 +00:00
Jonas Maebe
1934285c20
* don't convert "int64(sint32) * cardinal_const" into a 32x32->64
...
multiplication (mantis #32046 )
git-svn-id: trunk@37921 -
2018-01-06 13:44:03 +00:00
pierre
59edd81a26
Disable some code using bestrealrec if macro FPC_SOFT_FPUX80 is defined
...
git-svn-id: trunk@37296 -
2017-09-21 14:39:14 +00:00
Károly Balogh
b755524c38
made it possible to override the decision from the cgs, if a certain muln needs a helper
...
git-svn-id: trunk@36347 -
2017-05-26 18:42:21 +00:00
nickysn
34113b930b
* removed the checkoverflow: boolean parameter of the software mul helpers;
...
replaced it with a separate "_checkoverflow" version of each helper
git-svn-id: trunk@36344 -
2017-05-26 15:34:26 +00:00
Károly Balogh
3e8ee48458
m68k: define cpurox and enabled the rotate-related optimizations on CPUs which support rotate instructionsoptions.pas
...
git-svn-id: trunk@36302 -
2017-05-23 00:16:29 +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
546e993c25
* use resultdef for the type of the resulting zero const from the '0*x' and
...
'0 and x' optimization
git-svn-id: trunk@36040 -
2017-05-01 18:11:12 +00:00
nickysn
f26a844b19
* only do the '0*x' and '0 and x' optimization if x has no side effects (except
...
at -O4, where it is done regardless of whether there are side effects or not)
git-svn-id: trunk@36039 -
2017-05-01 17:34:19 +00:00
nickysn
f44f2f9194
* do the optimizations in r36027 at level -O3 or higher
...
git-svn-id: trunk@36034 -
2017-05-01 13:14:32 +00:00
nickysn
6d589f415b
* do the left.equals(right) check before might_have_sideeffects, because
...
left.equals(right) is usually faster
git-svn-id: trunk@36033 -
2017-05-01 12:57:15 +00:00
nickysn
217d39abf1
* fixed bug in r36027 (I had it fixed already, but accidentally committed the
...
wrong file in r36027)
git-svn-id: trunk@36030 -
2017-05-01 11:43:16 +00:00
nickysn
5aeb73b940
+ optimizations (at -O2 level) for (where 'a' is an integer expression, without
...
side effects):
* a - a -> 0
* a xor a -> 0
* a and a -> a
* a or a -> a
* a <> a -> false
* a < a -> false
* a > a -> false
* a = a -> true
* a <= a -> true
* a >= a -> true
git-svn-id: trunk@36027 -
2017-05-01 10:17:50 +00:00