Re: build: are there situations where 'ar' does not work?

2010-08-23 Thread Andi Kleen
Ralf Wildenhues  writes:

> Now, to avoid issues when GCC uses newer Libtool: are there situations
> where running $AR does not work?  Cross compile?  In-tree binutils?

It doesn't work when you use LTO without gold/linker-plugin.

-Andi

-- 
a...@linux.intel.com -- Speaking for myself only.


A question about MAX_EXPR

2010-08-23 Thread Revital1 Eres

Hello,

I'm compiling the following test with GCC 4.6.0 and I do not see that
MAX_EXPR is generated for (num)<0)?0:(num).
With GCC 4.3.2 it is generated OK in original dump (both compilation were
made with -O3).  Is there a flag I should use to generate MAX_EXPR
with GCC 4.6.0?

Thanks,
Revital

#define TEST(num) (unsigned char)(((num)>0xFF)?0xff:(((num)<0)?0:(num)))

int foo(const unsigned char *tmp, int i, int val)
{
return TEST(tmp[i] + val);
}



Matching Constraints and Predicate

2010-08-23 Thread Paulo J. Matos
Hello,

I am quite confused with the following from the internals:
; Operand predicates can allow operands that are not actually
; acceptable to the hardware, as long as the constraints give
; reload the ability to fix them up (see Constraints). However,
; GCC will usually generate better code if the predicates specify
; the requirements of the machine instructions as closely as
; possible. Reload cannot fix up operands that must be
; constants (immediate operands); you must use a predicate that
; allows only constants, or else enforce the requirement in the
; extra condition.

This seems to imply that if the predicates specify the same
requirements of constraints, then resulting code if better.

However, if I have register constraints that define constraint x to
match a certain register class X and I define predicate:
(define_predicate "x_operand"
(and (match_operand 0 "register_operand")
 (match_test "REGNO_REG_CLASS(REGNO(op)) == X")))

and then I have a match_operand on an insn (match_operand 0
"x_operand" "x") this is quite disastrous as gcc promptly stops since
any pseudo-register during will fail the predicate and no rule will
not be matched.
It feels like I should say in the predicate something like: it's
either a pseudo, or a register from X.

What am I misinterpreting?

Cheers,

-- 
PMatos


Re: A question about MAX_EXPR

2010-08-23 Thread Jakub Jelinek
On Mon, Aug 23, 2010 at 02:46:21PM +0300, Revital1 Eres wrote:
> I'm compiling the following test with GCC 4.6.0 and I do not see that
> MAX_EXPR is generated for (num)<0)?0:(num).
> With GCC 4.3.2 it is generated OK in original dump (both compilation were
> made with -O3).  Is there a flag I should use to generate MAX_EXPR
> with GCC 4.6.0?
> 
> Thanks,
> Revital
> 
> #define TEST(num) (unsigned char)(((num)>0xFF)?0xff:(((num)<0)?0:(num)))
> 
> int foo(const unsigned char *tmp, int i, int val)
> {
> return TEST(tmp[i] + val);
> }

There are two issues here:
1) the (completely unnecessary here) narrowing cast to unsigned char
   This prevents fold_cond_expr_with_comparison from being called, as
   the arguments aren't equal.  One is
   ((int)tmp[i]) + val, the other is tmp[i] + (unsigned char)val.
   Unfortunately even fold_converting the comparison operand
   to (unsigned char) doesn't yield something that would be
   operand_equal_for_comparison_p.
2) without the unnecessary cast, MAX_EXPR is generated, but MIN_EXPR
   around it is not.  The problem is that the argument is not the same,
   (it is the same as TREE_OPERAND (max_expr, 0)).

Jakub


get "stack smasshing" for code that uses pointers passed as references.

2010-08-23 Thread Wendell Nichols

I have some code that passes pointers like:

int foo( int a,char *& word){
...
}

If that function modifies the actual pointer word (indexes it for 
instance) I will get a stack smashing error at runtime.  The code runs 
perfectly if I set -fno-stack-protector.


Is this feature intended to work properly with references?
wcn


symbol redefined errors

2010-08-23 Thread Kartik.Vashishta
We are getting the following errors, this happened when we moved from a
legacy system where everything worked to a newer system. The compiler
was reinstalled on the newer system and all files were copied. Any help
will be appreciated.

Qsms using gcc compiler
QSMS COMPILER - VERSION v7.8 (/usr/qtime/qc/v7.8)

