path64/compiler — Issue #129: Strange code path in src/be/com/wn_lower.cxx
Author: juikim
Created: 2011-11-16 19:39:05+00:00
State: open

static Lower_Mistore_Memlib((WN *block, WN *tree, LOWER_ACTIONS actions)
{
...
INT64 const_val;
...
BOOL is_const = FALSE;
...
if (WN_operator_is(WN_kid0(tree), OPR_INTCONST)) {
is_const = TRUE;
return tree; // Don't handle constant
}

if (WN_operator(WN_kid0(tree)) != OPR_ILOAD) return tree; // Expect ILOAD
...
if (store_base == NULL || (!is_const && load_base == NULL))
return tree;
...
for ( ; stmt && ! OPERATOR_is_endsbb(WN_operator(stmt)) &&
WN_operator(stmt) != OPR_LABEL ; stmt = WN_next(stmt) ) {
...
if (is_const) {
if (!WN_operator_is(WN_kid0(stmt), OPR_INTCONST)
|| const_val != WN_const_val(WN_kid0(stmt))) {
// continue; // process the next statement
return tree; // save compiling time
}
} else {
if (WN_operator(WN_kid0(stmt)) != OPR_ILOAD) return tree; // Expect ILOAD
}
...
}

First of all, is_const is a dead variable because this function returns immediately as soon as it becomes TRUE. Second, const_val is never initialized to any value. Therefore, the last if statement makes absolutely no sense. From the similarities of the if statements, I can only guess the author tried to mimic the same logic here, though.