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: PATCH:[darwin] fix load of a misaligned double word



On Dec 31, 2003, at 2:59 PM, David Edelsohn wrote:


	___r1 is a pointer to int, which appears to produce the
mis-aligned offsets.

No, ___r1 is an int.


Here's the self-contained shorter example. When compiled with

[dhcp10:~/programs/gambc40b4] lucier% gcc -v
Reading specs from /pkgs/gcc-3.4/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/specs
Configured with: ../configure --prefix=/pkgs/gcc-3.4 --disable-checking
Thread model: posix
gcc version 3.4.0 20031229 (experimental)


by

gcc -I../include -I. -no-cpp-precomp -Wall -W -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fomit-frame-pointer -fPIC -fno-common -mcpu=G5 -save-temps -DHAVE_CONFIG_H -D___PRIMAL -D___LIBRARY -D___GAMBCDIR=\"/usr/local/\" -c test2.i -da
gcc: unrecognized option `-no-cpp-precomp'
test2.s:63:Parameter error: expression must be a multiple of 4 (parameter 2)


I've looked at the dumps and from the sched2 (the last) dump it is clear that while the instruction as scheduled tries to load the double to the GPR with an offset of 3, the actual instruction list seems to say that it's loading it to a DFMODE register:

(insn:TI 191 303 314 12 (set (reg/v:DF r0 [orig:126 ___F64V1 ] [126])
(mem:DF (plus:SI (reg/v:SI r9 [orig:125 ___r1 ] [125])
(const_int 3 [0x3])) [0 S8 A64])) 318 {*movdf_hardfloat64} (nil)
(expr_list:REG_DEAD (reg/v:SI r9 [orig:125 ___r1 ] [125])
(nil)))


But, as you well know, I'm not an expert at this, so you'll need to make your own analysis.

Brad

struct sigcontext {
    int sc_onstack;
    int sc_mask;
 int sc_ir;
    int sc_psw;
    int sc_sp;
 void *sc_regs;
};

typedef int jmp_buf[(26 + 36 + 129 + 1)];

static int ___lp;

/*

struct _jmp_buf {
 struct sigcontext sigcontext;
 unsigned long vmask __attribute__((aligned(8)));
 unsigned long vreg[32 * 4] __attribute__((aligned(16)));

};
*/

typedef struct ___jmpbuf_struct
  {
    jmp_buf buf;
  } ___jmpbuf_struct;


typedef struct ___processor_state_struct { int *stack_trip; int *stack_limit; int *fp; int *stack_start; int *stack_break;

    int *heap_limit;
    int *hp;

    int current_thread;
    int run_queue;

    int r[5];
    int pc;
    int temp1;
    int temp2;
    int temp3;
    int temp4;

    int na;
    int intr_enabled;
    int intr_flag[8];

    int glo_list_head;
    int glo_list_tail;

    int handler_break;
    int handler_stack_limit;
    int handler_heap_limit;
    int handler_not_proc;
    int handler_not_proc_glo;
    int handler_wrong_nargs;
    int handler_get_rest;
    int handler_get_key;
    int handler_get_key_rest;
    int handler_force;
    int handler_cfun_conv_error;
    int handler_sfun_conv_error;
    int handler_return_to_c;

    int executable_wills;
    int nonexecutable_wills;

    void (*dummy8) (void);
    void (*dummy7) (void);
    void (*dummy6) (void);
    void (*dummy5) (void);
    void (*dummy4) (void);
    void (*dummy3) (void);
    void (*dummy2) (void);
    void (*dummy1) (void);


___jmpbuf_struct *catcher; } ___processor_state_struct, *___processor_state;

typedef int (*___host) (___processor_state);

typedef struct ___label_struct
  {
    int header;
    int entry_or_descr;
    void* host_label;
    ___host host;
  } ___label_struct;

    int (*___isfinite)
       (double x);

static int ___H__23__23_rational_3f_ (___processor_state ___ps){ register int ___pc, ___start, ___temp; register unsigned long long ___temp64; register int ___r0; register int ___r1; double ___F64V1;
static void *___hlbl_tbl[]={
0,
&&___L0__23__23_rational_3f_,
0}; if (___ps == 0) return (int)___hlbl_tbl;
___r0=___ps->r[0]; ___r1=___ps->r[1]; ___start=___lp+((132)*4*4); ___pc=___ps->pc; goto *((___label_struct*)(___pc-1))->host_label;
___L0__23__23_rational_3f_:
if(___ps->na==1){}else
{___ps->temp1=___start+((132 -132 +0)*4*4); { {___pc=___ps->handler_wrong_nargs;goto ___jumpext;}}}
___L__23__23_rational_3f_:
if (((___r1&((1<<2)-1))==(0))) {
goto ___L2__23__23_rational_3f_;
}
if ((((___temp=(___r1))&((1<<2)-1))==1&&((((*((int*)((___temp)- (1)))))&(((1<<5)-1)<<3))==(((30))<<3)))) {
goto ___L3__23__23_rational_3f_;
}
if (!((___r1&((1<<2)-1))==(1))) {
goto ___L1__23__23_rational_3f_;
}
___r1=((((*((int*)((___r1)-(1))))&(((1<<5)-1)<<3))>>(3 -2)));
if ((___r1==(((int)(31L))<<2))) {
goto ___L2__23__23_rational_3f_;
}
if ((___r1==(((int)(2L))<<2))) {
goto ___L2__23__23_rational_3f_;
}
if (!(___r1==(((int)(3L))<<2))) {
goto ___L1__23__23_rational_3f_;
}
___L1__23__23_rational_3f_:
___r1=(((((int)(-1))<<2)+2));
{ {void *___host_label; ___pc=___r0; ___host_label=((___label_struct*)(___pc-1))->host_label; if (((___label_struct*)(___pc-1))->host == ___H__23__23_rational_3f_) goto *___host_label; goto ___jumpext;}}
___L2__23__23_rational_3f_:
___r1=(((((int)(-2))<<2)+2));
{ {void *___host_label; ___pc=___r0; ___host_label=((___label_struct*)(___pc-1))->host_label; if (((___label_struct*)(___pc-1))->host == ___H__23__23_rational_3f_) goto *___host_label; goto ___jumpext;}}
___L3__23__23_rational_3f_:
___F64V1=(*((double*)((((int*)((___r1)-(1)))+1))));
___r1=((___isfinite(___F64V1))?((((int)(-2))<<2)+2):((((int)( -1))<<2)+2));
{ {void *___host_label; ___pc=___r0; ___host_label=((___label_struct*)(___pc-1))->host_label; if (((___label_struct*)(___pc-1))->host == ___H__23__23_rational_3f_) goto *___host_label; goto ___jumpext;}}
___jumpext:
___ps->pc=___pc; ___ps->r[1]=___r1; return ___pc; }



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