From 6cbadf36b260041a608d34e6f839aef9403d68c1 Mon Sep 17 00:00:00 2001 From: Geoffrey Keating Date: Wed, 27 Dec 2000 11:01:03 +0000 Subject: [PATCH] [multiple changes] 2000-12-27 Geoffrey Keating * config/rs6000/rs6000.md (define_attr "length"): Correct calculation. 2000-12-26 Geoffrey Keating * gcc.c-torture/compile/20001226-1.c: New test. From-SVN: r38495 --- gcc/ChangeLog | 5 ++++ gcc/config/rs6000/rs6000.md | 8 +++--- gcc/testsuite/ChangeLog | 4 +++ .../gcc.c-torture/compile/20001226-1.c | 26 +++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20001226-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b93316ce2e2..ad406bdb062 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2000-12-27 Geoffrey Keating + + * config/rs6000/rs6000.md (define_attr "length"): Correct + calculation. + 2000-12-26 Kazu Hirata * config/h8300/h8300.c: Fix a comment typo. diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index a2be5ff4198..9df70cf3eaf 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -41,12 +41,14 @@ (const_string "integer")) ;; Length (in bytes). +; '(pc)' in the following doesn't include the instruction itself; it is +; calculated as if the instruction had zero size. (define_attr "length" "" (if_then_else (eq_attr "type" "branch") - (if_then_else (and (ge (minus (pc) (match_dup 0)) + (if_then_else (and (ge (minus (match_dup 0) (pc)) (const_int -32768)) - (lt (minus (pc) (match_dup 0)) - (const_int 32767))) + (lt (minus (match_dup 0) (pc)) + (const_int 32764))) (const_int 4) (const_int 8)) (const_int 4))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ae0a8925f8b..af375824f46 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-12-26 Geoffrey Keating + + * gcc.c-torture/compile/20001226-1.c: New test. + 2000-12-22 Joseph S. Myers * gcc.c-torture/compile/20001222-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20001226-1.c b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c new file mode 100644 index 00000000000..54dacf74167 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20001226-1.c @@ -0,0 +1,26 @@ +/* This testcase exposed two branch shortening bugs on powerpc. */ + +#define C(a,b) \ + if (a > b) goto gt; \ + if (a < b) goto lt; + +#define C4(x,b) C((x)[0], b) C((x)[1],b) C((x)[2],b) C((x)[3],b) +#define C16(x,y) C4(x, (y)[0]) C4(x, (y)[1]) C4(x, (y)[2]) C4(x, (y)[3]) + +#define C64(x,y) C16(x,y) C16(x+4,y) C16(x+8,y) C16(x+12,y) +#define C256(x,y) C64(x,y) C64(x,y+4) C64(x,y+8) C64(x,y+12) + +#define C1024(x,y) C256(x,y) C256(x+16,y) C256(x+32,y) C256(x+48,y) +#define C4096(x,y) C1024(x,y) C1024(x,y+16) C1024(x,y+32) C1024(x,y+48) + +unsigned foo(int x[64], int y[64]) +{ + C4096(x,y); + + return 0x01234567; + gt: + return 0x12345678; + lt: + return 0xF0123456; +} +