Is the GCC optimazer too smart?

2009-12-10 Thread sergio borghese
Hi All, I just joined the list and I'm not a compiler guru, so I'd like "the list" opinion on a behavior I notice today. Not sure it is really a bug, so do not want to directly open a bug in the bugzilla repository. Consider the below sample code: #include int main(int argc, char** argv) {    

Re: Is the GCC optimizer too smart?

2009-12-10 Thread Paolo Carlini
On 12/10/2009 01:03 PM, sergio borghese wrote: > Now my question is: is it correct that the compiler enforces the > constantness of the variable, even tought it states in the warning > that the const qualifier has been discarded? > I think you are missing that the compiler is not "enforcing" any

Re: Is the GCC optimazer too smart?

2009-12-10 Thread Jonathan Wakely
2009/12/10 sergio borghese: > > Now my question is: is it correct that the compiler enforces the > constantness of the variable, even tought it states in the warning > that the const qualifier has been discarded? the calls to printf can be optimised to printf("i: %dn", 0) so it doesn't use the val

gcc-4.5-20091210 is now available

2009-12-10 Thread gccadmin
Snapshot gcc-4.5-20091210 is now available on ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20091210/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 4.5 SVN branch with the following options: svn://gcc.gnu.org/svn/gcc/trunk

generate RTL sequence

2009-12-10 Thread daniel tian
Hi, I have a problem about RTL sequence. If I wanna generate the RTL in sequence, and don't let gcc to schedule them. Like the following(all the variable is rtx): emit_insn(reg0, operands[0]); emit_insn(reg1, reg0); emit_insn(operands[0], reg1); But gcc will will re

Re: generate RTL sequence

2009-12-10 Thread Ian Lance Taylor
daniel tian writes: > I have a problem about RTL sequence. > If I wanna generate the RTL in sequence, and don't let gcc to schedule > them. > Like the following(all the variable is rtx): > > emit_insn(reg0, operands[0]); > emit_insn(reg1, reg0); > emit_insn(operands[0],

Re: generate RTL sequence

2009-12-10 Thread daniel tian
2009/12/11 Ian Lance Taylor : > daniel tian writes: > >>     I have a problem about RTL sequence. >>     If I wanna generate the RTL in sequence, and don't let gcc to schedule >> them. >>     Like the following(all the variable is rtx): >> >>     emit_insn(reg0,  operands[0]); >>     emit_insn(re

Re: generate RTL sequence

2009-12-10 Thread Jianzhang Peng
I'm tring this function, but it have some problems. It seems not link the new insn in the double-list. void merge(rtx insn1,rtx insn2) { rtx par, pre,sur, insn; par = gen_rtx_PARALLEL (SFmode, rtvec_alloc (2)); XVECEXP (par, 0, 0) = PATTERN(insn1); XVECEXP (par, 0

Re: generate RTL sequence

2009-12-10 Thread Ian Lance Taylor
daniel tian writes: > 2009/12/11 Ian Lance Taylor : >> daniel tian writes: >> >>>     I have a problem about RTL sequence. >>>     If I wanna generate the RTL in sequence, and don't let gcc to schedule >>> them. >>>     Like the following(all the variable is rtx): >>> >>>     emit_insn(reg0,  o

Re: generate RTL sequence

2009-12-10 Thread daniel tian
I think you should do the operation with the functions in emit-rtl.c. Like the functions:add_insn_after, add_insn_before, df_insn_delete. You could try those things. 2009/12/11 Jianzhang Peng : > I'm tring this function, but it have some problems. It seems not link > the new insn in the double-l

Re: generate RTL sequence

2009-12-10 Thread daniel tian
>> Does there any solution in RTL level? >> Because I already solve the problem in ASM output level,  exactly the >> same solution as you suggest in this email. >> I may need do some optimization later. So RTL level will be great! > > As far as I know there is no way to do this at the RTL level.  I

Re: generate RTL sequence

2009-12-10 Thread daniel tian
Ian: By the way, I don't underand the start_sequence and end_sequence. What does those function mean. I checked the source code in emit-rtl.c. I still can't figure out what they do. There is a structure sequence_stack, I don't what it does. Thanks.

identifying indirect references in a loop

2009-12-10 Thread Aravinda
Hi, Im trying to identify all indirect references in a loop so that, after this analysis, I have a list of tree_nodes of pointer_type that are dereferenced in a loop along with their step size, if any. E.g. while(i++ < n) { *(p+i); } I want to get the pointer_type_node for 'p' and identify th

Re: generate RTL sequence

2009-12-10 Thread Ian Lance Taylor
daniel tian writes: > By the way, I don't underand the start_sequence and end_sequence. > What does those function mean. > I checked the source code in emit-rtl.c. > I still can't figure out what they do. > There is a structure sequence_stack, I don't what it does. start_sequence and end_

Re: generate RTL sequence

2009-12-10 Thread Richard Kenner
> > There is a structure sequence_stack, I don't what it does. > > start_sequence and end_sequence are used to group insns into a > specific location when you are generating insns. I quote the comment > in emit-rtl.c: And sequence_stack exists so you can arbitrarily nest insn sequences.

Re: generate RTL sequence

2009-12-10 Thread Joern Rennecke
Quoting daniel tian : Hi, I have a problem about RTL sequence. If I wanna generate the RTL in sequence, and don't let gcc to schedule them. Like the following(all the variable is rtx): emit_insn(reg0, operands[0]); emit_insn(reg1, reg0); emit_insn(operands[0], reg