public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-03-20 21:55 Ulrich Weigand
  2003-03-20 22:31 ` Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ulrich Weigand @ 2003-03-20 21:55 UTC (permalink / raw)
  To: gcc

Hello,

Ada builds are currently failing on s390x due to missing __divti3.

Now, I guess we could add 128-bit division routines to libgcc.
However, the question is whether this should really be needed.

What appears to happen is that the Ada source in question defines
a variable-sized object with non-standard alignment requirements,
and Ada reflects this by building a DECL_SIZE_UNIT tree containing
various mult_expr and div_expr nodes.  As alignment is counted in
bits, those have type bit_size_type, which on 64-bit platforms
corresponds to TImode. When expanding that tree, the backend emits
calls to __divti3.

However, I'm wondering:

- does bit_size_type really need to be TImode
- if so, shouldn't these special cases be implemented more efficiently
  somewhere (we divide by an integer constant 8 here)
- in general, are we really supposed to need TImode division

How does this work on other 64-bit platforms?


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-03-20 22:35 Ulrich Weigand
  2003-03-20 23:44 ` Richard Henderson
  0 siblings, 1 reply; 19+ messages in thread
From: Ulrich Weigand @ 2003-03-20 22:35 UTC (permalink / raw)
  To: rth; +Cc: gcc, uweigand

Richard Henderson wrote:

>On Thu, Mar 20, 2003 at 09:58:58PM +0100, Ulrich Weigand wrote:
>> Ada builds are currently failing on s390x due to missing __divti3.
>
>That shouldn't be happening.  They get built for e.g. alpha and ia64...

Well, I guess I can find out why divti3 doesn't get built.  However,
the IMO really interesting question is why TImode division should be
needed -- calling __divti3 just to make sure that a variable is 8-byte
aligned on the stack strikes me as seriously suboptimal ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-03-21  2:09 Ulrich Weigand
  0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Weigand @ 2003-03-21  2:09 UTC (permalink / raw)
  To: janis187; +Cc: uweigand, gcc

Janis Johnson wrote:

>You can change the value of MIN_UNITS_PER_WORD when compiling libgcc2.c.

Thanks for the tip, this was indeed the problem.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-03-24 11:08 Richard Kenner
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Kenner @ 2003-03-24 11:08 UTC (permalink / raw)
  To: weigand; +Cc: gcc

There is a bug I found a while ago related to unnecessary bitsizetype
operations, but I'm having troubloe setting up an environment
to test it.  In any case, I'm away until Wednesday morning.  More then.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re:  RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-03-31 20:16 Richard Kenner
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Kenner @ 2003-03-31 20:16 UTC (permalink / raw)
  To: Ulrich.Weigand; +Cc: gcc

Sorry I forgot to get back to this when I got back last week.

    What appears to happen is that the Ada source in question defines a
    variable-sized object with non-standard alignment requirements, and
    Ada reflects this by building a DECL_SIZE_UNIT tree containing various
    mult_expr and div_expr nodes.  As alignment is counted in bits, those
    have type bit_size_type, which on 64-bit platforms corresponds to
    TImode. When expanding that tree, the backend emits calls to __divti3.

The point of having separate DECL_SIZE_UNIT and DECL_SIZE is precisely for
the former to only have computations in sizetype and the latter in bitsizetype.
There are very rare situations where a bitsizetype might be in the expression
for DECL_SIZE_UNIT, but other occurrences are a bug.  Indeed, there's
a trivial bug in layout_decl that would account for some of those usages.
Here's the diff; I'll do the testing and installation for it within the
next few days.

*************** layout_decl (decl, known_align)
*** 368,372 ****
        DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (type);
      }
!   else
      DECL_SIZE_UNIT (decl)
        = convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),
--- 365,369 ----
        DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (type);
      }
!   else if (DECL_SIZE_UNIT (decl) == 0)
      DECL_SIZE_UNIT (decl)
        = convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl),


    - does bit_size_type really need to be TImode

Perhaps not, but it should for consistency.  In practice, not that much needs
to be computed dynamically for bitsizes.

    - if so, shouldn't these special cases be implemented more efficiently
      somewhere (we divide by an integer constant 8 here)

