Program test1:
sub $0, $0, $0 # $0=0
lw $1, 0($0) # $1=4, mem(0) = 4
lw $2, 2($0) # $2=12, mem(2) = 12
sub $2, $2, $1 # $2=8
add $4, $2, $2 # $4=16
sw $4, 4($0) # mem(4) = 16
beq $4, $0, -7 # not taken
loop:
add $4, $4, $4 # $4=32
add $4, $4, $4 # $4=64
beq $0, $0, -3 # taken, branch to loop
sub $4, $4, $4 # foo inst
sub $4, $4, $4 # foo inst
You can make slight changes to adapt this program to your instruction set.
For example, you can remove the first sub if $0 is always zero in your design,
or use branch like "beqz $4, -7" if that is what supported. You cannot reorder
instructions to remove data dependence.