Author: Thomas Preud'homme <robotux@celest.fr> Date: Tue Dec 31 23:51:20 2013 +0800 Move logic for if (int value) to tccgen.c Move the logic to do a test of an integer value (ex if (0)) out of arch-specific code to tccgen.c to avoid code duplication. This also fixes test of long long value which was only testing the bottom half of such values on 32 bits architectures. I don't understand why if () in gtst(i) was removed. This patch allows to compile a linux kernel v.2.4.26 W/o this patch a tcc simply crashes.
Unified · Split
| @@ -1418,7 +1418,7 @@ int gtst(int inv, int t) · 1417 unmodified lines | ||
| 1418 | 1418 | op|=encbranch(r,t,1); |
| 1419 | 1419 | o(op); |
| 1420 | 1420 | t=r; |
| 1421 | − } else { /* VT_JMP || VT_JMPI */ | |
| 1421 | + } else if (v == VT_JMP || v == VT_JMPI) { | |
| 1422 | 1422 | if ((v & 1) == inv) { |
| 1423 | 1423 | if(!vtop->c.i) |
| 1424 | 1424 | vtop->c.i=t; |
| @@ -2102,7 +2102,7 @@ int gtst(int inv, int t) · 2101 unmodified lines | ||
| 2102 | 2102 | C67_NOP(5); |
| 2103 | 2103 | t = ind1; //return where we need to patch |
| 2104 | 2104 | |
| 2105 | − } else { /* VT_JMP || VT_JMPI */ | |
| 2105 | + } else if (v == VT_JMP || v == VT_JMPI) { | |
| 2106 | 2106 | /* && or || optimization */ |
| 2107 | 2107 | if ((v & 1) == inv) { |
| 2108 | 2108 | /* insert vtop->c jump list in t */ |
| @@ -677,7 +677,7 @@ ST_FUNC int gtst(int inv, int t) · 676 unmodified lines | ||
| 677 | 677 | /* fast case : can jump directly since flags are set */ |
| 678 | 678 | g(0x0f); |
| 679 | 679 | t = psym((vtop->c.i - 16) ^ inv, t); |
| 680 | − } else { /* VT_JMP || VT_JMPI */ | |
| 680 | + } else if (v == VT_JMP || v == VT_JMPI) { | |
| 681 | 681 | /* && or || optimization */ |
| 682 | 682 | if ((v & 1) == inv) { |
| 683 | 683 | /* insert vtop->c jump list in t */ |
| @@ -516,7 +516,7 @@ int gtst(int inv, int t) · 515 unmodified lines | ||
| 516 | 516 | break; |
| 517 | 517 | } |
| 518 | 518 | t = out_opj(c, t); |
| 519 | − } else { /* VT_JMP || VT_JMPI */ | |
| 519 | + } else if (v == VT_JMP || v == VT_JMPI) { | |
| 520 | 520 | /* && or || optimization */ |
| 521 | 521 | if ((v & 1) == inv) { |
| 522 | 522 | /* insert vtop->c jump list in t */ |
| @@ -1592,7 +1592,7 @@ int gtst(int inv, int t) · 1591 unmodified lines | ||
| 1592 | 1592 | } |
| 1593 | 1593 | g(0x0f); |
| 1594 | 1594 | t = psym((vtop->c.i - 16) ^ inv, t); |
| 1595 | − } else { /* VT_JMP || VT_JMPI */ | |
| 1595 | + } else if (v == VT_JMP || v == VT_JMPI) { | |
| 1596 | 1596 | /* && or || optimization */ |
| 1597 | 1597 | if ((v & 1) == inv) { |
| 1598 | 1598 | /* insert vtop->c jump list in t */ |