mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Improve dead code elimination
This commit is contained in:
parent
760db8c5ad
commit
0e36cb3ac4
6606 changed files with 9685 additions and 9854 deletions
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
|
@ -550,47 +549,3 @@ TEST(div64, test) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCH(imul, bench) {
|
||||
volatile register int8_t x8, y8;
|
||||
volatile register int16_t x16, y16;
|
||||
volatile register int32_t x32, y32;
|
||||
volatile register int64_t x64, y64;
|
||||
EZBENCH2("imul8", PROGN(x8 = 7, y8 = 18), y8 *= x8);
|
||||
EZBENCH2("imul16", PROGN(x16 = 123, y16 = 116), y16 *= x16);
|
||||
EZBENCH2("imul32", PROGN(x32 = 0x238943, y32 = 0x238), y32 *= x32);
|
||||
EZBENCH2("imul64", PROGN(x64 = 0x23894329838932, y64 = 0x238), y64 *= x64);
|
||||
}
|
||||
|
||||
BENCH(idiv, bench) {
|
||||
volatile register int8_t x8, y8;
|
||||
volatile register int16_t x16, y16;
|
||||
volatile register int32_t x32, y32;
|
||||
volatile register int64_t x64, y64;
|
||||
EZBENCH2("idiv8", PROGN(x8 = 7, y8 = 18), x8 /= y8);
|
||||
EZBENCH2("idiv16", PROGN(x16 = 123, y16 = 116), x16 /= y16);
|
||||
EZBENCH2("idiv32", PROGN(x32 = 0x238943298, y32 = 0x238), x32 /= y32);
|
||||
EZBENCH2("idiv64", PROGN(x64 = 0x23894329838932, y64 = 0x238), x64 /= y64);
|
||||
}
|
||||
|
||||
BENCH(mul, bench) {
|
||||
volatile register uint8_t x8, y8;
|
||||
volatile register uint16_t x16, y16;
|
||||
volatile register uint32_t x32, y32;
|
||||
volatile register uint64_t x64, y64;
|
||||
EZBENCH2("mul8", PROGN(x8 = 7, y8 = 18), y8 *= x8);
|
||||
EZBENCH2("mul16", PROGN(x16 = 123, y16 = 116), y16 *= x16);
|
||||
EZBENCH2("mul32", PROGN(x32 = 0x238943, y32 = 0x238), y32 *= x32);
|
||||
EZBENCH2("mul64", PROGN(x64 = 0x23894329838932, y64 = 0x238), y64 *= x64);
|
||||
}
|
||||
|
||||
BENCH(div, bench) {
|
||||
volatile register uint8_t x8, y8;
|
||||
volatile register uint16_t x16, y16;
|
||||
volatile register uint32_t x32, y32;
|
||||
volatile register uint64_t x64, y64;
|
||||
EZBENCH2("div8", PROGN(x8 = 7, y8 = 18), x8 /= y8);
|
||||
EZBENCH2("div16", PROGN(x16 = 123, y16 = 116), x16 /= y16);
|
||||
EZBENCH2("div32", PROGN(x32 = 0x238943298, y32 = 0x238), x32 /= y32);
|
||||
EZBENCH2("div64", PROGN(x64 = 0x23894329838932, y64 = 0x238), x64 /= y64);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/progn.internal.h"
|
||||
#include "libc/fmt/bing.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
@ -161,9 +160,14 @@ BENCH(machine, benchPrimeNumberPrograms) {
|
|||
ASSERT_EQ(15, Read32(m->ax));
|
||||
}
|
||||
|
||||
static void machine_benchFpu_fn(void) {
|
||||
ExecuteUntilHalt(m);
|
||||
FpuPop(m);
|
||||
}
|
||||
|
||||
BENCH(machine, benchFpu) {
|
||||
VirtualRecv(m, 0, kPi80, sizeof(kPi80));
|
||||
EZBENCH2("pi80", m->ip = 0, PROGN(ExecuteUntilHalt(m), FpuPop(m)));
|
||||
EZBENCH2("pi80", m->ip = 0, machine_benchFpu_fn());
|
||||
}
|
||||
|
||||
BENCH(machine, benchLoadExec2) {
|
||||
|
@ -266,13 +270,18 @@ BENCH(machine, benchLoadExec8) {
|
|||
EZBENCH2("fchs", m->ip = 0, ExecuteInstruction(m));
|
||||
}
|
||||
|
||||
static void machine_benchPushpop_fn(void) {
|
||||
LoadInstruction(m);
|
||||
ExecuteInstruction(m);
|
||||
LoadInstruction(m);
|
||||
ExecuteInstruction(m);
|
||||
}
|
||||
|
||||
BENCH(machine, benchPushpop) {
|
||||
uint8_t kPushpop[] = {0x50, 0x58};
|
||||
Write64(m->ax, 0);
|
||||
VirtualRecv(m, 0, kPushpop, sizeof(kPushpop));
|
||||
EZBENCH2("pushpop", m->ip = 0,
|
||||
PROGN(LoadInstruction(m), ExecuteInstruction(m), LoadInstruction(m),
|
||||
ExecuteInstruction(m)));
|
||||
EZBENCH2("pushpop", m->ip = 0, machine_benchPushpop_fn());
|
||||
}
|
||||
|
||||
BENCH(machine, benchPause) {
|
||||
|
@ -291,14 +300,18 @@ BENCH(machine, benchClc) {
|
|||
EZBENCH2("clc", m->ip = 0, ExecuteInstruction(m));
|
||||
}
|
||||
|
||||
static void machine_benchNop_fn(void) {
|
||||
LoadInstruction(m);
|
||||
ExecuteInstruction(m);
|
||||
}
|
||||
|
||||
BENCH(machine, benchNop) {
|
||||
uint8_t kNop[] = {0x90};
|
||||
Write64(m->ax, 0);
|
||||
VirtualRecv(m, 0, kNop, sizeof(kNop));
|
||||
LoadInstruction(m);
|
||||
EZBENCH2("nop", m->ip = 0, ExecuteInstruction(m));
|
||||
EZBENCH2("nop w/ load", m->ip = 0,
|
||||
PROGN(LoadInstruction(m), ExecuteInstruction(m)));
|
||||
EZBENCH2("nop w/ load", m->ip = 0, machine_benchNop_fn());
|
||||
}
|
||||
|
||||
TEST(x87, fprem1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue