From e1258f943de6a0e5b426bc170f0828900c646a22 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 4 Feb 2020 20:52:58 +0100 Subject: [PATCH] Working on new ValueSource based unwinding! --- .../kickc/passes/Pass1UnwindStructValues.java | 6 +- .../passes/unwinding/ValueSourceBase.java | 57 ++++++++++++++ .../passes/unwinding/ValueSourceConstant.java | 75 +++++++++++++++++++ .../unwinding/ValueSourceStructVariable.java | 35 +-------- .../passes/unwinding/ValueSourceZero.java | 73 ++++++++++++++++++ src/test/ref/struct-15.log | 12 +-- src/test/ref/struct-16.log | 8 +- src/test/ref/struct-17.log | 22 +++--- src/test/ref/struct-18.log | 14 ++-- src/test/ref/struct-19.log | 24 +++--- src/test/ref/struct-20.log | 22 +++--- src/test/ref/struct-21.log | 10 ++- src/test/ref/struct-22.log | 14 ++-- src/test/ref/struct-24.log | 14 ++-- src/test/ref/struct-26.log | 16 ++-- src/test/ref/struct-27.log | 10 ++- src/test/ref/struct-28.log | 10 ++- src/test/ref/struct-32.log | 12 +-- src/test/ref/struct-ptr-12.log | 10 ++- src/test/ref/struct-ptr-14.log | 22 +++--- 20 files changed, 342 insertions(+), 124 deletions(-) create mode 100644 src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceBase.java create mode 100644 src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceConstant.java create mode 100644 src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceZero.java diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java b/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java index 4309dab24..813fb7f40 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java @@ -316,7 +316,7 @@ public class Pass1UnwindStructValues extends Pass1Base { * @param currentStmt The current statement * @param stmtIt The statement iterator * @param currentBlock The current block - * @return The vaule source for copying. null if no value source can be created. + * @return The value source for copying. null if no value source can be created. */ private ValueSource getValueSource(Value value, Statement currentStmt, ListIterator stmtIt, ControlFlowBlock currentBlock) { if(value instanceof VariableRef) { @@ -325,6 +325,10 @@ public class Pass1UnwindStructValues extends Pass1Base { return new ValueSourceStructVariable(variable); } } + if(value instanceof StructZero) + return new ValueSourceZero(((StructZero) value).getTypeStruct(), null); + if(value instanceof ConstantStructValue) + return new ValueSourceConstant(((ConstantStructValue) value).getType(getScope()), null, (ConstantStructValue) value); return null; } diff --git a/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceBase.java b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceBase.java new file mode 100644 index 000000000..c645c0838 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceBase.java @@ -0,0 +1,57 @@ +package dk.camelot64.kickc.passes.unwinding; + +import dk.camelot64.kickc.model.operators.OperatorSizeOf; +import dk.camelot64.kickc.model.symbols.ProgramScope; +import dk.camelot64.kickc.model.symbols.StructDefinition; +import dk.camelot64.kickc.model.symbols.Variable; +import dk.camelot64.kickc.model.types.SymbolTypeStruct; +import dk.camelot64.kickc.model.values.ConstantValue; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** Value Source for a variable */ +public abstract class ValueSourceBase implements ValueSource { + + @Override + public boolean isSimple() { + return getArraySpec() == null && !(getSymbolType() instanceof SymbolTypeStruct); + } + + /** It is a struct with C-classic memory layout + * + * @return true if the value is a struct with C-classic memory layout + */ + protected abstract boolean isStructClassic(); + + @Override + public boolean isBulkCopyable() { + return getArraySpec() != null || isStructClassic(); + } + + @Override + public boolean isUnwindable() { + return getSymbolType() instanceof SymbolTypeStruct; + } + + protected ConstantValue getByteSize(ProgramScope scope) { + return getArraySpec() != null ? getArraySpec().getArraySize() : OperatorSizeOf.getSizeOfConstantVar(scope, getSymbolType()); + } + + @Override + public List getMemberNames(ProgramScope scope) { + if(getSymbolType() instanceof SymbolTypeStruct) { + StructDefinition structDefinition = ((SymbolTypeStruct) getSymbolType()).getStructDefinition(scope); + Collection structMemberVars = structDefinition.getAllVars(false); + ArrayList memberNames = new ArrayList<>(); + for(Variable structMemberVar : structMemberVars) { + memberNames.add(structMemberVar.getLocalName()); + } + return memberNames; + } else { + return null; + } + } + +} \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceConstant.java b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceConstant.java new file mode 100644 index 000000000..3f31d20b2 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceConstant.java @@ -0,0 +1,75 @@ +package dk.camelot64.kickc.passes.unwinding; + +import dk.camelot64.kickc.model.ControlFlowBlock; +import dk.camelot64.kickc.model.operators.OperatorSizeOf; +import dk.camelot64.kickc.model.statements.Statement; +import dk.camelot64.kickc.model.symbols.*; +import dk.camelot64.kickc.model.types.SymbolType; +import dk.camelot64.kickc.model.types.SymbolTypePointer; +import dk.camelot64.kickc.model.types.SymbolTypeStruct; +import dk.camelot64.kickc.model.values.*; + +import java.util.ListIterator; + +/** Unwinding a constant value. */ +public class ValueSourceConstant extends ValueSourceBase { + private final SymbolType symbolType; + private final ArraySpec arraySpec; + private final ConstantValue value; + + public ValueSourceConstant(SymbolType symbolType, ArraySpec arraySpec, ConstantValue value) { + this.symbolType = symbolType; + this.arraySpec = arraySpec; + this.value = value; + } + + @Override + public SymbolType getSymbolType() { + return symbolType; + } + + @Override + public ArraySpec getArraySpec() { + return arraySpec; + } + + @Override + protected boolean isStructClassic() { + return getSymbolType() instanceof SymbolTypeStruct; + } + + @Override + public RValue getSimpleValue(ProgramScope programScope) { + return value; + } + + @Override + public ValueSource getMemberUnwinding(String memberName, ProgramScope programScope, Statement currentStmt, ControlFlowBlock currentBlock, ListIterator stmtIt) { + StructDefinition structDefinition = ((SymbolTypeStruct) getSymbolType()).getStructDefinition(programScope); + ConstantStructValue constantStructValue = (ConstantStructValue) value; + final Variable member = structDefinition.getMember(memberName); + final SymbolType type = member.getType(); + final ArraySpec arraySpec = member.getArraySpec(); + final ConstantValue memberValue = constantStructValue.getValue(member.getRef()); + return new ValueSourceConstant(type, arraySpec, memberValue); + } + + @Override + public LValue getBulkLValue(ProgramScope scope) { + throw new InternalError("Not a valid LValue!"); + } + + @Override + public RValue getBulkRValue(ProgramScope scope) { + String constName = scope.allocateIntermediateVariableName(); + Variable constVar = Variable.createConstant(constName, symbolType, scope, getArraySpec(), value, Scope.SEGMENT_DATA_DEFAULT); + scope.add(constVar); + if(getArraySpec()!=null) { + final SymbolType elementType = ((SymbolTypePointer) getSymbolType()).getElementType(); + return new MemcpyValue(new PointerDereferenceSimple(new ConstantSymbolPointer(constVar.getRef())), getByteSize(scope), elementType); + } else { + return new MemcpyValue(new PointerDereferenceSimple(new ConstantSymbolPointer(constVar.getRef())), getByteSize(scope), getSymbolType()); + } + } + +} diff --git a/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceStructVariable.java b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceStructVariable.java index a2885287b..d0f4d60bd 100644 --- a/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceStructVariable.java +++ b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceStructVariable.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.ListIterator; /** Value Source for a variable */ -public class ValueSourceStructVariable implements ValueSource { +public class ValueSourceStructVariable extends ValueSourceBase { /** The variable. */ private final Variable variable; @@ -40,8 +40,8 @@ public class ValueSourceStructVariable implements ValueSource { } @Override - public boolean isSimple() { - return getArraySpec() == null && !(getSymbolType() instanceof SymbolTypeStruct); + protected boolean isStructClassic() { + return variable.isStructClassic(); } @Override @@ -49,21 +49,12 @@ public class ValueSourceStructVariable implements ValueSource { return new ConstantSymbolPointer(variable.getRef()); } - @Override - public boolean isBulkCopyable() { - return getArraySpec() != null || variable.isStructClassic(); - } - @Override public LValue getBulkLValue(ProgramScope scope) { ConstantSymbolPointer pointer = new ConstantSymbolPointer(variable.getRef()); return new PointerDereferenceSimple(pointer); } - private ConstantValue getByteSize(ProgramScope scope) { - return getArraySpec() != null ? getArraySpec().getArraySize() : OperatorSizeOf.getSizeOfConstantVar(scope, getSymbolType()); - } - @Override public RValue getBulkRValue(ProgramScope scope) { ConstantSymbolPointer pointer = new ConstantSymbolPointer(variable.getRef()); @@ -71,26 +62,6 @@ public class ValueSourceStructVariable implements ValueSource { return new MemcpyValue(pointerDeref, getByteSize(scope), getSymbolType()); } - @Override - public boolean isUnwindable() { - return getSymbolType() instanceof SymbolTypeStruct; - } - - @Override - public List getMemberNames(ProgramScope scope) { - if(getSymbolType() instanceof SymbolTypeStruct) { - StructDefinition structDefinition = ((SymbolTypeStruct) getSymbolType()).getStructDefinition(scope); - Collection structMemberVars = structDefinition.getAllVars(false); - ArrayList memberNames = new ArrayList<>(); - for(Variable structMemberVar : structMemberVars) { - memberNames.add(structMemberVar.getLocalName()); - } - return memberNames; - } else { - return null; - } - } - @Override public ValueSource getMemberUnwinding(String memberName, ProgramScope programScope, Statement currentStmt, ControlFlowBlock currentBlock, ListIterator stmtIt) { if(getSymbolType() instanceof SymbolTypeStruct) { diff --git a/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceZero.java b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceZero.java new file mode 100644 index 000000000..d22b8637a --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/unwinding/ValueSourceZero.java @@ -0,0 +1,73 @@ +package dk.camelot64.kickc.passes.unwinding; + +import dk.camelot64.kickc.model.ControlFlowBlock; +import dk.camelot64.kickc.model.Initializers; +import dk.camelot64.kickc.model.InternalError; +import dk.camelot64.kickc.model.operators.OperatorSizeOf; +import dk.camelot64.kickc.model.statements.Statement; +import dk.camelot64.kickc.model.symbols.ArraySpec; +import dk.camelot64.kickc.model.symbols.ProgramScope; +import dk.camelot64.kickc.model.symbols.StructDefinition; +import dk.camelot64.kickc.model.symbols.Variable; +import dk.camelot64.kickc.model.types.SymbolType; +import dk.camelot64.kickc.model.types.SymbolTypeStruct; +import dk.camelot64.kickc.model.values.ConstantValue; +import dk.camelot64.kickc.model.values.LValue; +import dk.camelot64.kickc.model.values.MemsetValue; +import dk.camelot64.kickc.model.values.RValue; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; + +/** Value Source for a zero value. */ +public class ValueSourceZero extends ValueSourceBase { + + private final SymbolType symbolType; + private final ArraySpec arraySpec; + + public ValueSourceZero(SymbolType symbolType, ArraySpec arraySpec) { + this.symbolType = symbolType; + this.arraySpec = arraySpec; + } + + @Override + public SymbolType getSymbolType() { + return symbolType; + } + + @Override + public ArraySpec getArraySpec() { + return arraySpec; + } + + @Override + protected boolean isStructClassic() { + return getSymbolType() instanceof SymbolTypeStruct; + } + + @Override + public RValue getSimpleValue(ProgramScope programScope) { + return Initializers.createZeroValue(new Initializers.ValueTypeSpec(getSymbolType(), getArraySpec()), null); + } + + @Override + public ValueSource getMemberUnwinding(String memberName, ProgramScope programScope, Statement currentStmt, ControlFlowBlock currentBlock, ListIterator stmtIt) { + StructDefinition structDefinition = ((SymbolTypeStruct) getSymbolType()).getStructDefinition(programScope); + final SymbolType memberType = structDefinition.getMember(memberName).getType(); + final ArraySpec memberArraySpec = structDefinition.getMember(memberName).getArraySpec(); + return new ValueSourceZero(memberType, memberArraySpec); + } + + @Override + public LValue getBulkLValue(ProgramScope scope) { + throw new InternalError("Not a legal LValue!"); + } + + @Override + public RValue getBulkRValue(ProgramScope scope) { + return new MemsetValue(getByteSize(scope), getSymbolType()); + } + +} diff --git a/src/test/ref/struct-15.log b/src/test/ref/struct-15.log index 6912dde39..3facbd7d9 100644 --- a/src/test/ref/struct-15.log +++ b/src/test/ref/struct-15.log @@ -1,4 +1,4 @@ -Adding struct value member variable copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) Adding value bulk copy *(&(struct Point) main::point2) ← memcpy(*(&(struct Point) main::point1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.y with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) @@ -12,6 +12,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (number) 2 *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) ← (number) 3 *(&(struct Point) main::point2) ← memcpy(*(&(struct Point) main::point1), struct Point, (const byte) SIZEOF_STRUCT_POINT) @@ -64,10 +65,11 @@ Finalized unsigned number type (byte) 3 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Removing C-classic struct-unwound assignment [4] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} -Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 -Simplifying expression containing zero (byte*)&main::point2 in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Removing C-classic struct-unwound assignment [5] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 +Simplifying expression containing zero (byte*)&main::point2 in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-16.log b/src/test/ref/struct-16.log index 6638645cf..4cfb825ec 100644 --- a/src/test/ref/struct-16.log +++ b/src/test/ref/struct-16.log @@ -1,4 +1,4 @@ -Adding struct value member variable copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.y with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) @@ -9,6 +9,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((const byte*) SCREEN + (number) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) *((const byte*) SCREEN + (number) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) to:main::@return @@ -48,8 +49,9 @@ Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Simplifying expression containing zero (byte*)&main::point1 in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-17.log b/src/test/ref/struct-17.log index de3b3d53d..55447587e 100644 --- a/src/test/ref/struct-17.log +++ b/src/test/ref/struct-17.log @@ -1,4 +1,4 @@ -Adding struct value member variable copy *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) +Adding value bulk copy *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) Replacing struct member reference (struct Vector) main::v.q with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q) @@ -23,6 +23,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) + (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X *((byte*~) main::$0) ← (number) 2 (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y @@ -110,14 +111,15 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 Successful SSA optimization PassNFinalizeNumberTypeConversions -Constant right-side identified [1] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [3] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [5] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [7] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [9] (byte*~) main::$4 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [11] (byte*~) main::$5 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [13] (byte*~) main::$6 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [15] (byte*~) main::$7 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} +Constant right-side identified [2] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [4] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [6] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [8] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [10] (byte*~) main::$4 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [12] (byte*~) main::$5 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [14] (byte*~) main::$6 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [16] (byte*~) main::$7 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y @@ -136,7 +138,7 @@ Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STR Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in -Simplifying expression containing zero SCREEN in [10] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$4) +Simplifying expression containing zero SCREEN in [11] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$4) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_VECTOR_P Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X diff --git a/src/test/ref/struct-18.log b/src/test/ref/struct-18.log index 09505b713..e973091f1 100644 --- a/src/test/ref/struct-18.log +++ b/src/test/ref/struct-18.log @@ -1,4 +1,4 @@ -Adding struct value member variable copy *(&(struct Vector) main::v) ← memcpy(*(&(const struct Vector) $0), struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) +Adding value bulk copy *(&(struct Vector) main::v) ← memcpy(*(&(const struct Vector) $0), struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) Replacing struct member reference (struct Vector) main::v.q with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q) @@ -15,6 +15,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Vector) main::v) ← memcpy(*(&(const struct Vector) $0), struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) + (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X *((const byte*) SCREEN + (number) 0) ← *((byte*~) main::$0) (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y @@ -74,10 +75,11 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 Successful SSA optimization PassNFinalizeNumberTypeConversions -Constant right-side identified [1] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [3] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [5] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [7] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} +Constant right-side identified [2] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [4] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [6] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [8] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y @@ -88,7 +90,7 @@ Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STR Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in -Simplifying expression containing zero SCREEN in [2] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) +Simplifying expression containing zero SCREEN in [3] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_VECTOR_P Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X diff --git a/src/test/ref/struct-19.log b/src/test/ref/struct-19.log index 0e0cbda60..ce5e531aa 100644 --- a/src/test/ref/struct-19.log +++ b/src/test/ref/struct-19.log @@ -1,6 +1,6 @@ -Adding struct value member variable copy *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) -Adding struct value member variable copy *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) -Adding struct value member variable copy *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) +Adding value bulk copy *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Postponing unwinding for (struct Vector) main::v.p ← (struct Point) main::p1 Postponing unwinding for (struct Vector) main::v.q ← (struct Point) main::p2 Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) @@ -23,8 +23,11 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Vector) main::v) ← memset(struct Vector, (const byte) SIZEOF_STRUCT_VECTOR) + (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p1 ← struct-unwound {*(&(struct Point) main::p1)} *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p2 ← struct-unwound {*(&(struct Point) main::p2)} *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q) ← memcpy(*(&(struct Point) main::p2), struct Point, (const byte) SIZEOF_STRUCT_POINT) (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X @@ -90,10 +93,13 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 Successful SSA optimization PassNFinalizeNumberTypeConversions -Constant right-side identified [5] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [7] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [9] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [11] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Vector) main::v ← struct-unwound {*(&(struct Vector) main::v)} +Removing C-classic struct-unwound assignment [3] (struct Point) main::p1 ← struct-unwound {*(&(struct Point) main::p1)} +Removing C-classic struct-unwound assignment [5] (struct Point) main::p2 ← struct-unwound {*(&(struct Point) main::p2)} +Constant right-side identified [8] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [10] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [12] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [14] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y @@ -104,8 +110,8 @@ Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STR Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in -Simplifying expression containing zero (struct Point*)&main::v in [3] *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) -Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) +Simplifying expression containing zero (struct Point*)&main::v in [6] *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Simplifying expression containing zero SCREEN in [9] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_VECTOR_P Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X diff --git a/src/test/ref/struct-20.log b/src/test/ref/struct-20.log index 3488e8677..4b179c265 100644 --- a/src/test/ref/struct-20.log +++ b/src/test/ref/struct-20.log @@ -1,5 +1,5 @@ -Adding struct value member variable copy *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) -Adding struct value member variable copy *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Adding struct value member variable copy *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← (struct Point) main::p1 Adding struct value member variable copy *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q) ← (struct Point) main::p2 Replacing struct member reference (struct Vector) main::v.p with member unwinding reference *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) @@ -20,7 +20,9 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::p1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p1 ← struct-unwound {*(&(struct Point) main::p1)} *(&(struct Point) main::p2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p2 ← struct-unwound {*(&(struct Point) main::p2)} *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q) ← memcpy(*(&(struct Point) main::p2), struct Point, (const byte) SIZEOF_STRUCT_POINT) (struct Vector) main::v ← struct-unwound {*((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P), *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q)} @@ -86,11 +88,13 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 Successful SSA optimization PassNFinalizeNumberTypeConversions -Removing C-classic struct-unwound assignment [4] (struct Vector) main::v ← struct-unwound {*((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P), *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q)} -Constant right-side identified [5] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [7] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y -Constant right-side identified [9] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [11] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Point) main::p1 ← struct-unwound {*(&(struct Point) main::p1)} +Removing C-classic struct-unwound assignment [3] (struct Point) main::p2 ← struct-unwound {*(&(struct Point) main::p2)} +Removing C-classic struct-unwound assignment [6] (struct Vector) main::v ← struct-unwound {*((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P), *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q)} +Constant right-side identified [7] (byte*~) main::$0 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [9] (byte*~) main::$1 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P + (const byte) OFFSET_STRUCT_POINT_Y +Constant right-side identified [11] (byte*~) main::$2 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [13] (byte*~) main::$3 ← (byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_Q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y @@ -101,8 +105,8 @@ Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STR Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (struct Point*)&main::v in Simplifying expression containing zero (byte*)(struct Point*)&main::v+OFFSET_STRUCT_VECTOR_Q in -Simplifying expression containing zero (struct Point*)&main::v in [2] *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) -Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) +Simplifying expression containing zero (struct Point*)&main::v in [4] *((struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P) ← memcpy(*(&(struct Point) main::p1), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Simplifying expression containing zero SCREEN in [8] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_VECTOR_P Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X diff --git a/src/test/ref/struct-21.log b/src/test/ref/struct-21.log index 88007a02e..5b0799345 100644 --- a/src/test/ref/struct-21.log +++ b/src/test/ref/struct-21.log @@ -1,5 +1,5 @@ Setting inferred volatile on symbol affected by address-of (struct Point*) main::ptr ← &(struct Point) main::point1 -Adding struct value member variable copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Rewriting struct pointer member access *((struct Point*) main::ptr).x Rewriting struct pointer member access *((struct Point*) main::ptr).y Identified constant variable (struct Point*) main::ptr @@ -11,6 +11,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} (byte*~) main::$0 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_X *((const byte*) SCREEN + (number) 0) ← *((byte*~) main::$0) (byte*~) main::$1 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_Y @@ -55,14 +56,15 @@ Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Constant right-side identified [1] (byte*~) main::$0 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [3] (byte*~) main::$1 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Constant right-side identified [2] (byte*~) main::$0 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [4] (byte*~) main::$1 ← (byte*)(const struct Point*) main::ptr + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)main::ptr+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)main::ptr+OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantIdentification Simplifying expression containing zero (byte*)main::ptr in -Simplifying expression containing zero SCREEN in [2] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) +Simplifying expression containing zero SCREEN in [3] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) main::$0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-22.log b/src/test/ref/struct-22.log index 1b7ee6198..408563163 100644 --- a/src/test/ref/struct-22.log +++ b/src/test/ref/struct-22.log @@ -2,8 +2,8 @@ Created struct value member variable (byte) print::p_x Created struct value member variable (byte) print::p_y Converted struct value to member variables (struct Point) print::p Converted procedure struct value parameter to member unwinding (void()) print((byte) print::p_x , (byte) print::p_y) -Adding struct value member variable copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) -Adding struct value member variable copy *(&(struct Point) main::point2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Converted procedure struct value parameter to member unwinding in call (void~) main::$0 ← call print *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) Converted procedure struct value parameter to member unwinding in call (void~) main::$1 ← call print *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_Y) Replacing struct member reference (struct Point) print::p.x with member unwinding reference (byte) print::p_x @@ -17,7 +17,9 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @2 *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *(&(struct Point) main::point2) ← memcpy(*(&(const struct Point) $1), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} (byte) print::p_x#0 ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) (byte) print::p_y#0 ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) call print @@ -91,9 +93,11 @@ Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Simplifying expression containing zero (byte*)&main::point1 in [2] (byte) print::p_x#0 ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero (byte*)&main::point2 in [5] (byte) print::p_x#1 ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [10] *((const byte*) SCREEN + (byte) 0) ← (byte) print::p_x#2 +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Removing C-classic struct-unwound assignment [3] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} +Simplifying expression containing zero (byte*)&main::point1 in [4] (byte) print::p_x#0 ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero (byte*)&main::point2 in [7] (byte) print::p_x#1 ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [12] *((const byte*) SCREEN + (byte) 0) ← (byte) print::p_x#2 Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-24.log b/src/test/ref/struct-24.log index a042ffa3f..38fdd1e23 100644 --- a/src/test/ref/struct-24.log +++ b/src/test/ref/struct-24.log @@ -1,7 +1,7 @@ Fixing struct type size struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 -Adding struct value member variable copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS @@ -16,6 +16,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (number) 2 *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 0) ← (byte) 'j' *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 1) ← (byte) 'g' @@ -78,11 +79,12 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Successful SSA optimization PassNFinalizeNumberTypeConversions -Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 -Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) ← (byte) 'j' -Simplifying expression containing zero (byte*)&main::point1 in [4] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [4] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) -Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [5] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 +Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) ← (byte) 'j' +Simplifying expression containing zero (byte*)&main::point1 in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) +Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [6] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-26.log b/src/test/ref/struct-26.log index d23c13f04..1f13639aa 100644 --- a/src/test/ref/struct-26.log +++ b/src/test/ref/struct-26.log @@ -2,7 +2,7 @@ Fixing struct type size struct Point to 3 Fixing struct type size struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 -Adding struct value member variable copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) Adding value bulk copy *(&(struct Point) main::point2) ← memcpy(*(&(struct Point) main::point1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS @@ -18,6 +18,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (number) 2 *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 0) ← (byte) 'j' *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 1) ← (byte) 'g' @@ -83,12 +84,13 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Successful SSA optimization PassNFinalizeNumberTypeConversions -Removing C-classic struct-unwound assignment [5] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} -Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 -Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) ← (byte) 'j' -Simplifying expression containing zero (byte*)&main::point2 in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) -Simplifying expression containing zero (byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS in [7] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Removing C-classic struct-unwound assignment [6] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 +Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) ← (byte) 'j' +Simplifying expression containing zero (byte*)&main::point2 in [7] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [7] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) +Simplifying expression containing zero (byte*)&main::point2+OFFSET_STRUCT_POINT_INITIALS in [8] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-27.log b/src/test/ref/struct-27.log index 8dee2674a..e7449499c 100644 --- a/src/test/ref/struct-27.log +++ b/src/test/ref/struct-27.log @@ -1,7 +1,7 @@ Fixing struct type size struct Point to 4 Fixing struct type SIZE_OF struct Point to 4 Fixing struct type SIZE_OF struct Point to 4 -Adding struct value member variable copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS @@ -13,6 +13,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((const byte*) SCREEN + (number) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) *((const byte*) SCREEN + (number) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 0) *((const byte*) SCREEN + (number) 2) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 1) @@ -62,9 +63,10 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Successful SSA optimization PassNFinalizeNumberTypeConversions -Simplifying expression containing zero (byte*)&main::point1 in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) -Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) +Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-28.log b/src/test/ref/struct-28.log index 5af57a99d..390223242 100644 --- a/src/test/ref/struct-28.log +++ b/src/test/ref/struct-28.log @@ -1,7 +1,7 @@ Fixing struct type size struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 Fixing struct type SIZE_OF struct Point to 3 -Adding struct value member variable copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS Replacing struct member reference (struct Point) main::point1.initials with member unwinding reference (byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS @@ -13,6 +13,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((const byte*) SCREEN + (number) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) *((const byte*) SCREEN + (number) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 0) *((const byte*) SCREEN + (number) 2) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (number) 1) @@ -62,9 +63,10 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 2 Successful SSA optimization PassNFinalizeNumberTypeConversions -Simplifying expression containing zero (byte*)&main::point1 in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [1] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) -Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [2] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [2] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point1) +Simplifying expression containing zero (byte*)&main::point1+OFFSET_STRUCT_POINT_INITIALS in [3] *((const byte*) SCREEN + (byte) 1) ← *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_INITIALS + (byte) 0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-32.log b/src/test/ref/struct-32.log index 7bbd8b37e..26d02b1cc 100644 --- a/src/test/ref/struct-32.log +++ b/src/test/ref/struct-32.log @@ -1,4 +1,4 @@ -Adding struct value member variable copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) Adding value bulk copy *(&(struct Point) main::point2) ← memcpy(*(&(struct Point) main::point1), struct Point, (const byte) SIZEOF_STRUCT_POINT) Replacing struct member reference (struct Point) main::point1.x with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) Replacing struct member reference (struct Point) main::point1.y with member unwinding reference *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) @@ -12,6 +12,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::point1) ← memset(struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (number) 2 *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_Y) ← (number) 3 *(&(struct Point) main::point2) ← memcpy(*(&(struct Point) main::point1), struct Point, (const byte) SIZEOF_STRUCT_POINT) @@ -64,10 +65,11 @@ Finalized unsigned number type (byte) 3 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Removing C-classic struct-unwound assignment [4] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} -Simplifying expression containing zero (byte*)&main::point1 in [1] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 -Simplifying expression containing zero (byte*)&main::point2 in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) -Simplifying expression containing zero SCREEN in [5] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) +Removing C-classic struct-unwound assignment [1] (struct Point) main::point1 ← struct-unwound {*(&(struct Point) main::point1)} +Removing C-classic struct-unwound assignment [5] (struct Point) main::point2 ← struct-unwound {*(&(struct Point) main::point2)} +Simplifying expression containing zero (byte*)&main::point1 in [2] *((byte*)&(struct Point) main::point1+(const byte) OFFSET_STRUCT_POINT_X) ← (byte) 2 +Simplifying expression containing zero (byte*)&main::point2 in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2+(const byte) OFFSET_STRUCT_POINT_X) +Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← *((byte*)&(struct Point) main::point2) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-ptr-12.log b/src/test/ref/struct-ptr-12.log index 93444ffdb..82a81ca97 100644 --- a/src/test/ref/struct-ptr-12.log +++ b/src/test/ref/struct-ptr-12.log @@ -1,5 +1,5 @@ Setting inferred volatile on symbol affected by address-of (struct Point*) main::q ← &(struct Point) main::p -Adding struct value member variable copy *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Rewriting struct pointer member access *((struct Point*) main::q).x Rewriting struct pointer member access *((struct Point*) main::q).y Identified constant variable (struct Point*) main::q @@ -11,6 +11,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @1 *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p ← struct-unwound {*(&(struct Point) main::p)} (byte*~) main::$0 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_X *((const byte*) main::SCREEN + (number) 0) ← *((byte*~) main::$0) (byte*~) main::$1 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_Y @@ -55,14 +56,15 @@ Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Constant right-side identified [1] (byte*~) main::$0 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [3] (byte*~) main::$1 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Point) main::p ← struct-unwound {*(&(struct Point) main::p)} +Constant right-side identified [2] (byte*~) main::$0 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [4] (byte*~) main::$1 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::$0 = (byte*)main::q+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$1 = (byte*)main::q+OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantIdentification Simplifying expression containing zero (byte*)main::q in -Simplifying expression containing zero main::SCREEN in [2] *((const byte*) main::SCREEN + (byte) 0) ← *((const byte*) main::$0) +Simplifying expression containing zero main::SCREEN in [3] *((const byte*) main::SCREEN + (byte) 0) ← *((const byte*) main::$0) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X Successful SSA optimization PassNEliminateUnusedVars diff --git a/src/test/ref/struct-ptr-14.log b/src/test/ref/struct-ptr-14.log index e095d03d4..df3a50483 100644 --- a/src/test/ref/struct-ptr-14.log +++ b/src/test/ref/struct-ptr-14.log @@ -1,5 +1,5 @@ Setting inferred volatile on symbol affected by address-of (struct Point*) main::q ← &(struct Point) main::p -Adding struct value member variable copy *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) +Adding value bulk copy *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) Rewriting struct pointer member access *((struct Point*) main::q).x Rewriting struct pointer member access *((struct Point*) main::q).y Rewriting struct pointer member access *((struct Point*) set::ptr).x @@ -14,6 +14,7 @@ CONTROL FLOW GRAPH SSA (void()) main() main: scope:[main] from @2 *(&(struct Point) main::p) ← memcpy(*(&(const struct Point) $0), struct Point, (const byte) SIZEOF_STRUCT_POINT) + (struct Point) main::p ← struct-unwound {*(&(struct Point) main::p)} (struct Point*) set::ptr#0 ← (const struct Point*) main::q call set to:main::@1 @@ -93,23 +94,24 @@ Finalized unsigned number type (byte) 5 Successful SSA optimization PassNFinalizeNumberTypeConversions Identical Phi Values (struct Point*) set::ptr#1 (struct Point*) set::ptr#0 Successful SSA optimization Pass2IdenticalPhiElimination -Constant right-side identified [3] (byte*~) main::$1 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_X -Constant right-side identified [5] (byte*~) main::$2 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_Y +Removing C-classic struct-unwound assignment [1] (struct Point) main::p ← struct-unwound {*(&(struct Point) main::p)} +Constant right-side identified [4] (byte*~) main::$1 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_X +Constant right-side identified [6] (byte*~) main::$2 ← (byte*)(const struct Point*) main::q + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const struct Point*) set::ptr#0 = main::q Constant (const byte*) main::$1 = (byte*)main::q+OFFSET_STRUCT_POINT_X Constant (const byte*) main::$2 = (byte*)main::q+OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantIdentification -Constant value identified (byte*)set::ptr#0 in [9] (byte*~) set::$0 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X -Constant value identified (byte*)set::ptr#0 in [11] (byte*~) set::$1 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_Y +Constant value identified (byte*)set::ptr#0 in [10] (byte*~) set::$0 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X +Constant value identified (byte*)set::ptr#0 in [12] (byte*~) set::$1 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_Y Successful SSA optimization Pass2ConstantValues -Converting *(pointer+n) to pointer[n] [10] *((byte*~) set::$0) ← (byte) 4 -- *((byte*)set::ptr#0 + OFFSET_STRUCT_POINT_X) -Converting *(pointer+n) to pointer[n] [12] *((byte*~) set::$1) ← (byte) 5 -- *((byte*)set::ptr#0 + OFFSET_STRUCT_POINT_Y) +Converting *(pointer+n) to pointer[n] [11] *((byte*~) set::$0) ← (byte) 4 -- *((byte*)set::ptr#0 + OFFSET_STRUCT_POINT_X) +Converting *(pointer+n) to pointer[n] [13] *((byte*~) set::$1) ← (byte) 5 -- *((byte*)set::ptr#0 + OFFSET_STRUCT_POINT_Y) Successful SSA optimization Pass2InlineDerefIdx Simplifying expression containing zero (byte*)main::q in -Simplifying expression containing zero main::SCREEN in [4] *((const byte*) main::SCREEN + (byte) 0) ← *((const byte*) main::$1) -Simplifying expression containing zero (byte*)set::ptr#0 in [9] (byte*~) set::$0 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X -Simplifying expression containing zero (byte*)set::ptr#0 in [10] *((byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X) ← (byte) 4 +Simplifying expression containing zero main::SCREEN in [5] *((const byte*) main::SCREEN + (byte) 0) ← *((const byte*) main::$1) +Simplifying expression containing zero (byte*)set::ptr#0 in [10] (byte*~) set::$0 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X +Simplifying expression containing zero (byte*)set::ptr#0 in [11] *((byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X) ← (byte) 4 Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused variable (byte*~) set::$0 and assignment [5] (byte*~) set::$0 ← (byte*)(const struct Point*) set::ptr#0 Eliminating unused variable (byte*~) set::$1 and assignment [7] (byte*~) set::$1 ← (byte*)(const struct Point*) set::ptr#0 + (const byte) OFFSET_STRUCT_POINT_Y