From 64147b346b169d9a93c3ed5ba01b2b5f8b8db3b8 Mon Sep 17 00:00:00 2001 From: grischka Date: Sun, 28 Dec 2008 22:43:41 +0100 Subject: [PATCH] fix constant optimization for unsigneds --- tcc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tcc.c b/tcc.c index 772b1710..e7c6ca98 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; -- 2.11.4.GIT