This is the mail archive of the gcc-bugs@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] |
>Number: 2842 >Category: optimization >Synopsis: long long on IRIX gives bad code >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Wed May 16 05:06:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Helmut Jarausch, RWTH-Aachen, Germany >Release: 3.0 20010511 (prerelease) >Organization: >Environment: mips-sgi-irix6.5 >Description: The following code generates correctly sz(dble)= 8 dble= 1001 when compiled witout -O But compiled with -O2 it generates sz(dble)= 8 dble= 2147430212 See preprocessed and both assembler outputs below. #define MR_BIG_ENDIAN #ifdef MR_LITTLE_ENDIAN #define MR_TOP(x) (*(((int *)&(x))+1)) #define MR_BOT(x) (*(((int *)&(x)))) #endif #ifdef MR_BIG_ENDIAN #define MR_TOP(x) (*(((int *)&(x)))) #define MR_BOT(x) (*(((int *)&(x))+1)) #endif int main() { long long dble; MR_BOT(dble)=1001; MR_TOP(dble)=0; printf("sz(dble)= %d dble= %lld\n",sizeof(dble),dble); } Preprocessed: int main() { long long dble; (*(((int *)&(dble))+1))=1001; (*(((int *)&(dble))))=0; printf("sz(dble)= %d dble= %lld\n",sizeof(dble),dble); } non-optimized assembler output ------- #.file 1 "gcc_O_bug.c" .option pic2 .section .text .section .rodata .align 3 .LC0: .byte 0x73,0x7a,0x28,0x64,0x62,0x6c,0x65,0x29 .byte 0x3d,0x20,0x25,0x64,0x20,0x64,0x62,0x6c .byte 0x65,0x3d,0x20,0x25,0x6c,0x6c,0x64,0xa .byte 0x0 .text .align 2 .globl main .ent main main: .LFB1: .frame $fp,64,$31 # vars= 16, regs= 3/0, args= 0, extra= 16 .mask 0xd0000000,-16 .fmask 0x00000000,0 subu $sp,$sp,64 .LCFI0: sd $31,48($sp) .LCFI1: sd $fp,40($sp) .LCFI2: sd $28,32($sp) .LCFI3: move $fp,$sp .LCFI4: .set noat lui $1,%hi(%neg(%gp_rel(main))) addiu $1,$1,%lo(%neg(%gp_rel(main))) daddu $gp,$1,$25 .set at li $2,1001 # 0x3e9 sw $2,20($fp) sw $0,16($fp) la $4,.LC0 li $5,8 # 0x8 ld $6,16($fp) la $25,printf jal $31,$25 move $sp,$fp ld $31,48($sp) ld $fp,40($sp) ld $28,32($sp) addu $sp,$sp,64 j $31 .LFE1: .end main ============== output of -O2 compilation ============== #.file 1 "gcc_O_bug.c" .set nobopt .option pic2 .section .text .section .rodata .align 3 .LC0: .byte 0x73,0x7a,0x28,0x64,0x62,0x6c,0x65,0x29 .byte 0x3d,0x20,0x25,0x64,0x20,0x64,0x62,0x6c .byte 0x65,0x3d,0x20,0x25,0x6c,0x6c,0x64,0xa .byte 0x0 .text .align 2 .align 3 .globl main .ent main main: .LFB1: .frame $sp,48,$31 # vars= 16, regs= 2/0, args= 0, extra= 16 .mask 0x90000000,-8 .fmask 0x00000000,0 subu $sp,$sp,48 .LCFI0: sd $31,40($sp) .LCFI1: sd $28,32($sp) .LCFI2: .set noat lui $1,%hi(%neg(%gp_rel(main))) addiu $1,$1,%lo(%neg(%gp_rel(main))) daddu $gp,$1,$25 .set at ld $6,16($sp) la $4,.LC0 li $5,8 # 0x8 li $2,1001 # 0x3e9 sw $2,20($sp) sw $0,16($sp) la $25,printf jal $31,$25 ld $31,40($sp) ld $28,32($sp) #nop .set noreorder .set nomacro j $31 addu $sp,$sp,48 .set macro .set reorder .LFE1: .end main >How-To-Repeat: see above >Fix: >Release-Note: >Audit-Trail: >Unformatted:
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |