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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Byte/Bit Twiddling in Ada Date: 1997/02/15 Message-ID: #1/1 X-Deja-AN: 218979988 References: <5dvfnn$olj@neocad.xilinx.com> <33048844.7AEB@elca-matrix.ch> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-02-15T00:00:00+00:00 List-Id: Mats asked: <<(Robert, what kind of code would GNAT generate for these instructions ? Does the optimizer recognize the CPU's instruction set ?)>> in reference to slices of bit-packed arrays. GNAT certainly is in the business of recognizing the CPU instruction set! That's what the code generation of gcc is all about. However, that is not the issue here, the issue is very special handling of these kinds of slices at a level where the GCC optimizer could generate good code. This is not currently done. Note that if you want to do shifts or rotates, the use of modular types is probably more convenient and natural than writing strange concatenations and slice assignments. Yes, of course these could be optimized, but we have rarely seen people try to do, say your rotate case, this way, so it seems a low priority specialization. On the other hand, general slice assignments are a useful facility, but again, this is a relatively rare construct in the code we have seen. You can of course achieve these kind of effects with shifting and masking on modular values. GNAT *does* generate good code for messing with individual bits of a bit packed array, which seems the most common usage.