summaryrefslogtreecommitdiff
blob: 6bc1a3531da1f2936521f2032e9f9174b10a8700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
2003-02-25  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>

	PR target/9732
	* config/rs6000/rs6000.c (first_reg_to_save): Handle
	PIC_OFFSET_TABLE_REGNUM for -fPIC too.
	(rs6000_emit_prologue): Likewise.
	(rs6000_emit_epilogue): Likewise.
	* config/rs6000/rs6000.h (CONDITIONAL_REGISTER_USAGE): Make
	PIC_OFFSET_TABLE_REGNUM a fixed register for -fPIC.
	* testsuite/gcc.dg/20030225-2.c: New test.

--- gcc-3.2.2/gcc/config/rs6000/rs6000.c.pr9732	2003-01-29 20:56:16.000000000 +0100
+++ gcc-3.2.2/gcc/config/rs6000/rs6000.c	2003-02-28 10:52:09.000000000 +0100
@@ -7412,7 +7412,7 @@ first_reg_to_save ()
     if (regs_ever_live[first_reg] 
 	&& (! call_used_regs[first_reg]
 	    || (first_reg == RS6000_PIC_OFFSET_TABLE_REGNUM
-		&& ((DEFAULT_ABI == ABI_V4 && flag_pic == 1)
+		&& ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
 		    || (DEFAULT_ABI == ABI_DARWIN && flag_pic)))))
       break;
 
