aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorgrischka <grischka>2008-12-28 22:43:41 +0100
committergrischka <grischka>2009-04-18 15:07:08 +0200
commit64147b346b169d9a93c3ed5ba01b2b5f8b8db3b8 (patch)
tree9dd2ca7fd6ae85d13ab3da3b1d1e5df778d7a84d /tcc.c
parent7c3f19c079afcea8c07e571dd07f7ef03de86b8e (diff)
downloadtinycc-64147b346b169d9a93c3ed5ba01b2b5f8b8db3b8.tar.gz
tinycc-64147b346b169d9a93c3ed5ba01b2b5f8b8db3b8.tar.bz2
fix constant optimization for unsigneds
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tcc.c b/tcc.c
index 772b171..e7c6ca9 100644
--- a/tcc.c
+++ b/tcc.c
@@ -5556,8 +5556,20 @@ void gen_opic(int op)
v2 = vtop;
t1 = v1->type.t & VT_BTYPE;
t2 = v2->type.t & VT_BTYPE;
- l1 = (t1 == VT_LLONG) ? v1->c.ll : v1->c.i;
- l2 = (t2 == VT_LLONG) ? v2->c.ll : v2->c.i;
+
+ if (t1 == VT_LLONG)
+ l1 = v1->c.ll;
+ else if (v1->type.t & VT_UNSIGNED)
+ l1 = v1->c.ui;
+ else
+ l1 = v1->c.i;
+
+ if (t2 == VT_LLONG)
+ l2 = v2->c.ll;
+ else if (v2->type.t & VT_UNSIGNED)
+ l2 = v2->c.ui;
+ else
+ l2 = v2->c.i;
/* currently, we cannot do computations with forward symbols */
c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;