]> thyrsus.com Git - intercal.git/commitdiff
Change optimiser policy, and fix optimiser bugs
authorAlex Smith <ais523@bham.ac.uk>
Thu, 26 Aug 2010 20:30:49 +0000 (21:30 +0100)
committerAlex Smith <ais523@bham.ac.uk>
Thu, 26 Aug 2010 20:30:49 +0000 (21:30 +0100)
This includes a change in optimiser policy, such that optimising a
run-time error into a compile-time error is considered a bug (which
probably should have been the rule all along); the documentation was
inconsistent on this before now. This is also needed for the
testsuite to work with the optimiser.

The specific bugs: constant folding could make a mingle guaranteed
to overflow at runtime if the line was ever reached into a compile-
time error; and folding an and into an or was occasionally an
unchecked no-op, which causes the optimiser to enter an infinite
loop (it's now checked that it's not a no-op in advance).

doc/ick.txi
src/idiotism.oil

index a412094c8b134fd4eda9d1512e2124b6b4359146..f0361cfa9a74b0e075dee834e4b19fd092e827a1 100644 (file)
@@ -6718,10 +6718,8 @@ particular @ical{} expression works.
 Make sure that the optimizer doesn't change a statement from a run-time
 error into something that silently succeeds@!  Checking which bits can
 and can't be 1 is one good way to avoid this, especially with mingles.
-(At present, there are some idioms that can turn run-time errors into
-compile-time errors, such as with the expression
-@code{''#65535$#65535'$#0'}; this could be avoided, but for the time
-being it isn't.)
+Likewise, don't optimise a run-time error into a compile-time error
+(although creating a compile-time warning in this situation is fine).
 
 @item
 You can help@!  If you find an idiom that the optimizer isn't optimizing
index 5ab8997f1c52430af7719614b506937929e8ebb3..c97225913c3d269e3629cd062b6a7459fa4270eb 100644 (file)
@@ -34,7 +34,7 @@
 
 ; Constant folding
 [minglefold]
-(#{1}1$#{1}2)->(#{mingle(x1,x2)}0)
+(#{x<=65535}1$#{x<=65535}2)->(#{mingle(x1,x2)}0)
 [selectfold]
 (#{1}1~#{1}2)->(#{iselect(x1,x2)}0)
 [and32fold]
@@ -68,7 +68,7 @@
 
 ; Reducing constants inside a C or operation can help to recognize idioms
 [cfoldintoorinand]
-(((_1) | #{1}2) & #{1}3)->(((_1) | #{x2 & x3}0) & _3)
+(((_1) | #{(x != x & x3)}2) & #{1}3)->(((_1) | #{x2 & x3}0) & _3)
 
 ; Binary bitwise optimizations
 [cbinand]