From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,53a810f13e8ba40 X-Google-Attributes: gid103376,public From: "wiljan" Subject: Re: Byte/Bit Twiddling in Ada Date: 1997/02/15 Message-ID: <01bc1b6e$f5d65c30$3e208b82@wd>#1/1 X-Deja-AN: 219015090 References: <5dvfnn$olj@neocad.xilinx.com> <33048844.7AEB@elca-matrix.ch> Organization: Philips Electronics N.V. Newsgroups: comp.lang.ada Date: 1997-02-15T00:00:00+00:00 List-Id: Robert Dewar wrote in article ... > GNAT certainly is in the business of recognizing the CPU instruction set! > That's what the code generation of gcc is all about. > [snip] > > GNAT *does* generate good code for messing with individual bits of a bit > packed array, which seems the most common usage. > I do not agree on that Robert, Plese check out the following program: with Ada.Text_Io; use Ada.Text_Io; procedure testsetcomp is type set is array(0..31) of boolean; pragma pack (set); A, B : Set; begin A := (5..10=>True, others=>False); B := (others=>False); B (5..10) := (others=>True); if A <= B then Put_Line ("A<=B"); else Put_Line ("not A<=B"); end if; end testsetcomp; When I check the code generated using gnat -S -O2 -gnatp on above source I find the compiler generating loops for all kind of things. It generates loops for the variable initialisation. It also generates loops to perform the A<=B operation. I think this is normal usage of packed arrays. I actually use them a lot as if they where sets. Anyway GNAT generates very bad code for this. Somehow it is not a lot of knowledge about the packed arrays. I whould expect GNAT to generate only code for the call to: Put_Line ("A<=B"); That all which is actually needed in above code. Wiljan