🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6036

GCC 2.7.2 / SH / incorrect assembly code

#6036
From: Stephen Adams
Date: Tue, 07 Jan 1997 00:00
123 lines
3077 bytes

The following file when compiled with

	gcc -O -c bug.c

produces the following error:

/tmp/cca23824.s: Assembler messages:
/tmp/cca23824.s:15: Warning: pcrel too far

I think I know what the problem is.  config/sh/sh.c contains
the comment

  /* For HImode: range is 510, add 4 because pc counts from address of
     second instruction after this one, subtract 2 for the jump instruction
     that we may need to emit before the table.  This gives 512.
     For SImode: range is 1020, add 4 because pc counts from address of
     second instruction after this one, subtract 2 in case pc is 2 byte
     aligned, subtract 2 for the jump instruction that we may need to emit
     before the table.  This gives 1020.  */

However, in all cases that I have seen, the delay slot of
the jump instruction was unfilled (contains `nop') OR
contains an instruction that was moved from BEFORE the first
reference to the constant pool, leading to an actual range
larger than the calculated range.

bug.c:
________________________________________
void g (int *v)
{
  v[0] = 1000;
  v[1] = 1001;
  v[2] = 1002;
  v[3] = 1003;
  v[4] = 1004;
  v[5] = 1005;
  v[6] = 1006;
  v[7] = 1007;
  v[8] = 1008;
  v[9] = 1009;
  v[10] = 1010;
  v[11] = 1011;
  v[12] = 1012;
  v[13] = 1013;
  v[14] = 1014;
  v[15] = 1015;
  v[16] = 1016;
  v[17] = 1017;
  v[18] = 1018;
  v[19] = 1019;
  v[20] = 1020;
  v[21] = 1021;
  v[22] = 1022;
  v[23] = 1023;
  v[24] = 1024;
  v[25] = 1025;
  v[26] = 1026;
  v[27] = 1027;
  v[28] = 1028;
  v[29] = 1029;
  v[30] = 1030;
  v[31] = 1031;
  v[32] = 1032;
  v[33] = 1033;
  v[34] = 1034;
  v[35] = 1035;
  v[36] = 1036;
  v[37] = 1037;
  v[38] = 1038;
  v[39] = 1039;
  v[40] = 1040;
  v[41] = 1041;
  v[42] = 1042;
  v[43] = 1043;
  v[44] = 1044;
  v[45] = 1045;
  v[46] = 1046;
  v[47] = 1047;
  v[48] = 1048;
  v[49] = 1049;
  v[50] = 1050;
  v[51] = 1051;
  v[52] = 1052;
  v[53] = 1053;
  v[54] = 1054;
  v[55] = 1055;
  v[56] = 1056;
  v[57] = 1057;
  v[58] = 1058;
  v[59] = 1059;
  v[60] = 1060;
  v[61] = 1061;
  v[62] = 1062;
  v[63] = 1063;
  v[64] = 1064;
  v[65] = 1065;
  v[66] = 1066;
  v[67] = 1067;
  v[68] = 1068;
  v[69] = 1069;
  v[70] = 1070;
  v[71] = 1071;
  v[72] = 1072;
  v[73] = 1073;
  v[74] = 1074;
  v[75] = 1075;
  v[76] = 1076;
  v[77] = 1077;
  v[78] = 1078;
  v[79] = 1079;
  v[80] = 1080;
  v[81] = 1081;
  v[82] = 1082;
  v[83] = 1083;
  v[84] = 1084;
  v[85] = 1085;
  v[86] = 1086;
  v[87] = 1087;
  v[88] = 1088;
  v[89] = 1089;
}
Technical Details
Message-ID: <m0vheJz-00016XC@brugg.ai.mit.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,2f3ca6778e57882f,start
X-Google-Attributes: gid113d02,public
From: adams@martigny.ai.mit.edu (Stephen Adams)
Subject: GCC 2.7.2 / SH / incorrect assembly code
Date: 1997/01/07
Message-ID: <m0vheJz-00016XC@brugg.ai.mit.edu>
X-Deja-AN: 208326723
sender: bug-gcc-request@prep.ai.mit.edu
x-gateway: relay3.UU.NET from bug-gcc to gnu.gcc.bug; Tue, 7 Jan 1997 11:24:44 EST
newsgroups: gnu.gcc.bug