Skip to content

Commit 89196bd

Browse files
committed
Little fixes
1 parent 6220824 commit 89196bd

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

common/new_hash_map.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,10 @@ void* nl_hashset_put2(NL_HashSet* restrict hs, void* ptr, NL_HashFunc hash, NL_C
229229
size_t first = h & mask, i = first;
230230

231231
do {
232-
if (hs->data[i] == NULL) {
232+
if (hs->data[i] == NULL || hs->data[i] == NL_HASHSET_TOMB) {
233233
hs->count++;
234234
hs->data[i] = ptr;
235235
return NULL;
236-
} else if (hs->data[i] == NL_HASHSET_TOMB) {
237-
// go past it
238236
} else if (hs->data[i] == ptr || cmp(hs->data[i], ptr)) {
239237
return hs->data[i];
240238
}

cuik_c/expr_fold.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ static ptrdiff_t const_eval_subexpr(Cuik_Parser* restrict parser, TokenStream* t
202202
// try binary operators
203203
if (s->op >= EXPR_PLUS && s->op <= EXPR_CMPLT) {
204204
Cuik_ConstVal rhs, lhs;
205+
Cuik_Type* ty = types ? cuik_canonical_type(types[i]) : NULL;
205206

206207
i = const_eval_subexpr(parser, tokens, types, exprs, i - 1, &rhs);
207208
if (i == CONST_ERROR) return i;
208209
i = const_eval_subexpr(parser, tokens, types, exprs, i, &lhs);
209210
if (i == CONST_ERROR) return i;
210211

211-
Cuik_Type* ty = types ? cuik_canonical_type(types[i]) : NULL;
212212
if (ty && cuik_type_is_float(ty)) {
213213
if (lhs.tag == CUIK_CONST_INT) { lhs.tag = CUIK_CONST_FLOAT; lhs.f = lhs.i; }
214214
if (rhs.tag == CUIK_CONST_INT) { rhs.tag = CUIK_CONST_FLOAT; rhs.f = rhs.i; }

meta/dsl.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ local function lexer(str)
3030
local i = 1
3131
return function()
3232
-- skip whitespace
33-
::loop::
34-
if ch_class[str:byte(i)] == "ws" then
35-
i = i + 1
36-
goto loop
37-
elseif str:byte(i) == 35 then -- hash are comments
38-
while str:byte(i) ~= 10 do
33+
while ch_class[str:byte(i)] == "ws" or str:byte(i) == 35 do
34+
if ch_class[str:byte(i)] == "ws" then
3935
i = i + 1
36+
elseif str:byte(i) == 35 then -- hash are comments
37+
while str:byte(i) ~= 10 do
38+
i = i + 1
39+
end
4040
end
41-
goto loop
4241
end
4342

4443
if i > #str then

tb/codegen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ size_t tb__insert_before(Ctx* ctx, TB_Function* f, TB_Node* n, TB_Node* before_n
249249
size_t tb__insert_after(Ctx* ctx, TB_Function* f, TB_Node* n, TB_Node* before_n);
250250
VReg* tb__set_node_vreg(Ctx* ctx, TB_Node* n);
251251
int tb__reg_width_from_dt(int reg_class, TB_DataType dt);
252-
void rematerialize(Ctx* ctx, int* fixed_vregs, TB_Node* n, bool kill_node);
253252

254253
static bool tb__reg_mask_less(Ctx* ctx, RegMask* a, RegMask* b) {
255254
return a == b ? false : tb__reg_mask_meet(ctx, a, b) != a;

tb/opt/optimizer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,8 @@ bool tb_opt(TB_Function* f, TB_Worklist* ws, bool preserve_types) {
13931393
tb_compact_nodes(f, ws);
13941394
size_t new = tb_arena_current_size(&f->arena);
13951395
TB_OPTDEBUG(PASSES)(printf(" * Node GC: %.f KiB => %.f KiB\n", old / 1024.0, new / 1024.0));
1396+
1397+
tb_print_dumb(f);
13961398
}
13971399

13981400
// currently only rotating loops

tb/opt/peep_int.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static Lattice* value_arith_raw(TB_Function* f, TB_NodeTypeEnum type, TB_DataTyp
135135
uint64_t u = amin & bmin & ~min;
136136
uint64_t v = ~(amax | bmax) & max;
137137
// just checking the sign bits
138-
if ((u | v) & imin) {
138+
if ((((u | v) >> (bits - 1)) & 1) != 0) {
139139
overflow = true;
140140
min = imin, max = imax;
141141
}
@@ -150,7 +150,7 @@ static Lattice* value_arith_raw(TB_Function* f, TB_NodeTypeEnum type, TB_DataTyp
150150
uint64_t u = ~(amin ^ bmax) | ~(amin ^ min);
151151
uint64_t v = ~(amax ^ bmin) | ~(amax ^ max);
152152

153-
if (((u & v) & imin) == 0) {
153+
if ((((u & v) >> (bits - 1)) & 1) == 0) {
154154
overflow = true;
155155
min = imin, max = imax;
156156
}
@@ -182,7 +182,7 @@ static Lattice* value_arith_raw(TB_Function* f, TB_NodeTypeEnum type, TB_DataTyp
182182

183183
if (n != NULL && !overflow) {
184184
// no signed overflow?
185-
TB_NODE_GET_EXTRA_T(n, TB_NodeBinopInt)->ab |= TB_ARITHMATIC_NSW;
185+
// TB_NODE_GET_EXTRA_T(n, TB_NodeBinopInt)->ab |= TB_ARITHMATIC_NSW;
186186
}
187187

188188
// sign extend our integers now

tb/tb_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
////////////////////////////////
2424
#define TB_OPTDEBUG_STATS 0
2525
#define TB_OPTDEBUG_PASSES 0
26-
#define TB_OPTDEBUG_PEEP 0
27-
#define TB_OPTDEBUG_SCCP 0
26+
#define TB_OPTDEBUG_PEEP 1
27+
#define TB_OPTDEBUG_SCCP 1
2828
#define TB_OPTDEBUG_LOOP 0
2929
#define TB_OPTDEBUG_SROA 0
3030
#define TB_OPTDEBUG_GCM 0

0 commit comments

Comments
 (0)