summaryrefslogtreecommitdiff
path: root/compiler_and_linker/unsorted/LoopOptimization.c
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
commitaec1b8dddc68ecb8288ec6132932e4c7b4bca09f (patch)
tree8138328fe43bcc5fff690dc60caac79aa570ab2b /compiler_and_linker/unsorted/LoopOptimization.c
parentfcfbafff31869ed808bff0639532db1828660e92 (diff)
downloadMWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.tar.gz
MWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.zip
getting close to done
Diffstat (limited to 'compiler_and_linker/unsorted/LoopOptimization.c')
-rw-r--r--compiler_and_linker/unsorted/LoopOptimization.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler_and_linker/unsorted/LoopOptimization.c b/compiler_and_linker/unsorted/LoopOptimization.c
index 1c0b905..c2a360f 100644
--- a/compiler_and_linker/unsorted/LoopOptimization.c
+++ b/compiler_and_linker/unsorted/LoopOptimization.c
@@ -843,19 +843,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
if (loop->unknownCondition == ELESS) {
branchOpcode = PC_BF;
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = loop->lower;
reg1 = addiInstr->args[2].data.reg.reg;
value2 = absStep - 1 - loop->lower;
mode = 0;
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
- branchCondition = 0;
+ branchCondition = 0; // LT
value1 = loop->upper;
reg1 = addiInstr->args[1].data.reg.reg;
value2 = absStep - 1 + loop->upper;
mode = 1;
} else {
- branchCondition = 0;
+ branchCondition = 0; // LT
reg1 = addiInstr->args[1].data.reg.reg;
reg2 = addiInstr->args[2].data.reg.reg;
value2 = absStep - 1;
@@ -864,19 +864,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
} else if (loop->unknownCondition == ELESSEQU) {
branchOpcode = PC_BT;
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
- branchCondition = 0;
+ branchCondition = 0; // LT
value1 = loop->lower;
reg1 = addiInstr->args[2].data.reg.reg;
value2 = absStep - loop->lower;
mode = 0;
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = loop->upper;
reg1 = addiInstr->args[1].data.reg.reg;
value2 = absStep + loop->upper;
mode = 1;
} else {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = 0;
reg1 = addiInstr->args[1].data.reg.reg;
reg2 = addiInstr->args[2].data.reg.reg;
@@ -886,19 +886,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
} else if (loop->unknownCondition == EGREATER) {
branchOpcode = PC_BF;
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
- branchCondition = 0;
+ branchCondition = 0; // LT
value1 = loop->lower;
reg1 = addiInstr->args[2].data.reg.reg;
value2 = absStep - 1 + loop->lower;
mode = 1;
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = loop->upper;
reg1 = addiInstr->args[1].data.reg.reg;
value2 = absStep - 1 - loop->upper;
mode = 0;
} else {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = 0;
reg1 = addiInstr->args[1].data.reg.reg;
reg2 = addiInstr->args[2].data.reg.reg;
@@ -908,19 +908,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
} else if (loop->unknownCondition == EGREATEREQU) {
branchOpcode = PC_BT;
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
- branchCondition = 1;
+ branchCondition = 1; // GT
value1 = loop->lower;
reg1 = addiInstr->args[2].data.reg.reg;
value2 = absStep + loop->lower;
mode = 1;
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
- branchCondition = 0;
+ branchCondition = 0; // LT
value1 = loop->upper;
reg1 = addiInstr->args[1].data.reg.reg;
value2 = absStep - loop->upper;
mode = 0;
} else {
- branchCondition = 0;
+ branchCondition = 0; // LT
reg1 = addiInstr->args[1].data.reg.reg;
reg2 = addiInstr->args[2].data.reg.reg;
value2 = absStep;
@@ -928,7 +928,7 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
}
} else if (loop->unknownCondition == ENOTEQU) {
branchOpcode = PC_BT;
- branchCondition = 2;
+ branchCondition = 2; // EQ
if (loop->step > 0) {
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
value1 = loop->lower;