Adding compiler options: "-D ISSPIF=0"
Gener version v7.8.11 - Copyright (c) 1986-2004 SPSS Ltd. All rights
reserved.
Gener processed 54 files,
3 files from current directory,
24 files from /usr/qtime/qc/v7.8/sms/mfi/mfi7.1,
13 files from /usr/qtime/qc/v7.8/sms/qts/include,
14 files from /usr/qtime/qc/v7.8/sms/standard/include.
Using ANSI C compilation
.In file included from /usr/include/curses.h:23,
 from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.3/include/curses.h:5,
 from /usr/qtime/qc/v7.8/sms/src/supervisor.c:13:
/usr/include/widec.h:38: warning: `getwc' redefined
/usr/include/iso/wchar_iso.h:186: warning: this is the location of the
previous definition
/usr/include/widec.h:39: warning: `putwc' redefined
/usr/include/iso/wchar_iso.h:189: warning: this is the location of the
previous definition
/usr/include/widec.h:40: warning: `getwchar' redefined
/usr/include/iso/wchar_iso.h:187: warning: this is the location of the
previous definition
/usr/include/widec.h:41: warning: `putwchar' redefined
/usr/include/iso/wchar_iso.h:190: warning: this is the location of the
previous definition
...


Re: Add uninitialized attribute?

2010-08-23 Thread Richard Guenther
On Sat, Aug 21, 2010 at 11:43 AM, Florian Weimer  wrote:
> * H. J. Lu:
>
>> Sometime I have to do
>>
>> int x = 0;
>>
>> to silence gcc from uninitialized warnings when I know it is
>> unnecessary.
>
> I guess the official idiom is
>
>  int x = x;

That's what I thought as well, so I am confused.

> and it is somewhat used in the GNU project although it is not
> portable.

Neither is any of the other suggestions.

Richard.


Re: build: are there situations where 'ar' does not work?

2010-08-23 Thread Richard Guenther
On Mon, Aug 23, 2010 at 12:43 PM, Andi Kleen  wrote:
> Ralf Wildenhues  writes:
>
>> Now, to avoid issues when GCC uses newer Libtool: are there situations
>> where running $AR does not work?  Cross compile?  In-tree binutils?
>
> It doesn't work when you use LTO without gold/linker-plugin.

Sure it does.  Just the created archive will not be considered for LTO
optimization.

Richard.

> -Andi
>
> --
> a...@linux.intel.com -- Speaking for myself only.
>


Re: get "stack smasshing" for code that uses pointers passed as references.

2010-08-23 Thread Florian Weimer
* Wendell Nichols:

> I have some code that passes pointers like:
>
> int foo( int a,char *& word){
> ...
> }
>
> If that function modifies the actual pointer word (indexes it for
> instance) I will get a stack smashing error at runtime.  The code runs
> perfectly if I set -fno-stack-protector.
>
> Is this feature intended to work properly with references?

Yes, it is.  You should try to come up with a minimal example, so that
we can see if it is caused by your code or a compiler bug.


Re: Matching Constraints and Predicate

2010-08-23 Thread Ian Lance Taylor
"Paulo J. Matos"  writes:

> However, if I have register constraints that define constraint x to
> match a certain register class X and I define predicate:
> (define_predicate "x_operand"
> (and (match_operand 0 "register_operand")
>  (match_test "REGNO_REG_CLASS(REGNO(op)) == X")))

As you observe, this is wrong.  A pseudo-register has no register class.
You can only test the register class if you first test that you have a
hard register.

This also makes no sense.  The operand predicate should test whether the
value is acceptable.  The constraints should tell the register allocator
where the value should go.  The paragraph you quoted is saying that the
operand predicate should restrict the value as much as possible to
ensure that the constraints will match.  The paragraph is not saying
that you should test the register class of a register in the operand
predicate.

Ian


Re: symbol redefined errors

2010-08-23 Thread Ian Lance Taylor
 writes:

