]> thyrsus.com Git - intercal.git/commitdiff
Optimiser fixes for complement
authorAlex Smith <ais523@bham.ac.uk>
Sat, 31 May 2008 19:36:24 +0000 (15:36 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 00:34:56 +0000 (20:34 -0400)
NEWS.txt
src/dekludge.c
src/idiotism.oil

index fb5247854710daa9465919948302905ac03867d0..cb7b4d961309fe773298f7d0b7c5945faace3f99 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -60,9 +60,15 @@ Changes by Joris Huizer
 11. The -g option now causes optimisation of the output compiled C to be
     turned off, and adds comments to the output file the same way -c does.
 
+12. Added new optimiser idioms [cxorand16] and [cxorand32] for situations
+    where AND and XOR together are used to simulate AND and bitwise-not;
+    also generalised the idiom-matching code to compare 16-bit and 32-bit
+    constants as equal if they have the same value, and fixed some typos in
+    the current 16-bit complement idioms.
+
 Bugs reported by the Debian autobuilders and Joey Hess
 
-12. The build of the optimiser idioms is now split over many files, to reduce
+13. The build of the optimiser idioms is now split over many files, to reduce
     the memory usage of gcc when it tries to compile the giant output C file.
     This was a problem on ia64. (The ulimit method of preventing thrashing has
     been removed, as this method works better; likewise, the optimiser
@@ -70,21 +76,21 @@ Bugs reported by the Debian autobuilders and Joey Hess
 
 Changes by Alex Smith
 
-13. convickt can now produce its output as INTERCAL initialisation of a tail
+14. convickt can now produce its output as INTERCAL initialisation of a tail
     array. (This doesn't auto-offset between the different characters; it is
     therefore mostly useful for producing Baudot arrays for CLC-INTERCAL-style
     IO.)
 
-14. The function clock_gettime is now supported by the yuk profiler as an
+15. The function clock_gettime is now supported by the yuk profiler as an
     alternative method of getting a high-resolution clock for profiling (it
     is available on at least Linux).
 
-15. Upgraded the autoconfiguration to a substantially newer version of
+16. Upgraded the autoconfiguration to a substantially newer version of
     autoconf. Hopefully the same script works on all operating systems now,
     because I've removed the one that configures for DOS (which was previously
     separate).
 
-16. Added support for computed CREATE (the computation is done at create-time,
+17. Added support for computed CREATE (the computation is done at create-time,
     rather than when the unknown statement is encountered); partly because
     this was rather easy, but mostly because it can be used to simulate a
     computed NEXT, thus making the example expansion library compunex (which I
@@ -96,10 +102,10 @@ Changes by Alex Smith
     features of NEXT, anyway, rather than the small subset COMPUNEX could
     manage.)
 
-17. Plugged a couple of small memory leaks; however, there are still several
+18. Plugged a couple of small memory leaks; however, there are still several
     much bigger memory leaks that could do with being fixed.
 
-18. About the version number: this release is mostly bugfixing, but does add a
+19. About the version number: this release is mostly bugfixing, but does add a
     few new features, so I wasn't sure whether to increment the major or the
     minor version number. In the end, I used the old INTERCAL maxim 'when in
     doubt, do both'.
index 709cf1c8e1c3575b7b361a1656fe1dc9b7cd61cf..739554118e206ebe39dc02ddc8b6e0e4cb757ae4 100644 (file)
@@ -76,7 +76,10 @@ ick_bool nodessame(node* n1, node* n2)
 {
   if(!n1) return !n2;
   if(!n2) return 0;
-  if(n1->opcode!=n2->opcode) return 0;
+  if(n1->opcode!=n2->opcode)
+    return (((n1->opcode == MESH && n2->opcode == MESH32) ||
+        (n1->opcode == MESH32 && n2->opcode == MESH)) &&
+        n1->constant == n2->constant);
   if(!nodessame(n1->lval,n2->lval)) return 0;
   if(!nodessame(n1->rval,n2->rval)) return 0;
   switch(n1->opcode)
index 917e3398f81aba3a19cb5e683f23b5eaafaa9825..4af6f7b788336bb379e3c3608403a5408230263d 100644 (file)
 ((?32(_{!(c&1431655765LU)}2|_{!(c&2863311530LU)}1))&
  #{!(x&2863311530LU)&&iselect(x,1431655765LU)==xselx(iselect(x,1431655765LU))}3
 )->(((_2 >> #1) ^ _1) & _3)
-
+  
 ; Bitwise complements. (The INTERCAL which ultimately leads to cases 3 and 4
 ; is not the most efficient way to do this, by the way.)
 [cnot1]
-(#65535 ^ .{!c&4294901760LU}1)->(~16 .1)
+(#65535 ^ .{!(c&4294901760LU)}1)->(~16 .1)
 [cnot2]
-(.{!c&4294901760LU}1 ^ #65535)->(~16 .1)
+(.{!(c&4294901760LU)}1 ^ #65535)->(~16 .1)
 [cnot3]
 (#4294967295 ^ :1)->(~32 :1)
 [cnot4]
 (:1 ^ #4294967295)->(~32 :1)
 
+; bitwise logical equivalence
+[cxorand16]
+((.1 ^ _2) & _2)->((~16 .1) & _2)
+((_2 ^ .1) & _2)->((~16 .1) & _2)
+((.1 & _2) ^ _2)->((~16 .1) & _2)
+((_2 & .1) ^ _2)->((~16 .1) & _2)
+(_2 ^ (.1 & _2))->((~16 .1) & _2)
+(_2 ^ (_2 & .1))->((~16 .1) & _2)
+(_2 & (.1 ^ _2))->((~16 .1) & _2)
+(_2 & (_2 ^ .1))->((~16 .1) & _2)
+[cxorand32]
+((:1 ^ _2) & _2)->((~32 _1) & _2)
+((_2 ^ :1) & _2)->((~32 _1) & _2)
+((:1 & _2) ^ _2)->((~32 _1) & _2)
+((_2 & :1) ^ _2)->((~32 _1) & _2)
+(_2 ^ (:1 & _2))->((~32 _1) & _2)
+(_2 ^ (_2 & :1))->((~32 _1) & _2)
+(_2 & (:1 ^ _2))->((~32 _1) & _2)
+(_2 & (_2 ^ :1))->((~32 _1) & _2)
+
 ; Special cases of select
 
 ; Selecting the rightmost bits of a number