Skip to content

Commit 7072002

Browse files
committed
disable optimization on AND in simplify_cast()
Consider the code below. unsigned int foo(unsigned long long x) { unsigned int tmp = x & 0x1fffffff; return tmp; } sparse emits: and.64 %r2 <- %arg1, $0x1fffffff ret.32 %r2 %r2 seems to be interpreted as both 64 and 32 bits. Disable the optimization in simplify_cast() to avoid the confusion. Signed-off-by: Xi Wang <xi.wang@gmail.com>
1 parent c0e4a0a commit 7072002

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

simplify.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -685,19 +685,6 @@ static int simplify_cast(struct instruction *insn)
685685
goto simplify;
686686
}
687687

688-
/* A cast of a "and" might be a no-op.. */
689-
if (src->type == PSEUDO_REG) {
690-
struct instruction *def = src->def;
691-
if (def->opcode == OP_AND && instruction_size(def) >= size) {
692-
pseudo_t val = def->src2;
693-
if (val->type == PSEUDO_VAL) {
694-
unsigned long long value = val->value;
695-
if (!(value >> (size-1)))
696-
goto simplify;
697-
}
698-
}
699-
}
700-
701688
if (size == orig_size) {
702689
int op = (orig_type->ctype.modifiers & MOD_SIGNED) ? OP_SCAST : OP_CAST;
703690
if (insn->opcode == op)

0 commit comments

Comments
 (0)