aboutsummaryrefslogtreecommitdiff
path: root/qbe.c
diff options
context:
space:
mode:
Diffstat (limited to 'qbe.c')
-rw-r--r--qbe.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/qbe.c b/qbe.c
index 719d0a0..fad1858 100644
--- a/qbe.c
+++ b/qbe.c
@@ -852,19 +852,19 @@ casesearch(struct function *f, struct value *v, struct switchcase *c, struct val
funcjmp(f, defaultlabel);
return;
}
- label[0] = mkblock("switch_lt");
- label[1] = mkblock("switch_ge");
+ label[0] = mkblock("switch_ne");
+ label[1] = mkblock("switch_lt");
label[2] = mkblock("switch_gt");
// XXX: linear search if c->node.height < 4
key = mkintconst(&i64, c->node.key);
- res = funcinst(f, ICULTW, &i32, (struct value *[]){v, key});
- funcjnz(f, res, label[0], label[1]);
+ res = funcinst(f, ICEQW, &i32, (struct value *[]){v, key});
+ funcjnz(f, res, c->body, label[0]);
funclabel(f, label[0]);
- casesearch(f, v, c->node.child[0], defaultlabel);
+ res = funcinst(f, ICULTW, typeint.repr, (struct value *[]){v, key});
+ funcjnz(f, res, label[1], label[2]);
funclabel(f, label[1]);
- res = funcinst(f, ICUGTW, typeint.repr, (struct value *[]){v, key});
- funcjnz(f, res, label[2], c->body);
+ casesearch(f, v, c->node.child[0], defaultlabel);
funclabel(f, label[2]);
casesearch(f, v, c->node.child[1], defaultlabel);
}