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]
Other format: [Raw text]

bug in the assignment of an integer


Hi,

I am working on the port of the gcc version 3.0.1 to the StarCore
architecture ( DSP from Motorola/Agere ).

While compiling the code fragment

x = 0x7fffffff;
y = 0x80000000;

with the optimization turned on ( O1 or higher ) compiler produces the
following code:

x <- 0x7fffffff
y <- x+1

which, also logically being correct, may or may not generated the desirable
result in 'y' - StarCore ( as some other CPUs ) under certain conditions
doesn't generate result when an instruction will cause overflow ( instead
setting some flags to indicate that ).

The code, responsible for this optimization is found in
'reload1.c:reload_cse_move2add':

    rtx new_src = GEN_INT (sext_for_mode (GET_MODE (reg),
       INTVAL (src)
       - reg_offset[regno]));
.....
      success = validate_change (insn, &PATTERN (insn),
            gen_add2_insn (reg, new_src), 0);


Perhaps it should be a command option to enable/disable this optimization
and/or expression:

       reg_offset[regno] + ( INTVAL (src) - reg_offset[regno] )

shall be checked for overflow.

Regards,

David Livshin
dlivshin@internet-zahav.net
Tel:      +972 - 8 - 935 - 4597
Mobile: +972 - 67 - 290 - 998
Laskov 11/31
Rehovot, 76654
Israel






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