pro64-support
[Top] [All Lists]

inefficient code generation for static initialized bitfields

To: pro64-support@xxxxxxxxxxx
Subject: inefficient code generation for static initialized bitfields
From: David Goodwin <goodwin@xxxxxxxxxxxxx>
Date: Tue, 31 Oct 2000 10:48:11 -0800 (PST)
Reply-to: goodwin@xxxxxxxxxxxxx
Sender: owner-pro64-support@xxxxxxxxxxx
This function generates inefficient code for the static initialization of
the bitfields in f. I think the problem is that the semantics of the whirl
generated by the front end result in the use of read-modify-writes to
initialize the fields when it could just write.


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef struct fields_struct
{
  unsigned int f1:2;
  unsigned int f2:2;
  unsigned int f3:2;
  unsigned int f4:2;
} fields;

fields
si1 (void)
{
  fields f = { 0, 1, 2 };
  return f;
}



        //  /usr/lib/gcc-lib/ia64-sgi-linux/sgicc-1.0/be::0.01.0-11

        //-----------------------------------------------------------
        // Compiling si.c (/tmp/ccI.j6MBFt)
        //-----------------------------------------------------------

        //-----------------------------------------------------------
        // Options:
        //-----------------------------------------------------------
        //  Target:Itanium, ISA:ISA_1, Pointer Size:64
        //  -O2 (Optimization level)
        //  -g0 (Debug level)
        //  -m1 (Report warnings)
        //-----------------------------------------------------------


        .section .text, "ax", "progbits"
        .align  16
        .section .text

        // Program Unit: si1
        .proc   si1#
        .global si1#
si1#:   // 0x0
        // f = 0
        .file   0 "/usr/local/home/goodwin/si.c"
        .loc    0       15      0
//  11  } fields;
//  12  
//  13  fields
//  14  si1 (void)
//  15  {
.BB1_si1:       // 0x0
//<freq>
//<freq> BB:1 frequency = 1.00000 (heuristic)
//<freq>
 {            .mii
        .loc    0       16      0
//  16    fields f = { 0, 1, 2 };
//      .unwentry
              ld4 r14=[sp]              // [0]  id:8 f+0x0
              mov r11=1                 // [0]  
              mov r10=2                 // [0]  
 }; {         .mii
              adds r9=1,sp              // [0]  f+1
              adds r8=2,sp              // [1]  f+2
              mov r3=0                  // [1]  
 }; {         .mii
              adds r2=3,sp              // [1]  f+3
              nop.i 0 ;;                //  
              dep r14=0,r14,0,2 ;;      // [2]  
 }; {         .mii
              nop.m 0                   //  
              dep r11=r11,r14,2,2 ;;    // [3]  
              dep r10=r10,r11,4,2 ;;    // [4]  
 }; {         .mmi
              st4 [sp]=r10              // [5]  id:8 f+0x0
              st1 [r9]=r3               // [6]  id:9 f+0x1
              nop.i 0                   //  
 }; {         .mmi
              st1 [r8]=r3               // [7]  id:9 f+0x1
              ld8.a r8=[sp]             // [8]  id:10 f+0x0
              nop.i 0                   //  
 }; {         .mmi
              st1 [r2]=r3 ;;            // [8]  id:9 f+0x1
              ld8.c.nc r8=[sp]          // [9]  
              nop.i 0                   //  
 }; {         .mib
              nop.m 0                   //  
              nop.i 0                   //  
              br.ret.sptk.many b0 ;;    // [9]  
 };
        .endp   si1#
// emit unwind info
        .section .IA_64.unwind_info
.Lunwind_info_0:
        data8 0x1000000000001
        data8 0x17
        .section .IA_64.unwind
        data8 @segrel(si1#)
        data8 @segrel(si1#+0x80)
        data8 @segrel(.Lunwind_info_0)
        .section .text
        .align 16
//      .gpvalue 0

        .section .debug_info, "", "progbits"
        .align  0
        data1   0x35, 0x00, 0x00, 0x00, 0x02, 0x00
        data4.ua        .debug_abbrev
        data1   0x08, 0x01, 0x73, 0x69, 0x2e, 0x63, 0x00, 0x2d
        data1   0x4f, 0x32, 0x00, 0x01, 0x00
        data4.ua        .debug_line
        data1   0x02, 0x01, 0x0f, 0x73, 0x69, 0x31, 0x00, 0x01
        data1   0x03, 0x92, 0x0c, 0x00
        data8.ua        .BB1_si1
        data8.ua        .BB1_si1 + 0x80
        data1   0x00, 0x00

        .section .debug_aranges, "", "progbits"
        .align  0
        data1   0x2c, 0x00, 0x00, 0x00, 0x02, 0x00
        data4.ua        .debug_info
        data1   0x08, 0x00, 0x00, 0x00, 0x00, 0x00
        data8.ua        .BB1_si1
        data8.ua        .BB1_si1 - .BB1_si1 + 0x80
        data1   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        data1   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

        .section .debug_pubnames, "", "progbits"
        .align  0
        data1   0x16, 0x00, 0x00, 0x00, 0x02, 0x00
        data4.ua        .debug_info
        data1   0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00
        data1   0x73, 0x69, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00

        .section .debug_abbrev, "", "progbits"
        .align  0
        data1   0x01, 0x11, 0x01, 0x03, 0x08, 0x25, 0x08, 0x13
        data1   0x0b, 0x42, 0x0b, 0x10, 0x06, 0x00, 0x00, 0x02
        data1   0x2e, 0x00, 0x3a, 0x0b, 0x3b, 0x0b, 0x03, 0x08
        data1   0x3f, 0x0c, 0x40, 0x0a, 0x11, 0x01, 0x12, 0x01
        data1   0x00, 0x00

<Prev in Thread] Current Thread [Next in Thread>
  • inefficient code generation for static initialized bitfields, David Goodwin <=