> We are getting the following errors, this happened when we moved from a
> legacy system where everything worked to a newer system. The compiler
> was reinstalled on the newer system and all files were copied. Any help
> will be appreciated.
>
> Qsms using gcc compiler
> QSMS COMPILER - VERSION v7.8 (/usr/qtime/qc/v7.8)
>
> Adding compiler options: "-D ISSPIF=0"
> Gener version v7.8.11 - Copyright (c) 1986-2004 SPSS Ltd. All rights
> reserved.
> Gener processed 54 files,
> 3 files from current directory,
> 24 files from /usr/qtime/qc/v7.8/sms/mfi/mfi7.1,
> 13 files from /usr/qtime/qc/v7.8/sms/qts/include,
> 14 files from /usr/qtime/qc/v7.8/sms/standard/include.
> Using ANSI C compilation
> .In file included from /usr/include/curses.h:23,
>  from
> /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.3/include/curses.h:5,
>  from /usr/qtime/qc/v7.8/sms/src/supervisor.c:13:
> /usr/include/widec.h:38: warning: `getwc' redefined
> /usr/include/iso/wchar_iso.h:186: warning: this is the location of the
> previous definition
> /usr/include/widec.h:39: warning: `putwc' redefined
> /usr/include/iso/wchar_iso.h:189: warning: this is the location of the
> previous definition
> /usr/include/widec.h:40: warning: `getwchar' redefined
> /usr/include/iso/wchar_iso.h:187: warning: this is the location of the
> previous definition
> /usr/include/widec.h:41: warning: `putwchar' redefined
> /usr/include/iso/wchar_iso.h:190: warning: this is the location of the
> previous definition
> ...

This question is not appropriate for the mailing list gcc@gcc.gnu.org,
which is for gcc development.  It would be appropriate for
gcc-h...@gcc.gnu.org.  Please take any followups to gcc-help.  Thanks.

This does not appear to be a gcc issue as such.  This appears to be a
problem with the header files on your system, specifically the two
header files mentioned above.  They do not appear to be compatible.
Those header files did not come from gcc.  You will have to look at
those header files to find out why they are incompatible.

Ian


Need help in deciding the instruction set for a new target.

2010-08-23 Thread Mohamed Shafi
Hello all,

I am trying to do a port on GCC 4.5. The target has a memory
resolution of 32bits i.e. char is 32bits in the target (addr 0 selects
1st 32bit and addr 1 selects 2nd 32bit). It has only word (32bit)
access.

In terms of address resolution this target is similar to c4x which
became obsolete in GCC 4.2. There are two ways to implement this port.
One is to have BITS_PER_UNIT ==32, like c4x and other is to have a
normal C like char == 8, short == 16, and int == 32. We are thinking
about having BITS_PER_UNIT == 32. Yes I know the support for such a
target is bit rotten in GCC. I am currently trying to removing it.

In the mean time, we are in the process of finalizing the
instructions. The current instruction set has support for 32bit
immediate data only in move operations. i.e.

move src1GP, #imm32

For all other operations like div, sub, add, compare, modulus, load,
store the support is only for 16bit immediate. For all these
instruction there is separate flavor for sign and zero extension. i.e.

mod.s32 srcdstGP, #imm16 // 32%imm16   signed modulus
mod.u32 srcdstGP, #imm16 // 32%imm16 unsigned modulus

cmp.s32 src1GP, #imm16 // signed register to 16-bit immediate compare
cmp.u32 src1GP, #imm16 // unsigned register to 16-bit immediate compare

sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract


I want to know if it is good to have both sign and zero extension for
16bit immediate.
Will it be of any use with a configuration where char == short == int == 32bit?
Will I be able to support these kinds of instructions in a GCC port?
Or will it good to have a separate sign and zero extension
instruction, which the current instruction set doesn’t have.
Do I need a separate sign and zero ext instructions along with the
above instructions?

It would be of great help if you could guide me in deciding these instructions.

Regards,
Shafi


Broken links on main gcc website.

2010-08-23 Thread Gareth Randall

Hi,

In:  http://www.gnu.org/software/gcc/

Broken links in the “Documentation” panel on the right:

http://www.gnu.org/software/gcc/install/ (Empty directory)
http://www.gnu.org/software/gcc/install/specific.html
http://www.gnu.org/software/gcc/install/test.html

Yours,
--
=== Gareth Randall ===


Re: Broken links on gnu website.

2010-08-23 Thread Andrew Pinski
On Mon, Aug 23, 2010 at 11:23 AM, Gareth Randall
 wrote:
> Hi,
>
> In:  http://www.gnu.org/software/gcc/

This is really a mirror of the main gcc.gnu.org project page.

>
> Broken links in the “Documentation” panel on the right:
>
> http://www.gnu.org/software/gcc/install/         (Empty directory)


http://gcc.gnu.org/install/ works so it is a problem with the www.gnu.org page.

Thanks,
Andrew Pinski


Re: Need help in deciding the instruction set for a new target.

