mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-06 15:41:05 +00:00
Fixed problem with recursive aliasses (it was caused by a bad alias-replacement earlier). Closes #305
Fixed literal calculation of constant pointer decrement.
This commit is contained in:
parent
42ecee2f94
commit
036ff9259c
@ -5,6 +5,7 @@ import dk.camelot64.kickc.model.symbols.ProgramScope;
|
||||
import dk.camelot64.kickc.model.types.SymbolType;
|
||||
import dk.camelot64.kickc.model.values.ConstantInteger;
|
||||
import dk.camelot64.kickc.model.values.ConstantLiteral;
|
||||
import dk.camelot64.kickc.model.values.ConstantPointer;
|
||||
|
||||
/** Unary Decrement operator (--) */
|
||||
public class OperatorDecrement extends OperatorUnary {
|
||||
@ -17,6 +18,8 @@ public class OperatorDecrement extends OperatorUnary {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand, ProgramScope scope) {
|
||||
if(operand instanceof ConstantInteger ) {
|
||||
return new ConstantInteger(((ConstantInteger) operand).getInteger() -1);
|
||||
} else if(operand instanceof ConstantPointer) {
|
||||
return new ConstantPointer(0xffff&(((ConstantPointer) operand).getLocation()-1), ((ConstantPointer) operand).getElementType());
|
||||
}
|
||||
throw new ConstantNotLiteral("Calculation not literal " + getOperator() + " " + operand );
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class OperatorIncrement extends OperatorUnary {
|
||||
if(operand instanceof ConstantInteger ) {
|
||||
return new ConstantInteger(((ConstantInteger) operand).getInteger() + 1);
|
||||
} else if(operand instanceof ConstantPointer) {
|
||||
return new ConstantPointer(((ConstantPointer) operand).getLocation()+1, ((ConstantPointer) operand).getElementType());
|
||||
return new ConstantPointer(0xffff&(((ConstantPointer) operand).getLocation()+1), ((ConstantPointer) operand).getElementType());
|
||||
}
|
||||
throw new ConstantNotLiteral("Calculation not literal " + getOperator() + " " + operand );
|
||||
}
|
||||
|
@ -45,42 +45,40 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
|
||||
|
||||
// Remove all candidates that are used after assignment in phi blocks
|
||||
private static void cleanupCandidates(Aliases candidates, Program program) {
|
||||
for(final AliasSet aliasSet : candidates.aliases) {
|
||||
for(ControlFlowBlock block : program.getGraph().getAllBlocks()) {
|
||||
if(block.hasPhiBlock()) {
|
||||
StatementPhiBlock phi = block.getPhiBlock();
|
||||
boolean lMatch = false;
|
||||
for(StatementPhiBlock.PhiVariable phiVariable : phi.getPhiVariables()) {
|
||||
if(lMatch) {
|
||||
if(aliasSet.contains(phiVariable.getVariable())) {
|
||||
// Assigning inside tha alias set again - no need to check the variables
|
||||
continue;
|
||||
}
|
||||
for(StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) {
|
||||
RValue rValue = phiRValue.getrValue();
|
||||
if(aliasSet.contains(rValue)) {
|
||||
program.getLog().append("Alias candidate removed (phi-usage) " + rValue.toString(program));
|
||||
aliasSet.remove(rValue);
|
||||
break;
|
||||
ListIterator<AliasSet> aliasSetListIterator = candidates.getAliasSets().listIterator();
|
||||
while(aliasSetListIterator.hasNext()) {
|
||||
AliasSet aliasSet = aliasSetListIterator.next();
|
||||
boolean removeSet = false;
|
||||
for(ControlFlowBlock block : program.getGraph().getAllBlocks()) {
|
||||
if(block.hasPhiBlock()) {
|
||||
StatementPhiBlock phi = block.getPhiBlock();
|
||||
boolean lMatch = false;
|
||||
for(StatementPhiBlock.PhiVariable phiVariable : phi.getPhiVariables()) {
|
||||
if(lMatch) {
|
||||
if(aliasSet.contains(phiVariable.getVariable())) {
|
||||
// Assigning inside tha alias set again - no need to check the variables
|
||||
continue;
|
||||
}
|
||||
for(StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) {
|
||||
RValue rValue = phiRValue.getrValue();
|
||||
if(aliasSet.contains(rValue)) {
|
||||
removeSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(aliasSet.contains(phiVariable.getVariable())) {
|
||||
lMatch = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(aliasSet.contains(phiVariable.getVariable())) {
|
||||
lMatch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(removeSet) {
|
||||
program.getLog().append("Alias candidate removed (phi-usage) " + aliasSet.toString(program));
|
||||
aliasSetListIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
ListIterator<AliasSet> aliasSetListIterator = candidates.getAliasSets().listIterator();
|
||||
while(aliasSetListIterator.hasNext()) {
|
||||
AliasSet aliasSet = aliasSetListIterator.next();
|
||||
if(aliasSet.getVars().size() <= 1) {
|
||||
program.getLog().append("Alias candidate removed (solo) " + aliasSet.toString(program));
|
||||
aliasSetListIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all candidates that are volatile and not assigned to the same variable
|
||||
@ -101,7 +99,7 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
|
||||
if(unversionedFullName == null) {
|
||||
unversionedFullName = variableRef.getFullNameUnversioned();
|
||||
} else if(!unversionedFullName.equals(variableRef.getFullNameUnversioned())) {
|
||||
sameBaseVar = false;
|
||||
sameBaseVar = false;
|
||||
}
|
||||
}
|
||||
if(anyVolatile & !sameBaseVar) {
|
||||
@ -204,7 +202,7 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
|
||||
List<StatementLValue> assignments = new ArrayList<>();
|
||||
for(VariableRef aliasVar : aliasSet.getVars()) {
|
||||
StatementLValue assignment = getGraph().getAssignment(aliasVar);
|
||||
if(assignment!=null) {
|
||||
if(assignment != null) {
|
||||
assignments.add(assignment);
|
||||
StatementSource source = assignment.getSource();
|
||||
if(bestSource == null) {
|
||||
@ -221,7 +219,7 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bestSource!=null) {
|
||||
if(bestSource != null) {
|
||||
// Found a best source - update all statements
|
||||
for(StatementLValue assignment : assignments) {
|
||||
assignment.setSource(bestSource);
|
||||
@ -254,7 +252,7 @@ public class Pass2AliasElimination extends Pass2SsaOptimization {
|
||||
while(variableIterator.hasNext()) {
|
||||
StatementPhiBlock.PhiVariable phiVariable = variableIterator.next();
|
||||
AliasSet aliasSet = aliases.findAliasSet(phiVariable.getVariable());
|
||||
if(aliasSet != null && phiVariable.getValues().size()>0) {
|
||||
if(aliasSet != null && phiVariable.getValues().size() > 0) {
|
||||
boolean remove = true;
|
||||
for(StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) {
|
||||
if(!aliasSet.contains(phiRValue.getrValue())) {
|
||||
|
@ -3014,10 +3014,8 @@ Alias (byte*) initSprites::sp#2 = (byte*) initSprites::sp#3
|
||||
Alias (word) setupRasterIrq::raster#1 = (word) setupRasterIrq::raster#3 (word) setupRasterIrq::raster#4
|
||||
Alias (void()*) setupRasterIrq::irqRoutine#2 = (void()*) setupRasterIrq::irqRoutine#4 (void()*) setupRasterIrq::irqRoutine#3
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::x#3 =
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::y#3 =
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2 = (byte) getCharToProcess::x#3
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2 = (byte) getCharToProcess::y#3
|
||||
Alias (signed word) atan2_16::x#1 = (signed word) atan2_16::x#5 (signed word) atan2_16::x#10
|
||||
Alias (signed word) atan2_16::y#1 = (signed word) atan2_16::y#12 (signed word) atan2_16::y#9
|
||||
Alias (signed word) atan2_16::yi#0 = (signed word) atan2_16::yi#9
|
||||
@ -3044,16 +3042,12 @@ Alias (word) processChars::xpos#0 = (word) processChars::xpos#1
|
||||
Alias (word) setupRasterIrq::raster#1 = (word) setupRasterIrq::raster#2
|
||||
Alias (void()*) setupRasterIrq::irqRoutine#1 = (void()*) setupRasterIrq::irqRoutine#2
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::x#3 =
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::y#3 =
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2 = (byte) getCharToProcess::x#3
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2 = (byte) getCharToProcess::y#3
|
||||
Alias (byte) processChars::i#10 = (byte) processChars::i#3
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::x#3 =
|
||||
Alias candidate removed (solo) (byte) getCharToProcess::y#3 =
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::x#2 = (byte) getCharToProcess::x#3
|
||||
Alias candidate removed (phi-usage) (byte) getCharToProcess::y#2 = (byte) getCharToProcess::y#3
|
||||
Identical Phi Values (signed word) atan2_16::y#1 (signed word) atan2_16::y#0
|
||||
Identical Phi Values (signed word) atan2_16::x#1 (signed word) atan2_16::x#0
|
||||
Identical Phi Values (signed word) atan2_16::yi#10 (signed word) atan2_16::yi#3
|
||||
|
@ -146,14 +146,13 @@ Alias (byte) main::pos#1 = (byte) main::pos#4 (byte) main::min#1
|
||||
Alias (byte) main::pos#3 = (byte) main::pos#6 (byte) main::max#1
|
||||
Alias (byte) main::min#5 = (byte) main::min#6
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) main::pos#1
|
||||
Alias (byte) main::pos#3 = (byte) main::pos#5
|
||||
Alias candidate removed (phi-usage) (byte) main::pos#1 = (byte) main::pos#3 (byte) main::pos#5
|
||||
Alias (byte) main::max#2 = (byte) main::max#4
|
||||
Alias (byte) main::min#3 = (byte) main::min#5
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) main::pos#1
|
||||
Alias candidate removed (solo) (byte) main::pos#3 =
|
||||
Alias candidate removed (phi-usage) (byte) main::pos#1 = (byte) main::pos#3 (byte) main::pos#5
|
||||
Identical Phi Values (byte) main::pos#3 (byte) main::pos#1
|
||||
Identical Phi Values (byte) main::pos#5 (byte) main::pos#3
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) main::$1 [10] if((byte) main::pos#1>=(byte) main::min#2) goto main::@4
|
||||
Simple Condition (bool~) main::$3 [14] if((byte) main::pos#1<=(byte) main::max#2) goto main::@5
|
||||
|
@ -188,8 +188,7 @@ Alias (byte) scan_for_lowest::i#2 = (byte) scan_for_lowest::i#3 (byte) scan_for_
|
||||
Alias (signed word) scan_for_lowest::height#2 = (signed word) scan_for_lowest::height#3
|
||||
Alias (byte) scan_for_lowest::lowest#2 = (byte) scan_for_lowest::lowest#5 (byte) scan_for_lowest::lowest#3 (byte) scan_for_lowest::return#1 (byte) scan_for_lowest::return#4 (byte) scan_for_lowest::return#2
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) scan_for_lowest::i#2
|
||||
Alias candidate removed (solo) (byte) scan_for_lowest::i#4 =
|
||||
Alias candidate removed (phi-usage) (byte) scan_for_lowest::i#2 = (byte) scan_for_lowest::i#4
|
||||
Identical Phi Values (byte) scan_for_lowest::i#4 (byte) scan_for_lowest::i#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Identified duplicate assignment right side [11] (byte~) main::$4 ← (byte) main::hit_check#0 * (const byte) SIZEOF_SIGNED_WORD
|
||||
|
@ -92,8 +92,7 @@ Inversing boolean not [6] (bool~) main::$1 ← (byte) 0 == (byte~) main::$0 from
|
||||
Successful SSA optimization Pass2UnaryNotSimplification
|
||||
Alias (byte) main::i#2 = (word) main::w#0 (byte) main::i#4
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte) main::i#2
|
||||
Alias candidate removed (solo) (byte) main::i#3 =
|
||||
Alias candidate removed (phi-usage) (byte) main::i#2 = (byte) main::i#3
|
||||
Identical Phi Values (byte) main::i#3 (byte) main::i#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) main::$1 [7] if((byte) 0==(byte~) main::$0) goto main::@2
|
||||
|
@ -2891,9 +2891,9 @@ Alias (word) main::v#13 = (word) main::v#4 (word) main::v#6 (word) main::v#15
|
||||
Alias (word) myprintf::w3#1 = (word~) main::$15
|
||||
Alias (signed word) main::return#0 = (signed word) main::return#3 (signed word) main::return#1
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w1#10
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w2#11
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w3#11
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w1#10 = (word) myprintf::w1#29 (word) myprintf::w1#18 (word) myprintf::w1#12 (word) myprintf::w1#13
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w2#11 = (word) myprintf::w2#30 (word) myprintf::w2#19 (word) myprintf::w2#13 (word) myprintf::w2#14
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w3#11 = (word) myprintf::w3#30 (word) myprintf::w3#19 (word) myprintf::w3#13 (word) myprintf::w3#14
|
||||
Alias (word) divr16u::dividend#2 = (word) divr16u::dividend#3
|
||||
Alias (word) divr16u::quotient#3 = (word) divr16u::quotient#6
|
||||
Alias (word) divr16u::divisor#1 = (word) divr16u::divisor#3 (word) divr16u::divisor#6
|
||||
@ -2905,9 +2905,6 @@ Alias (byte) myprintf::bLen#10 = (byte) myprintf::bLen#16 (byte) myprintf::bLen#
|
||||
Alias (word) myprintf::w#10 = (word) myprintf::w#30 (word) myprintf::w#25 (word) myprintf::w#23
|
||||
Alias (byte*) myprintf::str#10 = (byte*) myprintf::str#28 (byte*) myprintf::str#12 (byte*) myprintf::str#16 (byte*) myprintf::str#11
|
||||
Alias (byte) myprintf::bArg#10 = (byte) myprintf::bArg#29 (byte) myprintf::bArg#20 (byte) myprintf::bArg#4 (byte) myprintf::bArg#15
|
||||
Alias (word) myprintf::w1#12 = (word) myprintf::w1#29 (word) myprintf::w1#18 (word) myprintf::w1#13
|
||||
Alias (word) myprintf::w2#13 = (word) myprintf::w2#30 (word) myprintf::w2#19 (word) myprintf::w2#14
|
||||
Alias (word) myprintf::w3#13 = (word) myprintf::w3#30 (word) myprintf::w3#19 (word) myprintf::w3#14
|
||||
Alias (byte) myprintf::bTrailing#11 = (byte) myprintf::bTrailing#39 (byte) myprintf::bTrailing#30 (byte) myprintf::bTrailing#28
|
||||
Alias (byte) myprintf::bDigits#16 = (byte) myprintf::bDigits#42 (byte) myprintf::bDigits#34 (byte) myprintf::bDigits#32
|
||||
Alias (byte) myprintf::bLeadZero#11 = (byte) myprintf::bLeadZero#36 (byte) myprintf::bLeadZero#26 (byte) myprintf::bLeadZero#25
|
||||
@ -2931,12 +2928,9 @@ Alias (byte) myprintf::bDigits#31 = (byte) myprintf::bDigits#37
|
||||
Alias (byte) myprintf::bLeadZero#2 = (byte) myprintf::bLeadZero#24
|
||||
Alias (byte) myprintf::bFormat#10 = (byte) myprintf::bFormat#9
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w1#10
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w2#11
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w3#11
|
||||
Alias candidate removed (solo) (word) myprintf::w1#12 =
|
||||
Alias candidate removed (solo) (word) myprintf::w2#13 =
|
||||
Alias candidate removed (solo) (word) myprintf::w3#13 =
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w1#10 = (word) myprintf::w1#29 (word) myprintf::w1#18 (word) myprintf::w1#12 (word) myprintf::w1#13
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w2#11 = (word) myprintf::w2#30 (word) myprintf::w2#19 (word) myprintf::w2#13 (word) myprintf::w2#14
|
||||
Alias candidate removed (phi-usage) (word) myprintf::w3#11 = (word) myprintf::w3#30 (word) myprintf::w3#19 (word) myprintf::w3#13 (word) myprintf::w3#14
|
||||
Identical Phi Values (word) divr16u::rem#8 (word) divr16u::rem#3
|
||||
Identical Phi Values (word) divr16u::dividend#4 (word) divr16u::dividend#1
|
||||
Identical Phi Values (word) divr16u::divisor#5 (word) divr16u::divisor#0
|
||||
@ -2947,9 +2941,12 @@ Identical Phi Values (word) append::sub#4 (word) append::sub#6
|
||||
Identical Phi Values (byte*) append::dst#5 (byte*) append::dst#4
|
||||
Identical Phi Values (word) utoa::value#5 (word) utoa::value#4
|
||||
Identical Phi Values (byte*) utoa::dst#15 (byte*) utoa::dst#5
|
||||
Identical Phi Values (word) myprintf::w1#12 (word) myprintf::w1#10
|
||||
Identical Phi Values (word) myprintf::w2#13 (word) myprintf::w2#11
|
||||
Identical Phi Values (word) myprintf::w3#13 (word) myprintf::w3#11
|
||||
Identical Phi Values (word) myprintf::w1#29 (word) myprintf::w1#10
|
||||
Identical Phi Values (word) myprintf::w2#30 (word) myprintf::w2#11
|
||||
Identical Phi Values (word) myprintf::w3#30 (word) myprintf::w3#11
|
||||
Identical Phi Values (word) myprintf::w1#18 (word) myprintf::w1#29
|
||||
Identical Phi Values (word) myprintf::w2#19 (word) myprintf::w2#30
|
||||
Identical Phi Values (word) myprintf::w3#19 (word) myprintf::w3#30
|
||||
Identical Phi Values (byte) myprintf::bTrailing#3 (byte) myprintf::bTrailing#11
|
||||
Identical Phi Values (byte) myprintf::bDigits#11 (byte) myprintf::bDigits#16
|
||||
Identical Phi Values (byte) myprintf::bLeadZero#10 (byte) myprintf::bLeadZero#11
|
||||
@ -2992,6 +2989,12 @@ Identical Phi Values (word) myprintf::w3#21 (word) myprintf::w3#20
|
||||
Identical Phi Values (word) myprintf::w#27 (word) myprintf::w#26
|
||||
Identical Phi Values (byte) myprintf::bTrailing#31 (byte) myprintf::bTrailing#10
|
||||
Identical Phi Values (byte) myprintf::bLeadZero#28 (byte) myprintf::bLeadZero#27
|
||||
Identical Phi Values (word) myprintf::w1#12 (word) myprintf::w1#10
|
||||
Identical Phi Values (word) myprintf::w2#13 (word) myprintf::w2#11
|
||||
Identical Phi Values (word) myprintf::w3#13 (word) myprintf::w3#11
|
||||
Identical Phi Values (word) myprintf::w1#13 (word) myprintf::w1#10
|
||||
Identical Phi Values (word) myprintf::w2#14 (word) myprintf::w2#11
|
||||
Identical Phi Values (word) myprintf::w3#14 (word) myprintf::w3#11
|
||||
Identical Phi Values (word) div10::val#5 (word) div10::val#4
|
||||
Identical Phi Values (word) main::u#11 (word) main::u#15
|
||||
Identical Phi Values (word) main::u#10 (word) main::u#17
|
||||
|
@ -2176,8 +2176,7 @@ Alias (byte) NUM_SQUARES#12 = (byte) NUM_SQUARES#5
|
||||
Alias (byte*) heap_head#11 = (byte*) heap_head#22
|
||||
Alias (word*) SQUARES#16 = (word*) SQUARES#7
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte*) main::fill#2
|
||||
Alias candidate removed (solo) (byte*) main::fill#3 =
|
||||
Alias candidate removed (phi-usage) (byte*) main::fill#2 = (byte*) main::fill#3
|
||||
Alias (word) bsearch16u::key#1 = (word) bsearch16u::key#5
|
||||
Alias (signed word) atan2_16::x#1 = (signed word) atan2_16::x#5 (signed word) atan2_16::x#10
|
||||
Alias (signed word) atan2_16::y#1 = (signed word) atan2_16::y#12 (signed word) atan2_16::y#9
|
||||
@ -2210,8 +2209,7 @@ Alias (byte) init_dist_screen::xb#2 = (byte) init_dist_screen::xb#5
|
||||
Alias (byte) init_dist_screen::y#11 = (byte) init_dist_screen::y#12
|
||||
Alias (byte*) heap_head#10 = (byte*) heap_head#42
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte*) main::fill#2
|
||||
Alias candidate removed (solo) (byte*) main::fill#3 =
|
||||
Alias candidate removed (phi-usage) (byte*) main::fill#2 = (byte*) main::fill#3
|
||||
Identical Phi Values (byte) bsearch16u::num#7 (byte) bsearch16u::num#2
|
||||
Identical Phi Values (word*) bsearch16u::items#7 (word*) bsearch16u::items#1
|
||||
Identical Phi Values (word) bsearch16u::key#4 (word) bsearch16u::key#0
|
||||
|
6
src/test/ref/struct-ptr-25.asm
Normal file
6
src/test/ref/struct-ptr-25.asm
Normal file
@ -0,0 +1,6 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
main: {
|
||||
rts
|
||||
}
|
15
src/test/ref/struct-ptr-25.cfg
Normal file
15
src/test/ref/struct-ptr-25.cfg
Normal file
@ -0,0 +1,15 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[5] return
|
||||
to:@return
|
366
src/test/ref/struct-ptr-25.log
Normal file
366
src/test/ref/struct-ptr-25.log
Normal file
@ -0,0 +1,366 @@
|
||||
Identified constant variable (byte*) filesEnd
|
||||
Identified constant variable (byte*) file
|
||||
Culled Empty Block (label) main::@3
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
(byte*) fileCur#0 ← (byte*) 0
|
||||
(byte*) fileTop#0 ← (byte*) 0
|
||||
(byte*) filesEnd#0 ← (byte*) 0
|
||||
(byte*) file#0 ← (byte*) 0
|
||||
to:@1
|
||||
main: scope:[main] from @1
|
||||
(byte*) fileCur#10 ← phi( @1/(byte*) fileCur#12 )
|
||||
(byte*) fileTop#4 ← phi( @1/(byte*) fileTop#10 )
|
||||
(bool~) main::$0 ← (byte*) fileTop#4 == (byte*) filesEnd#0
|
||||
(bool~) main::$1 ← ! (bool~) main::$0
|
||||
if((bool~) main::$1) goto main::@1
|
||||
to:main::@4
|
||||
main::@1: scope:[main] from main main::@4
|
||||
(byte*) fileTop#11 ← phi( main/(byte*) fileTop#4 main::@4/(byte*) fileTop#1 )
|
||||
(byte*) fileCur#5 ← phi( main/(byte*) fileCur#10 main::@4/(byte*) fileCur#11 )
|
||||
(bool~) main::$2 ← (byte*) file#0 <= (byte*) fileCur#5
|
||||
(bool~) main::$3 ← ! (bool~) main::$2
|
||||
if((bool~) main::$3) goto main::@2
|
||||
to:main::@5
|
||||
main::@4: scope:[main] from main
|
||||
(byte*) fileCur#11 ← phi( main/(byte*) fileCur#10 )
|
||||
(byte*) fileTop#5 ← phi( main/(byte*) fileTop#4 )
|
||||
(byte*) fileTop#1 ← -- (byte*) fileTop#5
|
||||
to:main::@1
|
||||
main::@2: scope:[main] from main::@1 main::@5
|
||||
(byte*) fileTop#6 ← phi( main::@1/(byte*) fileTop#11 main::@5/(byte*) fileTop#12 )
|
||||
(byte*) fileCur#6 ← phi( main::@1/(byte*) fileCur#5 main::@5/(byte*) fileCur#1 )
|
||||
(bool~) main::$4 ← (byte*) fileCur#6 < (byte*) fileTop#6
|
||||
(bool~) main::$5 ← ! (bool~) main::$4
|
||||
if((bool~) main::$5) goto main::@return
|
||||
to:main::@6
|
||||
main::@5: scope:[main] from main::@1
|
||||
(byte*) fileTop#12 ← phi( main::@1/(byte*) fileTop#11 )
|
||||
(byte*) fileCur#7 ← phi( main::@1/(byte*) fileCur#5 )
|
||||
(byte*) fileCur#1 ← -- (byte*) fileCur#7
|
||||
to:main::@2
|
||||
main::@6: scope:[main] from main::@2
|
||||
(byte*) fileTop#7 ← phi( main::@2/(byte*) fileTop#6 )
|
||||
(byte*) fileCur#2 ← (byte*) fileTop#7
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2 main::@6
|
||||
(byte*) fileCur#8 ← phi( main::@2/(byte*) fileCur#6 main::@6/(byte*) fileCur#2 )
|
||||
(byte*) fileTop#8 ← phi( main::@2/(byte*) fileTop#6 main::@6/(byte*) fileTop#7 )
|
||||
(byte*) fileTop#2 ← (byte*) fileTop#8
|
||||
(byte*) fileCur#3 ← (byte*) fileCur#8
|
||||
return
|
||||
to:@return
|
||||
@1: scope:[] from @begin
|
||||
(byte*) fileCur#12 ← phi( @begin/(byte*) fileCur#0 )
|
||||
(byte*) fileTop#10 ← phi( @begin/(byte*) fileTop#0 )
|
||||
call main
|
||||
to:@2
|
||||
@2: scope:[] from @1
|
||||
(byte*) fileCur#9 ← phi( @1/(byte*) fileCur#3 )
|
||||
(byte*) fileTop#9 ← phi( @1/(byte*) fileTop#2 )
|
||||
(byte*) fileTop#3 ← (byte*) fileTop#9
|
||||
(byte*) fileCur#4 ← (byte*) fileCur#9
|
||||
to:@end
|
||||
@end: scope:[] from @2
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) file
|
||||
(byte*) file#0
|
||||
(byte*) fileCur
|
||||
(byte*) fileCur#0
|
||||
(byte*) fileCur#1
|
||||
(byte*) fileCur#10
|
||||
(byte*) fileCur#11
|
||||
(byte*) fileCur#12
|
||||
(byte*) fileCur#2
|
||||
(byte*) fileCur#3
|
||||
(byte*) fileCur#4
|
||||
(byte*) fileCur#5
|
||||
(byte*) fileCur#6
|
||||
(byte*) fileCur#7
|
||||
(byte*) fileCur#8
|
||||
(byte*) fileCur#9
|
||||
(byte*) fileTop
|
||||
(byte*) fileTop#0
|
||||
(byte*) fileTop#1
|
||||
(byte*) fileTop#10
|
||||
(byte*) fileTop#11
|
||||
(byte*) fileTop#12
|
||||
(byte*) fileTop#2
|
||||
(byte*) fileTop#3
|
||||
(byte*) fileTop#4
|
||||
(byte*) fileTop#5
|
||||
(byte*) fileTop#6
|
||||
(byte*) fileTop#7
|
||||
(byte*) fileTop#8
|
||||
(byte*) fileTop#9
|
||||
(byte*) filesEnd
|
||||
(byte*) filesEnd#0
|
||||
(void()) main()
|
||||
(bool~) main::$0
|
||||
(bool~) main::$1
|
||||
(bool~) main::$2
|
||||
(bool~) main::$3
|
||||
(bool~) main::$4
|
||||
(bool~) main::$5
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@4
|
||||
(label) main::@5
|
||||
(label) main::@6
|
||||
(label) main::@return
|
||||
|
||||
Inversing boolean not [6] (bool~) main::$1 ← (byte*) fileTop#4 != (byte*) filesEnd#0 from [5] (bool~) main::$0 ← (byte*) fileTop#4 == (byte*) filesEnd#0
|
||||
Inversing boolean not [10] (bool~) main::$3 ← (byte*) file#0 > (byte*) fileCur#5 from [9] (bool~) main::$2 ← (byte*) file#0 <= (byte*) fileCur#5
|
||||
Inversing boolean not [16] (bool~) main::$5 ← (byte*) fileCur#6 >= (byte*) fileTop#6 from [15] (bool~) main::$4 ← (byte*) fileCur#6 < (byte*) fileTop#6
|
||||
Successful SSA optimization Pass2UnaryNotSimplification
|
||||
Alias (byte*) fileTop#4 = (byte*) fileTop#5
|
||||
Alias (byte*) fileCur#10 = (byte*) fileCur#11
|
||||
Alias (byte*) fileCur#5 = (byte*) fileCur#7
|
||||
Alias (byte*) fileTop#11 = (byte*) fileTop#12
|
||||
Alias (byte*) fileTop#6 = (byte*) fileTop#7 (byte*) fileCur#2
|
||||
Alias (byte*) fileTop#2 = (byte*) fileTop#8
|
||||
Alias (byte*) fileCur#3 = (byte*) fileCur#8
|
||||
Alias (byte*) fileTop#0 = (byte*) fileTop#10
|
||||
Alias (byte*) fileCur#0 = (byte*) fileCur#12
|
||||
Alias (byte*) fileTop#3 = (byte*) fileTop#9
|
||||
Alias (byte*) fileCur#4 = (byte*) fileCur#9
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte*) fileTop#11 = (byte*) fileTop#6 (byte*) fileTop#2
|
||||
Alias (byte*) fileCur#10 = (byte*) fileCur#5
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Alias candidate removed (phi-usage) (byte*) fileTop#11 = (byte*) fileTop#6 (byte*) fileTop#2
|
||||
Identical Phi Values (byte*) fileTop#4 (byte*) fileTop#0
|
||||
Identical Phi Values (byte*) fileCur#10 (byte*) fileCur#0
|
||||
Identical Phi Values (byte*) fileTop#6 (byte*) fileTop#11
|
||||
Identical Phi Values (byte*) fileTop#2 (byte*) fileTop#6
|
||||
Identical Phi Values (byte*) fileTop#3 (byte*) fileTop#2
|
||||
Identical Phi Values (byte*) fileCur#4 (byte*) fileCur#3
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) main::$1 [7] if((byte*) fileTop#0!=(byte*) filesEnd#0) goto main::@1
|
||||
Simple Condition (bool~) main::$3 [11] if((byte*) file#0>(byte*) fileCur#0) goto main::@2
|
||||
Simple Condition (bool~) main::$5 [17] if((byte*) fileCur#6>=(byte*) fileTop#11) goto main::@return
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte*) fileCur#0 = (byte*) 0
|
||||
Constant (const byte*) fileTop#0 = (byte*) 0
|
||||
Constant (const byte*) filesEnd#0 = (byte*) 0
|
||||
Constant (const byte*) file#0 = (byte*) 0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Removing PHI-reference to removed block (main) in block main::@1
|
||||
if() condition always false - eliminating [7] if((const byte*) fileTop#0!=(const byte*) filesEnd#0) goto main::@1
|
||||
Removing PHI-reference to removed block (main::@1) in block main::@2
|
||||
if() condition always false - eliminating [11] if((const byte*) file#0>(const byte*) fileCur#0) goto main::@2
|
||||
Successful SSA optimization Pass2ConstantIfs
|
||||
Eliminating unused variable - keeping the phi block (byte*) fileCur#3
|
||||
Eliminating unused constant (const byte*) filesEnd#0
|
||||
Eliminating unused constant (const byte*) file#0
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
Alias (byte*) fileTop#1 = (byte*) fileTop#11
|
||||
Alias (byte*) fileCur#1 = (byte*) fileCur#6
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Constant right-side identified [1] (byte*) fileTop#1 ← -- (const byte*) fileTop#0
|
||||
Constant right-side identified [4] (byte*) fileCur#1 ← -- (const byte*) fileCur#0
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const byte*) fileTop#1 = --fileTop#0
|
||||
Constant (const byte*) fileCur#1 = --fileCur#0
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
if() condition always true - replacing block destination [3] if((const byte*) fileCur#1>=(const byte*) fileTop#1) goto main::@return
|
||||
Successful SSA optimization Pass2ConstantIfs
|
||||
Eliminating unused constant (const byte*) fileTop#1
|
||||
Eliminating unused constant (const byte*) fileCur#1
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
Eliminating unused constant (const byte*) fileCur#0
|
||||
Eliminating unused constant (const byte*) fileTop#0
|
||||
Successful SSA optimization PassNEliminateUnusedVars
|
||||
Removing unused block main::@6
|
||||
Successful SSA optimization Pass2EliminateUnusedBlocks
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @2
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
Adding NOP phi() at start of main::@4
|
||||
Adding NOP phi() at start of main::@1
|
||||
Adding NOP phi() at start of main::@5
|
||||
Adding NOP phi() at start of main::@2
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 0 initial phi equivalence classes
|
||||
Coalesced down to 0 phi equivalence classes
|
||||
Culled Empty Block (label) @2
|
||||
Culled Empty Block (label) main::@4
|
||||
Culled Empty Block (label) main::@1
|
||||
Culled Empty Block (label) main::@5
|
||||
Culled Empty Block (label) main::@2
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[5] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) file
|
||||
(byte*) fileCur
|
||||
(byte*) fileTop
|
||||
(byte*) filesEnd
|
||||
(void()) main()
|
||||
|
||||
Initial phi equivalence classes
|
||||
Complete equivalence classes
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @begin
|
||||
bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
b1_from_bbegin:
|
||||
jmp b1
|
||||
// @1
|
||||
b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
// @end
|
||||
bend:
|
||||
// main
|
||||
main: {
|
||||
jmp breturn
|
||||
// main::@return
|
||||
breturn:
|
||||
// [5] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 48 combination
|
||||
Uplifting [] best 48 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @begin
|
||||
bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
b1_from_bbegin:
|
||||
jmp b1
|
||||
// @1
|
||||
b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from_b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
bend_from_b1:
|
||||
jmp bend
|
||||
// @end
|
||||
bend:
|
||||
// main
|
||||
main: {
|
||||
jmp breturn
|
||||
// main::@return
|
||||
breturn:
|
||||
// [5] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction main_from_b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction bbegin:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) file
|
||||
(byte*) fileCur
|
||||
(byte*) fileTop
|
||||
(byte*) filesEnd
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 6
|
||||
|
||||
// File Comments
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
// @begin
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
// @1
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
// @end
|
||||
// main
|
||||
main: {
|
||||
// main::@return
|
||||
// }
|
||||
// [5] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
|
10
src/test/ref/struct-ptr-25.sym
Normal file
10
src/test/ref/struct-ptr-25.sym
Normal file
@ -0,0 +1,10 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) file
|
||||
(byte*) fileCur
|
||||
(byte*) fileTop
|
||||
(byte*) filesEnd
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
|
Loading…
x
Reference in New Issue
Block a user