@@ -8804,7 +8804,7 @@ rs6000_emit_prologue ()
 	if ((regs_ever_live[info->first_gp_reg_save+i] 
 	     && ! call_used_regs[info->first_gp_reg_save+i])
 	    || (i+info->first_gp_reg_save == RS6000_PIC_OFFSET_TABLE_REGNUM
-		&& ((DEFAULT_ABI == ABI_V4 && flag_pic == 1)
+		&& ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
 		    || (DEFAULT_ABI == ABI_DARWIN && flag_pic))))
 	  {
 	    rtx addr, reg, mem;
@@ -9190,7 +9190,7 @@ rs6000_emit_epilogue (sibcall)
       if ((regs_ever_live[info->first_gp_reg_save+i] 
 	   && ! call_used_regs[info->first_gp_reg_save+i])
 	  || (i+info->first_gp_reg_save == RS6000_PIC_OFFSET_TABLE_REGNUM
-	      && ((DEFAULT_ABI == ABI_V4 && flag_pic == 1)
+	      && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
 		  || (DEFAULT_ABI == ABI_DARWIN && flag_pic))))
 	{
 	  rtx addr = gen_rtx_PLUS (Pmode, frame_reg_rtx, 
--- gcc-3.2.2/gcc/config/rs6000/rs6000.h.pr9732	2002-08-08 19:52:40.000000000 +0200
+++ gcc-3.2.2/gcc/config/rs6000/rs6000.h	2003-02-28 10:52:10.000000000 +0100
@@ -962,6 +962,10 @@ extern int rs6000_altivec_abi;
         = call_really_used_regs[i] = 1;					\
   if (DEFAULT_ABI == ABI_V4						\
       && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM			\
+      && flag_pic == 2)							\
+    fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM] = 1;			\
+  if (DEFAULT_ABI == ABI_V4						\
+      && PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM			\
       && flag_pic == 1)							\
     fixed_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]				\
       = call_used_regs[RS6000_PIC_OFFSET_TABLE_REGNUM]			\
--- gcc-3.2.2/gcc/testsuite/gcc.dg/20030225-2.c.pr9732	2003-02-28 10:55:14.000000000 +0100
+++ gcc-3.2.2/gcc/testsuite/gcc.dg/20030225-2.c	2003-02-28 10:55:03.000000000 +0100
@@ -0,0 +1,103 @@
+/* PR target/9732
+   This testcase segfaulted on PPC because PIC_OFFSET_TABLE_REGNUM was no
+   fixed register.
+   Distilled from the xvid sources by Guillaume Morin <guillaume@morinfr.org>
+   and Benjamin Herrenschmidt <benh@kernel.crashing.org>.  */
+/* { dg-do run } */
+/* { dg-options "-O2 -fPIC" } */
+/* { dg-warning "not supported" "PIC unsupported" { target cris-*-elf* mmix-*-* } 0 } */
+
+
+extern void exit (int);
+
+#define W1 2841					/* 2048*sqrt(2)*cos(1*pi/16) */
+#define W2 2676					/* 2048*sqrt(2)*cos(2*pi/16) */
+#define W3 2408					/* 2048*sqrt(2)*cos(3*pi/16) */
+#define W5 1609					/* 2048*sqrt(2)*cos(5*pi/16) */
+#define W6 1108					/* 2048*sqrt(2)*cos(6*pi/16) */
+#define W7 565					/* 2048*sqrt(2)*cos(7*pi/16) */
+
+
+/* private data */
+static short iclip[1024];		/* clipping table */
+static short *iclp;
+
+void
+idct_int32(short *const block)
+{
+  static short *blk;
+  static long i;
+  static long X0, X1, X2, X3, X4, X5, X6, X7, X8;
+
+  for (i = 0; i < 8; i++)		/* idct columns */
+    {
+      blk = block + i;
+      /* shortcut  */
+      if (! ((X1 = (blk[8 * 4] << 8)) | (X2 = blk[8 * 6])
+	     | (X3 = blk[8 * 2]) | (X4 = blk[8 * 1]) | (X5 = blk[8 * 7])
+	     | (X6 = blk[8 * 5]) | (X7 = blk[8 * 3])))
+	{
+	  blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = 
+	    blk[8 * 3] = blk[8 * 4] =
+	    blk[8 * 5] = blk[8 * 6] = blk[8 * 7] =
+	    iclp[(blk[8 * 0] + 32) >> 6];
+	  continue;
+	}
+      X0 = (blk[8 * 0] << 8) + 8192;
+
+      /* first stage  */
+      X8 = W7 * (X4 + X5) + 4;
+      X4 = (X8 + (W1 - W7) * X4) >> 3;
+      X5 = (X8 - (W1 + W7) * X5) >> 3;
+      X8 = W3 * (X6 + X7) + 4;
+      X6 = (X8 - (W3 - W5) * X6) >> 3;
+      X7 = (X8 - (W3 + W5) * X7) >> 3;
+
+      /* second stage  */
+      X8 = X0 + X1;
+      X0 -= X1;
+      X1 = W6 * (X3 + X2) + 4;
+      X2 = (X1 - (W2 + W6) * X2) >> 3;
+      X3 = (X1 + (W2 - W6) * X3) >> 3;
+      X1 = X4 + X6;
+      X4 -= X6;
+      X6 = X5 + X7;
+      X5 -= X7;
+
+      /* third stage  */
+      X7 = X8 + X3;
+      X8 -= X3;
+      X3 = X0 + X2;
+      X0 -= X2;
+      X2 = (181 * (X4 + X5) + 128) >> 8;
+      X4 = (181 * (X4 - X5) + 128) >> 8;
+
+      /* fourth stage  */
+      blk[8 * 0] = iclp[(X7 + X1) >> 14];
+      blk[8 * 1] = iclp[(X3 + X2) >> 14];
+      blk[8 * 2] = iclp[(X0 + X4) >> 14];
+      blk[8 * 3] = iclp[(X8 + X6) >> 14];
+      blk[8 * 4] = iclp[(X8 - X6) >> 14];
+      blk[8 * 5] = iclp[(X0 - X4) >> 14];
+      blk[8 * 6] = iclp[(X3 - X2) >> 14];
+      blk[8 * 7] = iclp[(X7 - X1) >> 14];
+    }
+}								/* end function idct_int32(block) */
+
+
+int main(void) {
+  int i;
+  unsigned short tab[64];
+
+  for (i = 0 ; i < 64 ; ++i) 
+    {  
+      tab[i] = (1+(int) (65535)*8000/(2147483647+1.0));
+    }
+  
+  iclp = iclip + 512;
+  for (i = -512; i < 512; i++)
+    iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
+
+  idct_int32((short *) tab);
+  exit (0);
+}