public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Optimization Problem
@ 2002-04-03 23:31 hideto-o
  0 siblings, 0 replies; 4+ messages in thread
From: hideto-o @ 2002-04-03 23:31 UTC (permalink / raw)
  To: gcc-help

I'm using gcc 2.9 cross compiler for MIPS3 (4650).
but I have a problem now. Please help me.

When I compile a C source below [LIST A] with optimization,
I got codes like [LIST B]. But LIST B is not right codes.

I guess gcc thinks that "if(f & 0x80000000)" means "if the leftmost bit of f is 1"
and gcc generates a code "bgez    $a2,10".
Now, variable f (unsigned long) is 32 bits width and general registers of MIPS is 64 bits width,
so "if(f & 0x80000000)" and "bgez    $a2,10" are not equal.
The former means to evaluate whether 32nd bit (from right) is 1, and the later means to evaluate
whethe 64th bit is 1. Because of wrong bit evaluation, my program doen't work well. 

Is this a known problem of gcc and already fixed at currnent version?
Or did I make some mistakes, for example, I forgot using some useful options?


gcc -mips3 -mgp64 -O1 -c if.c

[LIST A]if.c
unsigned int
test (unsigned long x, unsigned long y,  unsigned long  f){
  unsigned long  r;

  if (f & 0x80000000){
    r=x * y;
  }else{
    r=x + y;
  }

  return r;
}

[LIST B]objdump -d if.o
if.o:     file format elf32-bigmips

Disassembly of section .text:

0000000000000000 <test>:
   0:   04c10003        bgez    $a2,10 <test+0x10>
   4:   00851021        addu    $v0,$a0,$a1
   8:   00850018        mult    $a0,$a1
   c:   00001012        mflo    $v0
  10:   03e00008        jr      $ra
  14:   00000000        nop

Thanks

--
OGAWA Hideto, Japan.
hideto-o@mwb.biglobe.ne.jp




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Optimization problem
  2003-05-20 12:40 Optimization problem Anders Ådland
  2003-05-20 13:26 ` Nathan Sidwell
@ 2003-05-20 16:23 ` Muthukumar Ratty
  1 sibling, 0 replies; 4+ messages in thread
From: Muthukumar Ratty @ 2003-05-20 16:23 UTC (permalink / raw)
  To: Anders Ådland; +Cc: gcc-help

> My call to the library function atoi() is converted to a
> __strtol_internal function call when compiling with -O1 or higher. This
> is a GNU C library call, which I don't have. How can I tell GCC to use

It is defined as inline function in glibc. If you dont have
__strtol_internal, then that is your problem.


> the original call, but still optimize the rest of the code? I have tried
> -fno-bultin but it didn't help.
>

Try -fno-inline which will leave atoi as it is but also leave other
functions not inlined.

Muthu



> Anders
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Optimization problem
  2003-05-20 12:40 Optimization problem Anders Ådland
@ 2003-05-20 13:26 ` Nathan Sidwell
  2003-05-20 16:23 ` Muthukumar Ratty
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Sidwell @ 2003-05-20 13:26 UTC (permalink / raw)
  To: Anders Ådland; +Cc: gcc-help

Anders Ã…dland wrote:
> My call to the library function atoi() is converted to a
> __strtol_internal function call when compiling with -O1 or higher. This
> is a GNU C library call, which I don't have. How can I tell GCC to use
> the original call, but still optimize the rest of the code? I have tried
> -fno-bultin but it didn't help.
Are you sure that conversion isn't happening in the preprocessor?
The gcc source doesn't contain the string 'strtol_internal'.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Optimization problem
@ 2003-05-20 12:40 Anders Ådland
  2003-05-20 13:26 ` Nathan Sidwell
  2003-05-20 16:23 ` Muthukumar Ratty
  0 siblings, 2 replies; 4+ messages in thread
From: Anders Ådland @ 2003-05-20 12:40 UTC (permalink / raw)
  To: gcc-help

My call to the library function atoi() is converted to a
__strtol_internal function call when compiling with -O1 or higher. This
is a GNU C library call, which I don't have. How can I tell GCC to use
the original call, but still optimize the rest of the code? I have tried
-fno-bultin but it didn't help.

Anders



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-05-20 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-03 23:31 Optimization Problem hideto-o
2003-05-20 12:40 Optimization problem Anders Ådland
2003-05-20 13:26 ` Nathan Sidwell
2003-05-20 16:23 ` Muthukumar Ratty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).