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]

Re: patch to alias.c checked in


On Friday 19 January 2001 23:59, Franz Sirl wrote:
> On Friday 19 January 2001 14:09, Bernd Schmidt wrote:
> > I have no access to a ppc system right now.  You should probably post the
> > .i file unless the problem is already fixed.
>
> Here is the .i.

I finally found time to analyze that, it's really caused by your patch to
init_alias_analysis, this part to be exact:

                  else if (REG_N_SETS (regno) == 1
                           && GET_CODE (src) == PLUS
                           && GET_CODE (XEXP (src, 0)) == REG
                           && REGNO (XEXP (src, 0)) >= FIRST_PSEUDO_REGISTER
                           && (reg_known_value[REGNO (XEXP (src, 0))])
                           && GET_CODE (XEXP (src, 1)) == CONST_INT)
                    {
                      rtx op0 = XEXP (src, 0);
                      if (reg_known_value[REGNO (op0)])
                        op0 = reg_known_value[REGNO (op0)];
                      reg_known_value[regno]
                        = plus_constant_for_output (op0,
                                                    INTVAL (XEXP (src, 1)));
                      reg_known_equiv_p[regno] = 0;
                    }

If I comment out this part everything is OK again.

Now some more details, if you compile the .i with -O2 for ppc-linux-gnu with
a good and a bad  compiler, there will be eg. this diff in the .sched dump:

@@ -2800,78 +2793,74 @@
 ;;   new head = 3310
 ;;   new tail = 3311
 
 ;;   ======================================================
 ;;   -- basic block 84 from 3314 to 4902 -- before reload
 ;;   ======================================================
 
 
 ;;     Ready list (t =  0):    4902  4874  4872  3400  3380  3321  3314
 
 ;;     Ready list (t =  1):    4902  4874  4872  3400  3380  3333
 
 ;;     Ready list (t =  2):    4902  4874  4872  3400
 
 ;;     Ready list (t =  3):    4902  4874  3335
 
 ;;     Ready list (t =  4):    4902  3338
 
 ;;     Ready list (t =  5):    4885  3353  3344
 
-;;     Ready list (t =  6):    4885  3383  3355  3346
-
-;;     Ready list (t =  7):    4885  3383  3348
+;;     Ready list (t =  6):    4885  3355  3383  3346
 
-;;     Ready list (t =  8):    4885  3388  3371
+;;     Ready list (t =  7):    4885  3355  3388  3348
 
-;;     Ready list (t =  9):    4885  3390
+;;     Ready list (t =  8):    4885  3355  3390  3396  3371
 
-;;     Ready list (t = 10):    4887  4873  3375
+;;     Ready list (t =  9):    4873  4885  3355  3396
 
-;;     Ready list (t = 11):    4887  3377
+;;     Ready list (t = 10):    4873  4885  3375
 
-;;     Ready list (t = 12):    3396
+;;     Ready list (t = 11):    4887  4873  3377
 
