This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SRA bit-field optimization


> Ping^2?
>
> Tests on ppc* passed back then, BTW.

It apparently still misbehaves in some cases for Ada and has introduced an 
ACATS regression at -O2 on x86-64 (c37213b):

<bb 4>:
  # D.857_26 = PHI <D.857_11(3), D.857_27(7)>
  D.860_25 = (<unnamed-signed:64>) D.857_26;
  _init = VIEW_CONVERT_EXPR<struct p__cons[D.859:D.861]>(*x.1_3)[D.860_25]{lb: 
D.859_24 sz: 12};
  SR.57_139 = VIEW_CONVERT_EXPR<UNSIGNED_64>(_init.c1);
  _init.c1 = VIEW_CONVERT_EXPR<struct p__cons__T2b>(SR.57_139);
  D.976 = VIEW_CONVERT_EXPR<struct p__rec>(4294967297);
  SR.45_155 = VIEW_CONVERT_EXPR<UNSIGNED_64>(D.976);
  D.978.c1 = VIEW_CONVERT_EXPR<struct p__cons__T2b>(SR.45_155);
  D.978.d3 = 1;
  D.960 = D.978;
  VIEW_CONVERT_EXPR<struct p__cons[D.859:D.861]>(*x.1_3)[D.860_25]{lb: 
D.859_24 sz: 12} = D.960;

<bb 5>:
  if (D.858_23 == D.857_26)
    goto <bb 6>;
  else
    goto <bb 7>;

is now turned into

<bb 4>:
  # SR.128_80 = PHI <SR.128_164(3), SR.128_197(7)>
  # D.857_26 = PHI <D.857_11(3), D.857_27(7)>
  D.860_25 = (<unnamed-signed:64>) D.857_26;
  _init$d3_69 = VIEW_CONVERT_EXPR<struct p__cons[D.859:D.861]>(*x.1_3)
[D.860_25]{lb: D.859_24 sz: 12}.d3;
  SR.131_67 = VIEW_CONVERT_EXPR<UNSIGNED_64>(VIEW_CONVERT_EXPR<struct 
p__cons[D.859:D.861]>(*x.1_3)[D.860_25]{lb: D.859_24 sz: 12}.c1);
  _init$c1$B0F64_65 = SR.131_67;
  SR.132_63 = _init$c1$B0F64_65;
  _init.c1 = VIEW_CONVERT_EXPR<struct p__cons__T2b>(SR.132_63);
  SR.57_139 = VIEW_CONVERT_EXPR<UNSIGNED_64>(_init.c1);
  SR.133_6 = SR.57_139;
  _init$c1$B0F64_154 = SR.133_6;
  D.976 = VIEW_CONVERT_EXPR<struct p__rec>(4294967297);
  SR.45_155 = VIEW_CONVERT_EXPR<UNSIGNED_64>(D.976);
  SR.134_142 = SR.45_155;
  SR.130_124 = SR.134_142;
  SR.129_148 = 1;
  SR.135_147 = SR.128_80 & 4294967295;
  SR.138_83 = SR.130_124 >> 32;
  SR.136_141 = (p__sm___XDLU_1__10) SR.138_83;
  SR.139_140 = (UNSIGNED_64) SR.136_141;
  SR.140_138 = SR.139_140 << 32;
  SR.128_92 = SR.135_147 | SR.140_138;
  SR.141_201 = SR.128_92 & 0x0ffffffff00000000;
  SR.142_200 = (p__sm___XDLU_1__10) SR.130_124;
  SR.144_199 = (UNSIGNED_64) SR.142_200;
  SR.128_137 = SR.141_201 | SR.144_199;
  SR.128_197 = SR.130_124;
  SR.127_136 = SR.129_148;
  SR.145_135 = SR.128_197;

<bb 5>:
  VIEW_CONVERT_EXPR<struct p__cons[D.859:D.861]>(*x.1_3)[D.860_25]{lb: 
D.859_24 sz: 12}.c1 = VIEW_CONVERT_EXPR<struct p__cons__T2b>(SR.145_135);
  VIEW_CONVERT_EXPR<struct p__cons[D.859:D.861]>(*x.1_3)[D.860_25]{lb: 
D.859_24 sz: 12}.d3 = SR.127_136;
  if (D.858_23 == D.857_26)
    goto <bb 6>;
  else
    goto <bb 7>;


The correctness problem is that the last statement of BB 4 is not 
tree_could_throw_p anymore, yielding:

p.adb: In function 'P':
p.adb:1: error: statement marked for throw, but doesn't
SR.145_135 = SR.128_197;

The optimization problem is the junk now present at the end of BB 4.

Testcase attached, compile at -O2.

-- 
Eric Botcazou
PROCEDURE P IS

   SUBTYPE SM IS INTEGER RANGE 1..10;

   TYPE REC (D1, D2 : SM) IS RECORD NULL; END RECORD;

   F1_CONS : INTEGER := 2;

   FUNCTION F1 RETURN INTEGER IS
   BEGIN
      F1_CONS := F1_CONS - 1;
      RETURN F1_CONS;
   END F1;

   TYPE CONS (D3 : INTEGER := 1) IS
      RECORD
         C1 : REC(D3, F1);
      END RECORD;

   Y : CONS;

   TYPE ARR IS ARRAY (1..5) OF CONS;

BEGIN

   DECLARE
      X : ARR;
   BEGIN
      IF X /= (1..5 => (1, (1, 1))) THEN
         raise Program_Error;
      END IF;
   END;
   EXCEPTION
      WHEN CONSTRAINT_ERROR => NULL;

END;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]