diff --git a/src/test/java/dk/camelot64/kickc/test/kc/bool-min.kc b/src/test/java/dk/camelot64/kickc/test/kc/bool-min.kc
index 250bad687..341addd12 100644
--- a/src/test/java/dk/camelot64/kickc/test/kc/bool-min.kc
+++ b/src/test/java/dk/camelot64/kickc/test/kc/bool-min.kc
@@ -22,9 +22,9 @@ void bool_const_if() {
// A bunch of constant boolean vars (used in an if)
void bool_const_vars() {
byte a = 14;
- boolean b1 = (a==15);
- boolean b2 = 21 < a;
- boolean b = b1 || b2;
+ boolean b1 = (a==15) || !(21=-8);
+ boolean b = b1 && !b2 || false;
if(b) {
SCREEN[1] = 't';
} else {
diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bool-min.log b/src/test/java/dk/camelot64/kickc/test/ref/bool-min.log
index 4eb63fa3c..0dfbdddc4 100644
--- a/src/test/java/dk/camelot64/kickc/test/ref/bool-min.log
+++ b/src/test/java/dk/camelot64/kickc/test/ref/bool-min.log
@@ -23,9 +23,9 @@ void bool_const_if() {
// A bunch of constant boolean vars (used in an if)
void bool_const_vars() {
byte a = 14;
- boolean b1 = (a==15);
- boolean b2 = 21 < a;
- boolean b = b1 || b2;
+ boolean b1 = (a==15) || !(21=-8);
+ boolean b = b1 && !b2 || false;
if(b) {
SCREEN[1] = 't';
} else {
@@ -56,13 +56,21 @@ endproc // bool_const_if()
proc (void()) bool_const_vars()
(byte) bool_const_vars::a ← (byte/signed byte/word/signed word/dword/signed dword) 14
(boolean~) bool_const_vars::$0 ← (byte) bool_const_vars::a == (byte/signed byte/word/signed word/dword/signed dword) 15
- (boolean) bool_const_vars::b1 ← (boolean~) bool_const_vars::$0
(boolean~) bool_const_vars::$1 ← (byte/signed byte/word/signed word/dword/signed dword) 21 < (byte) bool_const_vars::a
- (boolean) bool_const_vars::b2 ← (boolean~) bool_const_vars::$1
- (boolean~) bool_const_vars::$2 ← (boolean) bool_const_vars::b1 || (boolean) bool_const_vars::b2
- (boolean) bool_const_vars::b ← (boolean~) bool_const_vars::$2
- (boolean~) bool_const_vars::$3 ← ! (boolean) bool_const_vars::b
- if((boolean~) bool_const_vars::$3) goto bool_const_vars::@1
+ (boolean~) bool_const_vars::$2 ← ! (boolean~) bool_const_vars::$1
+ (boolean~) bool_const_vars::$3 ← (boolean~) bool_const_vars::$0 || (boolean~) bool_const_vars::$2
+ (boolean) bool_const_vars::b1 ← (boolean~) bool_const_vars::$3
+ (boolean~) bool_const_vars::$4 ← (byte) bool_const_vars::a != (byte/signed byte/word/signed word/dword/signed dword) 44
+ (signed byte/signed word/signed dword~) bool_const_vars::$5 ← - (byte/signed byte/word/signed word/dword/signed dword) 8
+ (boolean~) bool_const_vars::$6 ← (byte) bool_const_vars::a >= (signed byte/signed word/signed dword~) bool_const_vars::$5
+ (boolean~) bool_const_vars::$7 ← (boolean~) bool_const_vars::$4 || (boolean~) bool_const_vars::$6
+ (boolean) bool_const_vars::b2 ← (boolean~) bool_const_vars::$7
+ (boolean~) bool_const_vars::$8 ← ! (boolean) bool_const_vars::b2
+ (boolean~) bool_const_vars::$9 ← (boolean) bool_const_vars::b1 && (boolean~) bool_const_vars::$8
+ (boolean~) bool_const_vars::$10 ← (boolean~) bool_const_vars::$9 || false
+ (boolean) bool_const_vars::b ← (boolean~) bool_const_vars::$10
+ (boolean~) bool_const_vars::$11 ← ! (boolean) bool_const_vars::b
+ if((boolean~) bool_const_vars::$11) goto bool_const_vars::@1
*((byte*) SCREEN + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 't'
goto bool_const_vars::@2
bool_const_vars::@1:
@@ -84,8 +92,16 @@ SYMBOLS
(void()) bool_const_vars()
(boolean~) bool_const_vars::$0
(boolean~) bool_const_vars::$1
+(boolean~) bool_const_vars::$10
+(boolean~) bool_const_vars::$11
(boolean~) bool_const_vars::$2
(boolean~) bool_const_vars::$3
+(boolean~) bool_const_vars::$4
+(signed byte/signed word/signed dword~) bool_const_vars::$5
+(boolean~) bool_const_vars::$6
+(boolean~) bool_const_vars::$7
+(boolean~) bool_const_vars::$8
+(boolean~) bool_const_vars::$9
(label) bool_const_vars::@1
(label) bool_const_vars::@2
(label) bool_const_vars::@return
@@ -135,13 +151,21 @@ bool_const_if::@return: scope:[bool_const_if] from bool_const_if::@2
bool_const_vars: scope:[bool_const_vars] from
(byte) bool_const_vars::a ← (byte/signed byte/word/signed word/dword/signed dword) 14
(boolean~) bool_const_vars::$0 ← (byte) bool_const_vars::a == (byte/signed byte/word/signed word/dword/signed dword) 15
- (boolean) bool_const_vars::b1 ← (boolean~) bool_const_vars::$0
(boolean~) bool_const_vars::$1 ← (byte/signed byte/word/signed word/dword/signed dword) 21 < (byte) bool_const_vars::a
- (boolean) bool_const_vars::b2 ← (boolean~) bool_const_vars::$1
- (boolean~) bool_const_vars::$2 ← (boolean) bool_const_vars::b1 || (boolean) bool_const_vars::b2
- (boolean) bool_const_vars::b ← (boolean~) bool_const_vars::$2
- (boolean~) bool_const_vars::$3 ← ! (boolean) bool_const_vars::b
- if((boolean~) bool_const_vars::$3) goto bool_const_vars::@1
+ (boolean~) bool_const_vars::$2 ← ! (boolean~) bool_const_vars::$1
+ (boolean~) bool_const_vars::$3 ← (boolean~) bool_const_vars::$0 || (boolean~) bool_const_vars::$2
+ (boolean) bool_const_vars::b1 ← (boolean~) bool_const_vars::$3
+ (boolean~) bool_const_vars::$4 ← (byte) bool_const_vars::a != (byte/signed byte/word/signed word/dword/signed dword) 44
+ (signed byte/signed word/signed dword~) bool_const_vars::$5 ← - (byte/signed byte/word/signed word/dword/signed dword) 8
+ (boolean~) bool_const_vars::$6 ← (byte) bool_const_vars::a >= (signed byte/signed word/signed dword~) bool_const_vars::$5
+ (boolean~) bool_const_vars::$7 ← (boolean~) bool_const_vars::$4 || (boolean~) bool_const_vars::$6
+ (boolean) bool_const_vars::b2 ← (boolean~) bool_const_vars::$7
+ (boolean~) bool_const_vars::$8 ← ! (boolean) bool_const_vars::b2
+ (boolean~) bool_const_vars::$9 ← (boolean) bool_const_vars::b1 && (boolean~) bool_const_vars::$8
+ (boolean~) bool_const_vars::$10 ← (boolean~) bool_const_vars::$9 || false
+ (boolean) bool_const_vars::b ← (boolean~) bool_const_vars::$10
+ (boolean~) bool_const_vars::$11 ← ! (boolean) bool_const_vars::b
+ if((boolean~) bool_const_vars::$11) goto bool_const_vars::@1
to:bool_const_vars::@3
bool_const_vars::@1: scope:[bool_const_vars] from bool_const_vars bool_const_vars::@4
*((byte*) SCREEN + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'f'
@@ -205,13 +229,21 @@ bool_const_if::@return: scope:[bool_const_if] from bool_const_if::@1 bool_const
bool_const_vars: scope:[bool_const_vars] from main::@1
(byte) bool_const_vars::a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 14
(boolean~) bool_const_vars::$0 ← (byte) bool_const_vars::a#0 == (byte/signed byte/word/signed word/dword/signed dword) 15
- (boolean) bool_const_vars::b1#0 ← (boolean~) bool_const_vars::$0
(boolean~) bool_const_vars::$1 ← (byte/signed byte/word/signed word/dword/signed dword) 21 < (byte) bool_const_vars::a#0
- (boolean) bool_const_vars::b2#0 ← (boolean~) bool_const_vars::$1
- (boolean~) bool_const_vars::$2 ← (boolean) bool_const_vars::b1#0 || (boolean) bool_const_vars::b2#0
- (boolean) bool_const_vars::b#0 ← (boolean~) bool_const_vars::$2
- (boolean~) bool_const_vars::$3 ← ! (boolean) bool_const_vars::b#0
- if((boolean~) bool_const_vars::$3) goto bool_const_vars::@1
+ (boolean~) bool_const_vars::$2 ← ! (boolean~) bool_const_vars::$1
+ (boolean~) bool_const_vars::$3 ← (boolean~) bool_const_vars::$0 || (boolean~) bool_const_vars::$2
+ (boolean) bool_const_vars::b1#0 ← (boolean~) bool_const_vars::$3
+ (boolean~) bool_const_vars::$4 ← (byte) bool_const_vars::a#0 != (byte/signed byte/word/signed word/dword/signed dword) 44
+ (signed byte/signed word/signed dword~) bool_const_vars::$5 ← - (byte/signed byte/word/signed word/dword/signed dword) 8
+ (boolean~) bool_const_vars::$6 ← (byte) bool_const_vars::a#0 >= (signed byte/signed word/signed dword~) bool_const_vars::$5
+ (boolean~) bool_const_vars::$7 ← (boolean~) bool_const_vars::$4 || (boolean~) bool_const_vars::$6
+ (boolean) bool_const_vars::b2#0 ← (boolean~) bool_const_vars::$7
+ (boolean~) bool_const_vars::$8 ← ! (boolean) bool_const_vars::b2#0
+ (boolean~) bool_const_vars::$9 ← (boolean) bool_const_vars::b1#0 && (boolean~) bool_const_vars::$8
+ (boolean~) bool_const_vars::$10 ← (boolean~) bool_const_vars::$9 || false
+ (boolean) bool_const_vars::b#0 ← (boolean~) bool_const_vars::$10
+ (boolean~) bool_const_vars::$11 ← ! (boolean) bool_const_vars::b#0
+ if((boolean~) bool_const_vars::$11) goto bool_const_vars::@1
to:bool_const_vars::@3
bool_const_vars::@1: scope:[bool_const_vars] from bool_const_vars
*((byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte) 'f'
@@ -246,8 +278,16 @@ SYMBOL TABLE SSA
(void()) bool_const_vars()
(boolean~) bool_const_vars::$0
(boolean~) bool_const_vars::$1
+(boolean~) bool_const_vars::$10
+(boolean~) bool_const_vars::$11
(boolean~) bool_const_vars::$2
(boolean~) bool_const_vars::$3
+(boolean~) bool_const_vars::$4
+(signed byte/signed word/signed dword~) bool_const_vars::$5
+(boolean~) bool_const_vars::$6
+(boolean~) bool_const_vars::$7
+(boolean~) bool_const_vars::$8
+(boolean~) bool_const_vars::$9
(label) bool_const_vars::@1
(label) bool_const_vars::@3
(label) bool_const_vars::@return
@@ -268,21 +308,33 @@ OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) main::@2
Culled Empty Block (label) @4
Succesful SSA optimization Pass2CullEmptyBlocks
-Alias (boolean) bool_const_vars::b1#0 = (boolean~) bool_const_vars::$0
-Alias (boolean) bool_const_vars::b2#0 = (boolean~) bool_const_vars::$1
-Alias (boolean) bool_const_vars::b#0 = (boolean~) bool_const_vars::$2
+Inversing boolean not (boolean~) bool_const_vars::$2 ← (byte/signed byte/word/signed word/dword/signed dword) 21 >= (byte) bool_const_vars::a#0 from (boolean~) bool_const_vars::$1 ← (byte/signed byte/word/signed word/dword/signed dword) 21 < (byte) bool_const_vars::a#0
+Succesful SSA optimization Pass2UnaryNotSimplification
+Alias (boolean) bool_const_vars::b1#0 = (boolean~) bool_const_vars::$3
+Alias (boolean) bool_const_vars::b2#0 = (boolean~) bool_const_vars::$7
+Alias (boolean) bool_const_vars::b#0 = (boolean~) bool_const_vars::$10
Succesful SSA optimization Pass2AliasElimination
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const boolean) bool_const_if::b#0 = true
Constant (const byte) bool_const_vars::a#0 = 14
+Constant (const signed byte/signed word/signed dword) bool_const_vars::$5 = -8
Succesful SSA optimization Pass2ConstantIdentification
Constant (const boolean) bool_const_if::$0 = !bool_const_if::b#0
-Constant (const boolean) bool_const_vars::b1#0 = bool_const_vars::a#0==15
-Constant (const boolean) bool_const_vars::b2#0 = 21=bool_const_vars::a#0
+Constant (const boolean) bool_const_vars::$4 = bool_const_vars::a#0!=44
+Constant (const boolean) bool_const_vars::$6 = bool_const_vars::a#0>=bool_const_vars::$5
Succesful SSA optimization Pass2ConstantIdentification
-Constant (const boolean) bool_const_vars::b#0 = bool_const_vars::b1#0||bool_const_vars::b2#0
+Constant (const boolean) bool_const_vars::b1#0 = bool_const_vars::$0||bool_const_vars::$2
+Constant (const boolean) bool_const_vars::b2#0 = bool_const_vars::$4||bool_const_vars::$6
Succesful SSA optimization Pass2ConstantIdentification
-Constant (const boolean) bool_const_vars::$3 = !bool_const_vars::b#0
+Constant (const boolean) bool_const_vars::$8 = !bool_const_vars::b2#0
+Succesful SSA optimization Pass2ConstantIdentification
+Constant (const boolean) bool_const_vars::$9 = bool_const_vars::b1#0&&bool_const_vars::$8
+Succesful SSA optimization Pass2ConstantIdentification
+Constant (const boolean) bool_const_vars::b#0 = bool_const_vars::$9||false
+Succesful SSA optimization Pass2ConstantIdentification
+Constant (const boolean) bool_const_vars::$11 = !bool_const_vars::b#0
Succesful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(SCREEN#0+0)
Consolidated array index constant in *(SCREEN#0+0)
@@ -290,21 +342,31 @@ Consolidated array index constant in *(SCREEN#0+1)
Consolidated array index constant in *(SCREEN#0+1)
Succesful SSA optimization Pass2ConstantAdditionElimination
if() condition always false - eliminating if if((const boolean) bool_const_if::$0) goto bool_const_if::@1
-if() condition always true - replacing block destination if((const boolean) bool_const_vars::$3) goto bool_const_vars::@1
+if() condition always true - replacing block destination if((const boolean) bool_const_vars::$11) goto bool_const_vars::@1
Succesful SSA optimization Pass2ConstantIfs
Removing unused block bool_const_if::@1
Removing unused block bool_const_vars::@3
Succesful SSA optimization Pass2EliminateUnusedBlocks
Eliminating unused constant (const boolean) bool_const_if::$0
-Eliminating unused constant (const boolean) bool_const_vars::$3
+Eliminating unused constant (const boolean) bool_const_vars::$11
Succesful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const boolean) bool_const_if::b#0
Eliminating unused constant (const boolean) bool_const_vars::b#0
Succesful SSA optimization PassNEliminateUnusedVars
+Eliminating unused constant (const boolean) bool_const_vars::$9
+Succesful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const boolean) bool_const_vars::b1#0
+Eliminating unused constant (const boolean) bool_const_vars::$8
+Succesful SSA optimization PassNEliminateUnusedVars
+Eliminating unused constant (const boolean) bool_const_vars::$0
+Eliminating unused constant (const boolean) bool_const_vars::$2
Eliminating unused constant (const boolean) bool_const_vars::b2#0
Succesful SSA optimization PassNEliminateUnusedVars
+Eliminating unused constant (const boolean) bool_const_vars::$4
+Eliminating unused constant (const boolean) bool_const_vars::$6
+Succesful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte) bool_const_vars::a#0
+Eliminating unused constant (const signed byte/signed word/signed dword) bool_const_vars::$5
Succesful SSA optimization PassNEliminateUnusedVars
OPTIMIZING CONTROL FLOW GRAPH
Block Sequence Planned @begin @3 @end main main::@1 main::@return bool_const_vars bool_const_vars::@1 bool_const_vars::@return bool_const_if bool_const_if::@3 bool_const_if::@return