2010-08-23 Thread Ian Lance Taylor
Mohamed Shafi  writes:

> I want to know if it is good to have both sign and zero extension for
> 16bit immediate.

Hard to say.  It really depends on the kind of constants you expect your
programs to use.  It's generally a good idea to have an efficient way to
load small constants which many programs use, such as 0, 1, -1.  The
latter implies that you will want sign extending immediate operations.
Whether your programs will benefit from an efficient way to load 0x,
I don't know.

> Will it be of any use with a configuration where char == short == int == 
> 32bit?

Yes, the size of supported immediate constants is really orthogonal to
the size of the data types.  Your programs are certainly going to refer
to numbers like 0, 1, and -1.  Efficient ways of using those constants
will generally pay off, though of course it is a tradeoff like
everything else in architecture design.

> Will I be able to support these kinds of instructions in a GCC port?

Yes.

> Or will it good to have a separate sign and zero extension
> instruction, which the current instruction set doesn’t have.
> Do I need a separate sign and zero ext instructions along with the
> above instructions?

When char is 32 bits, you don't really need sign and zero extension of
unknown values.  So the question is whether you need them for immediate
constants.  As I mention above, it will probably pay off to have
instructions which support sign extending immediate constants.  Whether
that is done via operands to add, etc., or via a load-immediate
instruction, really depends on other characteristics of your
architecture and of the programs you expect to write.

Hope this helps.

Ian


Re: Need help in deciding the instruction set for a new target.

2010-08-23 Thread Bernd Schmidt
On 08/23/2010 08:05 PM, Mohamed Shafi wrote:

> sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
> sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract

If you're using a bit to decide between these two, a better encoding
would be to just support a single instruction with a signed 17bit immediate.


Bernd


Snapshot announcements (was: gcc-4.4-20080725 is now available)

2010-08-23 Thread Gerald Pfeifer
On Sat, 14 Aug 2010, Gerald Pfeifer wrote:
> This is an excellent idea.  I just implemented a change to that
> effect and today's snapshot for GCC 4.6 has this:
>  
>   http://gcc.gnu.org/ml/gcc/2010-08/msg00232.html
> 
> I am not really satisfied about how this looks yet and will tweak
> this a bit over time.

Now also with SHA1 hashes and slightly adjusted, cf
  http://gcc.gnu.org/ml/gcc/2010-08/msg00317.html

Any comments, suggestions, hate mail, let me know.

Gerald


Re: Need help in deciding the instruction set for a new target.

2010-08-23 Thread Richard Henderson
On 08/23/2010 11:05 AM, Mohamed Shafi wrote:
> sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
> sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract

Having both of these is probably not useful.  Bernd pointed
out that a 17-bit constant would be more useful.  I'll point
out that if you have a signed constant then SUB and ADD tend
to be essentially identical as well.

Consider implementing "reverse subtract"

RSUB reg, #imm
as
reg = imm - reg

instead.


r~


Re: Broken links on main gcc website.

2010-08-23 Thread Jonathan Wakely
On 23 August 2010 19:23, Gareth Randall wrote:
> Hi,
>
> In:  http://www.gnu.org/software/gcc/
>
> Broken links in the “Documentation” panel on the right:
>
> http://www.gnu.org/software/gcc/install/         (Empty directory)
> http://www.gnu.org/software/gcc/install/specific.html
> http://www.gnu.org/software/gcc/install/test.html

Thanks for the report.  The main GCC website, where those pages are
copied from, is http://gcc.gnu.org and the links work OK there if
you're looking for the missing pages.


Re: Broken links on main gcc website.

2010-08-23 Thread Gerald Pfeifer
On Mon, 23 Aug 2010, Jonathan Wakely wrote:
>> In:  http://www.gnu.org/software/gcc/
>>
>> Broken links in the “Documentation” panel on the right:
>>
>> http://www.gnu.org/software/gcc/install/         (Empty directory)
>> http://www.gnu.org/software/gcc/install/specific.html
>> http://www.gnu.org/software/gcc/install/test.html
> Thanks for the report.  The main GCC website, where those pages are
> copied from, is http://gcc.gnu.org and the links work OK there if
> you're looking for the missing pages.

Thanks for the report, Gareth.  I'll have a look how we can address
this such that the links work on both sites.

Hmm, looking into this I had in fact designed these links so that they
would work on both sites; someone must have become creative with some
scripting.  I'll reach out to the GNU webmasters...

Gerald