-;;     Ready list (t = 14):    3397
+;;     Ready list (t = 12):    4887  3397
 ;;     Ready list (final):
 ;;   ==================== scheduling visualization
 ;;   clock     lsu                                iu                                 iu2                                iu2                                imuldiv                            bpu                                no-unit
 ;;   =====     ==============================     ==============================     ==============================     ==============================     ==============================     ==============================     =======
 ;;   0         3314 [r110+r1269]=r1270            ------------------------------     3321 r1276=r1268+0x10              ------------------------------     ------------------------------     ------------------------------
 ;;   1         3333 r1282=[r110+r1276]            ------------------------------     3380 r113=r113+0x1                 ------------------------------     ------------------------------     ------------------------------
 ;;   2         ------------------------------     ------------------------------     3400 r115=0x0                      4872 r1317=high(`@empty_wstr')     ------------------------------     ------------------------------
 ;;   3         ------------------------------     ------------------------------     3335 %3=r1282                      4874 r1738=r1666                   ------------------------------     ------------------------------
 ;;   4         ------------------------------     ------------------------------     3338 r1283=%3                      4902 r1794=r85+0x330               ------------------------------     ------------------------------
 ;;   5         ------------------------------     ------------------------------     3344 r1286=r1283<<0x2              3353 r1289=r114<<0x2               ------------------------------     ------------------------------
-;;   6         ------------------------------     ------------------------------     3346 r1287=r1286+0x4               3355 r1290=r1289+0x4               ------------------------------     ------------------------------
-;;   7         3348 [r1785+r1276]=r1287           ------------------------------     3383 r114=r114+0x1                 ------------------------------     ------------------------------     ------------------------------
-;;   8         3371 r1298=[r1666+r1289]           ------------------------------     3388 r1302=r114<<0x2               ------------------------------     ------------------------------     ------------------------------
-;;   9         ------------------------------     ------------------------------     3390 r1303=r1302+0x4               4885 r1792=r113<<0x3               ------------------------------     ------------------------------
-;;   10        ------------------------------     ------------------------------     3375 r1300=r1298+r1287             4873 r1334=r1303                   ------------------------------     ------------------------------
-;;   11        3377 [r1666+r1290]=r1300           ------------------------------     4887 r1790=r1792+0x10              ------------------------------     ------------------------------     ------------------------------
-;;   12        3396 r1306=[r1666+r1302]           ------------------------------     ------------------------------     ------------------------------     ------------------------------     ------------------------------
-;;       .
-;;   14        3397 [r1666+r1303]=r1306           ------------------------------     ------------------------------     ------------------------------     ------------------------------     ------------------------------
+;;   6         ------------------------------     ------------------------------     3346 r1287=r1286+0x4               3383 r114=r114+0x1                 ------------------------------     ------------------------------
+;;   7         3348 [r1785+r1276]=r1287           ------------------------------     3388 r1302=r114<<0x2               ------------------------------     ------------------------------     ------------------------------
+;;   8         3371 r1298=[r1666+r1289]           ------------------------------     3390 r1303=r1302+0x4               ------------------------------     ------------------------------     ------------------------------
+;;   9         3396 r1306=[r1666+r1302]           ------------------------------     3355 r1290=r1289+0x4               ------------------------------     ------------------------------     ------------------------------
+;;   10        ------------------------------     ------------------------------     3375 r1300=r1298+r1287             4885 r1792=r113<<0x3               ------------------------------     ------------------------------
+;;   11        3377 [r1666+r1290]=r1300           ------------------------------     4873 r1334=r1303                   ------------------------------     ------------------------------     ------------------------------
+;;   12        3397 [r1666+r1303]=r1306           ------------------------------     4887 r1790=r1792+0x10              ------------------------------     ------------------------------     ------------------------------
 
-;;   total time = 14
+;;   total time = 12

The interesting registers here are r114, r1289, r1290, r1302, r1303 and the memory
indexed by them.

good compiler:
3353 r1289=r114<<2
3355 r1290=r1289+0x4 (==(r114<<2)+0x4)
3383 r114=r114+1
3388 r1302=r114<<2  (this means that r1302 is equal to r1290 now)
3390 r1303=r1302+0x4 (==(r114<<2)+0x4)
3371 r1298=[r1666+r1289]
3377 [r1666+r1290]=r1300
3396 r1306=[r1666+r1302]
3397 [r1666+r1303]=r1306

bad compiler:
3353 r1289=r114<<2
3355 r1290=r1289+0x4 (==(r114<<2)+0x4)
3383 r114=r114+1
3388 r1302=r114<<2  (this means that r1302 is equal to r1290 now)
3390 r1303=r1302+0x4 (==(r114<<2)+0x4)
3371 r1298=[r1666+r1289]
3396 r1306=[r1666+r1302]
3377 [r1666+r1290]=r1300
3397 [r1666+r1303]=r1306

Note how insn 3396 and 3377 have been exchanged. Since r1666+r1290 points to
the same memory location as r1666+r1302, this means that this location is first
written then read in the "good" case, but first read then written in the "bad" case.

I'm not quite sure about the reason for the bug, is your change too aggressive
or does it uncover a bug in the *_dependence routines in alias.c? Or maybe even
glibc's ld-time.c is not aliasing safe?

BTW, during debugging I let open_dump_file set a global variable for the
current pass index and conditionalized your patch with
"compiler_pass_index != DFI_sched" to rule out the exact call to
init_alias_analysis causing the problem. Would such a global variable and the
move of the DFI_* enum to toplev.h be accepted as an additional debugging helper?

Franz.


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