question about the constraint modifier '+'

2012-04-04 Thread Handong Ye
Hi, I'm new in gcc, and maybe misunderstand the constraint modifier '+'.
As the internal document says, '+' means an inout parameter. In my
mind, it means the instruction both reads and writes the pseudo
register.

Assuming I have a pattern like:

(define_insn "lssu"
   [(set (match_operand:m1 0 ...)
   (unspec:m1 [ (match_operand:SI 1 "register_operand" "+r")
(match_operand:SI 2 ...)] UNSPEC_XXX))]

and I have a sequence of code like

(insn 1  (set (reg:SI 100) (...)))
...
(insn 10 ... (set (reg:m1 200) (unspec:m1 [(reg:SI 100) (...)]
UNSPEC_XXX)) 33 {lssu} (nil))
...
(insn 30 ... (set (reg:SI 300) (reg:SI 100)

Can I expect that pseudo reg 100 in insn 30 has the new value written
by insn 10?

My experiments show that this is not true, and pseudo reg 100 in insn
30 still takes the value in insn 1.
Or maybe something else is wrong in our porting ?

--
Thanks.
Handong


Re: [help]failed to generate PHI NODE in esra pass.

2012-11-04 Thread Handong Ye
On Sun, Nov 4, 2012 at 2:13 PM, Martin Jambor  wrote:
> Hi,
>
> On Sat, Nov 03, 2012 at 09:01:53AM +, Yangyueming wrote:
>> Hi, all
>>
>> I do the research of min max instructions recently. I find it is related 
>> with phiopt.
>>
>> case1:
>> int foo(short a ,short b)
>> {
>>   if (a < b)
>> a = b;
>>   return a;
>> }
>>
>> It is successed in pass phiopt1(-O2 with gcc 4.7.0). The MAX_EXPR can be 
>> generated.
>>
>> foo (short int a, short int b)
>> {
>>   int D.2094;
>>
>> :
>>   a_9 = MAX_EXPR ;
>>   D.2094_5 = (int) a_9;
>>   return D.2094_5;
>>
>> }
>>
>> But when I do the test for a case with a little change, it is failed to 
>> generate MAX_EXPR in phiopt1.
>> The failed case2 :
>> int foo(short a ,short b)
>> {
>>   int c;
>>   if (a < b)
>> a = b;
>>
>>   c = *(int *)&a;
>
> ehm, and just what do you expect the result of the above line to be?
>
>>   return c;
>> }
>>
>> I find it is because of the esra pass failed to generate PHI NODE.
>
> First and foremost, esra only deals with aggregate types and nothing
> in any of your examples is an aggregate, therefore esra does not touch
> your examples in any way.  Even though the a$0 temporary has a dollar
> sign in it, that does not mean it is created by SRA.  On my i686
> desktop the temporary is called a.0 and it is generated because in
> gimple all scalar loads and stores have to go through a variable in
> SSA form.
>
> Nevertheless, I can tell why there is no phi node for a. a has its
> address taken and therefore it is not in SSA form (as clearly visible
> in the first statements in bb 2 and bb 3).  Thus, no PHI nodes for a.
>

Why 'a' has no SSA form if it's address taken?
I didn't check the code, but I guess it may because 'a' value is not
directly used.

>> Dump of phifail.c.027t.esra:
>> foo (short int a, short int b)
>> {
>>   int c;
>>   short int a$0;
>>
>> :
>>   a$0_1 = a;
>>   if (a$0_1 < b_2(D))
>> goto ;
>>   else
>> goto ;
>>
>> :
>>   a = b_2(D);
>>
>> :
>>   c_4 = MEM[(int *)&a];
>>   c_5 = c_4;
>>   return c_5;
>>
>> }
>>
>> Why it is failed and if there's a way to make it work?
>
> I believe that the modified input has undefined semantics (sorry, I
> don't have time to verify this in the standard) and so no, there is no
> way to make it work.
>
> Martin



-- 
Thanks.
Handong


Re: [help]failed to generate PHI NODE in esra pass.

2012-11-05 Thread Handong Ye
On Mon, Nov 5, 2012 at 5:32 AM, Martin Jambor  wrote:
> Hi,
>
> On Sun, Nov 04, 2012 at 09:32:48PM -0800, Handong Ye wrote:
>> On Sun, Nov 4, 2012 at 2:13 PM, Martin Jambor  wrote:
>> > On Sat, Nov 03, 2012 at 09:01:53AM +, Yangyueming wrote:
>> >> Hi, all
>> >>
>
> ...
>
>> >>
>> >> But when I do the test for a case with a little change, it is failed to 
>> >> generate MAX_EXPR in phiopt1.
>> >> The failed case2 :
>> >> int foo(short a ,short b)
>> >> {
>> >>   int c;
>> >>   if (a < b)
>> >> a = b;
>> >>
>> >>   c = *(int *)&a;
>> >
>> > ehm, and just what do you expect the result of the above line to be?
>> >
>> >>   return c;
>> >> }
>> >>
>
> ...
>
>> >
>> > Nevertheless, I can tell why there is no phi node for a. a has its
>> > address taken and therefore it is not in SSA form (as clearly visible
>> > in the first statements in bb 2 and bb 3).  Thus, no PHI nodes for a.
>> >
>>
>> Why 'a' has no SSA form if it's address taken?
>> I didn't check the code, but I guess it may because 'a' value is not
>> directly used.
>
> Because address taken variables might be used and defined indirectly
> through a memory load/store, often in ways that are practically
> impossible to detect.

Isn't memory ssa supposed to handle such issues? ...
Seems I need do some research ...

Thanks
Handong

>
> Martin
>
>
>>
>> >> Dump of phifail.c.027t.esra:
>> >> foo (short int a, short int b)
>> >> {
>> >>   int c;
>> >>   short int a$0;
>> >>
>> >> :
>> >>   a$0_1 = a;
>> >>   if (a$0_1 < b_2(D))
>> >> goto ;
>> >>   else
>> >> goto ;
>> >>
>> >> :
>> >>   a = b_2(D);
>> >>
>> >> :
>> >>   c_4 = MEM[(int *)&a];
>> >>   c_5 = c_4;
>> >>   return c_5;
>> >>
>> >> }
>> >>
>> >> Why it is failed and if there's a way to make it work?
>> >
>> > I believe that the modified input has undefined semantics (sorry, I
>> > don't have time to verify this in the standard) and so no, there is no
>> > way to make it work.
>> >
>> > Martin
>>
>>
>>
>> --
>> Thanks.
>> Handong



-- 
Thanks.
Handong