No.

    - in general, are we really supposed to need TImode division

Yes.

    How does this work on other 64-bit platforms?

By having __divti3.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-04-01 19:26 Ulrich Weigand
  0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Weigand @ 2003-04-01 19:26 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc


Richard Kenner wrote:

>The point of having separate DECL_SIZE_UNIT and DECL_SIZE is precisely for
>the former to only have computations in sizetype and the latter in
bitsizetype.
>There are very rare situations where a bitsizetype might be in the
expression
>for DECL_SIZE_UNIT, but other occurrences are a bug.

I've just tried to reproduce the problem with my test case, and it does not
occur with current 3.3 (or head) any more.  Apparently the problem was
caused
by a failure of fold-const.c optimize out the redundant bitsizetype
operations,
which was fixed by rth's 2003-03-20 checkin:

http://gcc.gnu.org/ml/gcc-cvs/2003-03/msg01077.html

(Reverting that checkin causes the problem to reappear.)

In any case, I can now build a 64-bit gnat1 binary that contains no
reference to __divti3 whatsoever.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-04-01 22:53 Richard Kenner
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Kenner @ 2003-04-01 22:53 UTC (permalink / raw)
  To: Ulrich.Weigand; +Cc: gcc

    In any case, I can now build a 64-bit gnat1 binary that contains no
    reference to __divti3 whatsoever.

But you still must have it, since you can easily construct programs that
will need it.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-04-02 15:36 Richard Kenner
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Kenner @ 2003-04-02 15:36 UTC (permalink / raw)
  To: Ulrich.Weigand; +Cc: gcc

    I still don't quite understand under what circumstances you would in
    fact need to perform TImode computations at run time (that cannot be
    optimized away at compile time).  Do you have an example?

Somewhat contrived, but try:

procedure foo (x : integer) is
    type r1(d: integer) is record
      f1: string (1..d);
      f2: integer;
    end record;

    rr1: r1 (x);
    rr2: r1 (x * 2);
begin
    if rr1'size > rr2'size then
      raise program_error;
    end if;
end foo;

This has *some* TImode computations, but not many.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-04-02 15:36 Ulrich Weigand
  0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Weigand @ 2003-04-02 15:36 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc


Richard Kenner wrote:

>>In any case, I can now build a 64-bit gnat1 binary that contains no
>>reference to __divti3 whatsoever.

>But you still must have it, since you can easily construct programs that
>will need it.

I've fixed the incorrect libgcc build on s390x now, do I do have TImode
operations including __divti3.

I still don't quite understand under what circumstances you would in
fact need to perform TImode computations at run time (that cannot be
optimized away at compile time).  Do you have an example?


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3
@ 2003-04-02 15:43 Ulrich Weigand
  0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Weigand @ 2003-04-02 15:43 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc


Richard Kenner wrote:

>This has *some* TImode computations, but not many.

Ah, I see, thanks.  In this case, everything could be expanded
inline (without requiring libgcc calls); that's probably why I
didn't notice before ...


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2003-04-02 15:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-20 21:55 RFA: Ada variable-sized objects, bit_size_type == TImode, and divti3 Ulrich Weigand
2003-03-20 22:31 ` Richard Henderson
2003-03-20 23:18 ` Geert Bosch
2003-03-21  0:00 ` Janis Johnson
2003-03-20 22:35 Ulrich Weigand
2003-03-20 23:44 ` Richard Henderson
2003-03-21  0:25   ` Neil Booth
2003-03-21  1:58   ` Ulrich Weigand
2003-03-21  7:46     ` Richard Henderson
2003-03-21 16:27       ` Ulrich Weigand
2003-03-21 20:25       ` Ulrich Weigand
2003-03-21  2:09 Ulrich Weigand
2003-03-24 11:08 Richard Kenner
2003-03-31 20:16 Richard Kenner
2003-04-01 19:26 Ulrich Weigand
2003-04-01 22:53 Richard Kenner
2003-04-02 15:36 Richard Kenner
2003-04-02 15:36 Ulrich Weigand
2003-04-02 15:43 Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).