This is the mail archive of the gcc-patches@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]

Re: [PATCH] SSA expand: Convert mode when copying between partition base vars


Hi Michael,

Rather try this one. It fixes the cris issue (and perhaps the sparc thingy too), which is also about promoting PARM_DECLs.

This does only have an effect on partitions which do not contain the default definition of the variable. expand_used_vars does not invoke expand_one_var for a PARM_DECL as long as the respective bit in the partition_has_default_def bitmap is set.


And anyway I don't see how this prevents the problem which I'm seeing on S/390 where a parameter is copied to a local variable:

int
foo (int a)
{
  int w = a;
  if (a < 0)
    w = -(unsigned int) a;
  return w;
}

The problem is the partition copy which will be introduced between partition 0 and 1. The local variable 'w' is SImode while 'a' has been promoted to DImode:

From t.c.129r.expand (I've attached the complete file):

...
Partition map

Partition 0 (w_1 - 1 6 )
Partition 1 (a_2(D) - 2 )
Partition 2 (a.0_4 - 4 )
Partition 3 (D.1223_5 - 5 )


Replacing Expressions a.0_4 replace with --> a.0_4 = (unsigned int) a_2(D);

D.1223_5 replace with --> D.1223_5 = -a.0_4;


foo (int a) { int w; unsigned int D.1223; unsigned int a.0;

  # BLOCK 2 freq:10000
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (a_2(D) < 0)
    goto <bb 3>;
  else
    goto <bb 4>;
  # SUCC: 3 [36.6%]  (true,exec) 4 [63.4%]  (false,exec)

  # BLOCK 3 freq:3665
  # PRED: 2 [36.6%]  (true,exec)
  a.0_4 = (unsigned int) a_2(D);
  D.1223_5 = -a.0_4;
  w_6 = (int) D.1223_5;
  # SUCC: 4 [100.0%]  (fallthru,exec)

  # BLOCK 4 freq:10000
  # PRED: 2 [63.4%]  (false,exec) 3 [100.0%]  (fallthru,exec)
  # w_1 = PHI <a_2(D)(2), w_6(3)>
  return w_1;
  # SUCC: EXIT [100.0%]

}


Inserting a partition copy on edge BB2->BB4 :PART.0 = PART.1


Bye,

-Andreas-
;; Function foo (foo)

foo (int a)
{
  int w;
  unsigned int D.1223;
  unsigned int a.0;

  # BLOCK 2 freq:10000
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (a_2(D) < 0)
    goto <bb 3>;
  else
    goto <bb 4>;
  # SUCC: 3 [36.6%]  (true,exec) 4 [63.4%]  (false,exec)

  # BLOCK 3 freq:3665
  # PRED: 2 [36.6%]  (true,exec)
  a.0_4 = (unsigned int) a_2(D);
  D.1223_5 = -a.0_4;
  w_6 = (int) D.1223_5;
  # SUCC: 4 [100.0%]  (fallthru,exec)

  # BLOCK 4 freq:10000
  # PRED: 2 [63.4%]  (false,exec) 3 [100.0%]  (fallthru,exec)
  # w_1 = PHI <a_2(D)(2), w_6(3)>
  return w_1;
  # SUCC: EXIT [100.0%] 

}



Partition map 

Partition 1 (w_1 - 1 )
Partition 2 (a_2(D) - 2 )
Partition 4 (a.0_4 - 4 )
Partition 5 (D.1223_5 - 5 )
Partition 6 (w_6 - 6 )


Partition map 

Partition 0 (w_1 - 1 )
Partition 1 (a_2(D) - 2 )
Partition 2 (w_6 - 6 )


Live on entry to BB2 : a_2(D)  

Live on entry to BB3 : a_2(D)  

Live on entry to BB4 : 

Conflict graph:

After sorting:
Sorted Coalesce list:
(3665) w_1 <-> w_6

Partition map 

Partition 0 (w_1 - 1 )
Partition 1 (a_2(D) - 2 )
Partition 2 (w_6 - 6 )

Coalesce list: (1)w_1 & (6)w_6 [map: 0, 2] : Success -> 0
After Coalescing:

Partition map 

Partition 0 (w_1 - 1 6 )
Partition 1 (a_2(D) - 2 )
Partition 2 (a.0_4 - 4 )
Partition 3 (D.1223_5 - 5 )


Replacing Expressions
a.0_4 replace with --> a.0_4 = (unsigned int) a_2(D);

D.1223_5 replace with --> D.1223_5 = -a.0_4;


foo (int a)
{
  int w;
  unsigned int D.1223;
  unsigned int a.0;

  # BLOCK 2 freq:10000
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (a_2(D) < 0)
    goto <bb 3>;
  else
    goto <bb 4>;
  # SUCC: 3 [36.6%]  (true,exec) 4 [63.4%]  (false,exec)

  # BLOCK 3 freq:3665
  # PRED: 2 [36.6%]  (true,exec)
  a.0_4 = (unsigned int) a_2(D);
  D.1223_5 = -a.0_4;
  w_6 = (int) D.1223_5;
  # SUCC: 4 [100.0%]  (fallthru,exec)

  # BLOCK 4 freq:10000
  # PRED: 2 [63.4%]  (false,exec) 3 [100.0%]  (fallthru,exec)
  # w_1 = PHI <a_2(D)(2), w_6(3)>
  return w_1;
  # SUCC: EXIT [100.0%] 

}


Inserting a partition copy on edge BB2->BB4 :PART.0 = PART.1

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