From a3033f34cfe544f69cf769ce74a1a6f59b2dd95a Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 1 Jun 2003 18:10:09 +0200 Subject: [PATCH] re PR target/11044 ([x86] out of range loop instructions for FP code on K6) PR target/11044 * config/i386/i386.md (length attribute): Set length to 4 for instructions of type "fcmp". From-SVN: r67300 --- gcc/ChangeLog | 6 +++ gcc/config/i386/i386.md | 2 + gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/gcc.dg/i386-loop-3.c | 76 ++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/i386-loop-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c40d1ab4c6..21fe87ecd1e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-06-01 Eric Botcazou + + PR target/11044 + * config/i386/i386.md (length attribute): Set length to 4 + for instructions of type "fcmp". + 2003-06-01 Andreas Jaeger * toplev.c: Use ISO C90 prototypes. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index eb03cf2b8d5..181cf7e56aa 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -283,6 +283,8 @@ (define_attr "length" "" (cond [(eq_attr "type" "other,multi,fistp") (const_int 16) + (eq_attr "type" "fcmp") + (const_int 4) (eq_attr "unit" "i387") (plus (const_int 2) (plus (attr "prefix_data16") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 56bf4584037..7b6632c8a4c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-06-01 Eric Botcazou + + * gcc.dg/i386-loop-3.c: New test. + 2003-05-31 Toon Moene * g77.dg/ffree-form-2.f: XFAIL removed, because fixed. diff --git a/gcc/testsuite/gcc.dg/i386-loop-3.c b/gcc/testsuite/gcc.dg/i386-loop-3.c new file mode 100644 index 00000000000..c1b4bcea5be --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-loop-3.c @@ -0,0 +1,76 @@ +/* PR target/11044 */ +/* Originator: Tim McGrath */ +/* Testcase contributed by Eric Botcazou */ +/* { dg-do run { target i?86-*-* } } */ +/* { dg-options "-mtune=k6 -O3 -ffast-math -funroll-loops" } */ + +typedef struct +{ + unsigned char colormod; +} entity_state_t; + +typedef struct +{ + int num_entities; + entity_state_t *entities; +} packet_entities_t; + +typedef struct +{ + double senttime; + float ping_time; + packet_entities_t entities; +} client_frame_t; + +typedef enum +{ + cs_free, + cs_server, + cs_zombie, + cs_connected, + cs_spawned +} sv_client_state_t; + +typedef struct client_s +{ + sv_client_state_t state; + int ping; + client_frame_t frames[64]; +} client_t; + +int CalcPing (client_t *cl) +{ + float ping; + int count, i; + register client_frame_t *frame; + + if (cl->state == cs_server) + return cl->ping; + ping = 0; + count = 0; + for (frame = cl->frames, i = 0; i < 64; i++, frame++) { + if (frame->ping_time > 0) { + ping += frame->ping_time; + count++; + } + } + if (!count) + return 9999; + ping /= count; + + return ping * 1000; +} + +int main(void) +{ + client_t cl; + + memset(&cl, 0, sizeof(cl)); + + cl.frames[0].ping_time = 1.0f; + + if (CalcPing(&cl) != 1000) + abort(); + + return 0; +}