summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--8/insns.def2
-rw-r--r--8/isel.c6
-rw-r--r--test/condifrel.myr10
-rw-r--r--test/tests1
4 files changed, 15 insertions, 4 deletions
diff --git a/8/insns.def b/8/insns.def
index a75d56f..2639810 100644
--- a/8/insns.def
+++ b/8/insns.def
@@ -49,7 +49,7 @@ Insn(Isetz, "\tsetz %v\n", Use(), Def(.l={1}))
Insn(Isetnz, "\tsetnz %v\n", Use(), Def(.l={1}))
Insn(Isetl, "\tsetl %v\n", Use(), Def(.l={1}))
Insn(Isetle, "\tsetle %v\n", Use(), Def(.l={1}))
-Insn(Isetgt, "\tsetgt %v\n", Use(), Def(.l={1}))
+Insn(Isetg, "\tsetg %v\n", Use(), Def(.l={1}))
Insn(Isetge, "\tsetge %v\n", Use(), Def(.l={1}))
/* branch instructions */
diff --git a/8/isel.c b/8/isel.c
index d76cc4e..b2d2da9 100644
--- a/8/isel.c
+++ b/8/isel.c
@@ -42,7 +42,7 @@ struct {
[Olnot] = {Itest, Ijz, Isetz},
[Oeq] = {Icmp, Ijz, Isetz},
[One] = {Icmp, Ijnz, Isetnz},
- [Ogt] = {Icmp, Ijg, Isetgt},
+ [Ogt] = {Icmp, Ijg, Isetg},
[Oge] = {Icmp, Ijge, Isetge},
[Olt] = {Icmp, Ijl, Isetl},
[Ole] = {Icmp, Ijle, Isetle}
@@ -526,10 +526,10 @@ Loc *selexpr(Isel *s, Node *n)
case Oeq: case One: case Ogt: case Oge: case Olt: case Ole:
a = selexpr(s, args[0]);
b = selexpr(s, args[1]);
- b = inr(s, b);
+ a = inr(s, a);
c = locreg(ModeB);
r = locreg(mode(n));
- g(s, reloptab[exprop(n)].test, a, b, NULL);
+ g(s, reloptab[exprop(n)].test, b, a, NULL);
g(s, reloptab[exprop(n)].getflag, c, NULL);
movz(s, c, r);
return r;
diff --git a/test/condifrel.myr b/test/condifrel.myr
new file mode 100644
index 0000000..f76f5f3
--- /dev/null
+++ b/test/condifrel.myr
@@ -0,0 +1,10 @@
+
+var x = 3
+var y = 9
+const main = {
+ if x < 5 && y > 7
+ -> 7
+ else
+ -> 9
+ ;;
+}
diff --git a/test/tests b/test/tests
index e54313f..236c1b0 100644
--- a/test/tests
+++ b/test/tests
@@ -38,6 +38,7 @@ B closure E 55
B loop E 45
B condiftrue E 7
B condiffalse E 9
+B condifrel E 7
B fib E 21
B float E 1
B log-and E 0