diff options
author | 2004-11-26 21:23:05 -0700 | |
---|---|---|
committer | 2005-04-07 21:05:01 -0700 | |
commit | 7df3f1466ece2af375defe93483e8f2ef310d835 (patch) | |
tree | 9e30886612e258b09a86c176cb08b897bc8c1420 /simplify.c | |
parent | Add a semblance of sanity to structure member accesses. (diff) | |
download | sparse-7df3f1466ece2af375defe93483e8f2ef310d835.tar.gz sparse-7df3f1466ece2af375defe93483e8f2ef310d835.tar.bz2 sparse-7df3f1466ece2af375defe93483e8f2ef310d835.zip |
Add some more trivial constant simplifications.
Diffstat (limited to 'simplify.c')
-rw-r--r-- | simplify.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -250,6 +250,20 @@ static int simplify_constant_rightside(struct instruction *insn) static int simplify_constant_leftside(struct instruction *insn) { + long long value = insn->src1->value; + + switch (insn->opcode) { + case OP_ADD: case OP_OR: case OP_XOR: + if (!value) + return replace_with_pseudo(insn, insn->src2); + return 0; + + case OP_SHL: case OP_SHR: + case OP_AND: case OP_MUL: + if (!value) + return replace_with_pseudo(insn, insn->src1); + return 0; + } return 0; } |