This is the mail archive of the 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: [RFA] expand from SSA form (1/2)


On Wed, 29 Apr 2009, Andreas Krebbel wrote:

> > Your original one, or the amended one (for AIX)?  I'm asking because I
> > noticed a problem when fiddling with the AIX problem.  Your change to
> > insert_value_copy_on_edge might not work in all cases as you're doing the
> > expand_expr outside of a start_sequence.  I decided to simply not use the
> > helper function as I had to also change the code to use convert_modes.
> > 
> > It shouldn't expose itself as an RTL sharing problem, but it definitely
> > might have undesired effects.  Unfortunately our s390 is off today, so I
> > can't help without a testcase.
> I've tested the modified version from your last posting 
> ( A already 
> debugged a problem caused by my insert_value_copy_on_edge change - an 
> infinite loop due to a miscompile of do_add in real.c arrgh.

The machine is online again, so I had a look.  cprop creates this sharing, 
but it seems it's a preexisting bug (no idea why it didn't trigger 

The problem happens in this insn:

(insn 26 25 27 7 ../../../gcc/libgomp/config/linux/affinity.c:82 
(set (reg:DI 65 [ cpu+-4 ])
  (ior:DI (ashift:DI (zero_extend:DI (truncate:SI (mod:DI (reg:DI 65 [ cpu+-4 ])
            (sign_extend:DI (reg:SI 66 [ gomp_cpu_affinity_len ] )))))
           (const_int 32 [0x20]))
          (zero_extend:DI (truncate:SI
           (div:DI (reg:DI 65 [ cpu+-4 ])
                    (sign_extend:DI (reg:SI 66 [ gomp_cpu_affinity_len ]))))))) 352 {divmoddisi3}
  (expr_list:REG_EQUAL (ior:DI (ashift:DI (zero_extend:DI (umod:SI (reg:SI 61)
                        (mem/c/i:SI (plus:SI (reg:SI 12 %r12)
                                (reg:SI 64)) [7 gomp_cpu_affinity_len+0 S4 A32])))
                (const_int 32 [0x20]))
          (zero_extend:DI (udiv:SI (reg:SI 61)
            (mem/c/i:SI (plus:SI (reg:SI 12 %r12)
              (reg:SI 64)) [7 gomp_cpu_affinity_len+0 S4 A32]))))

pseudo 64 is the interesting one.  Note how it only occurs in the 
REG_EQUAL not, but it occurs twice.  try_replace_reg won't find anything 
to substitute in the PATTERN itself, but it unconditionally wants to 
replace occurences also in the notes:

  if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)
    set_unique_reg_note (insn, REG_EQUAL,
                         simplify_replace_rtx (XEXP (note, 0), from,
                         copy_rtx (to)));

Now, simplify_replace_rtx doesn't do any unsharing, and apply_change_group 
doesn't work for notes.  So reg 64 is replaced by this:

    (const:SI (unspec:SI [
                (symbol_ref:SI ("gomp_cpu_affinity_len") [flags 0x42]
                 <var_decl0x40938540 gomp_cpu_affinity_len>)
            ] 112))

Voila, RTL sharing in the note.  We need to unshare explicitely when using 
simplify_replace_rtx() when we can't be sure that FROM only occurs once, 
or TO is sharable.  Like the patch below.  It lets me build libgomp on 

On this basis I'm checking in our combined patch fixing the AIX problem.  
I'd be grateful for any further testing of this patch for the RTL sharing 
problem, I have not bootstrapped it on s390.

	* gcse.c (try_replace_reg): Unshare RTL when substituting into

--- gcse.c	2009-04-29 14:34:41.000000000 +0200
+++ /suse/matz/gcse.c	2009-04-29 19:19:44.833381000 +0200
@@ -2272,9 +2272,14 @@ try_replace_reg (rtx from, rtx to, rtx i
   /* If there is already a REG_EQUAL note, update the expression in it
      with our replacement.  */
   if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)
-    set_unique_reg_note (insn, REG_EQUAL,
-			 simplify_replace_rtx (XEXP (note, 0), from,
-			 copy_rtx (to)));
+    {
+      rtx x = XEXP (note, 0);
+      x = simplify_replace_rtx (x, from, copy_rtx (to));
+      reset_used_flags (x);
+      x = copy_rtx_if_shared (x);
+      set_unique_reg_note (insn, REG_EQUAL, x);
+    }
   if (!success && set && reg_mentioned_p (from, SET_SRC (set)))
       /* If above failed and this is a single set, try to simplify the source of

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