Bug 63156 - web can't handle AUTOINC correctly
Summary: web can't handle AUTOINC correctly
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-03 17:06 UTC by Carrot
Modified: 2021-03-31 20:48 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-09-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carrot 2014-09-03 17:06:01 UTC
Check out the latest trunk, apply the following patch to move web before IRA

Index: passes.def
===================================================================
--- passes.def	(revision 214881)
+++ passes.def	(working copy)
@@ -364,7 +364,6 @@
 	  NEXT_PASS (pass_rtl_loop_done);
 	  TERMINATE_PASS_LIST ()
       POP_INSERT_PASSES ()
-      NEXT_PASS (pass_web);
       NEXT_PASS (pass_rtl_cprop);
       NEXT_PASS (pass_cse2);
       NEXT_PASS (pass_rtl_dse1);
@@ -385,6 +384,7 @@
       NEXT_PASS (pass_sms);
       NEXT_PASS (pass_live_range_shrinkage);
       NEXT_PASS (pass_sched);
+      NEXT_PASS (pass_web);
       NEXT_PASS (pass_ira);
       NEXT_PASS (pass_reload);
       NEXT_PASS (pass_postreload);

Build an arm gcc, run following test

make check-gcc RUNTESTFLAGS="--target_board=arm-sim/arch=armv5te/thumb execute.exp=20000422-1.c"

You can see all tests pass. But if I enable the web pass,

make check-gcc RUNTESTFLAGS="--target_board=arm-sim/arch=armv5te/thumb/-fweb execute.exp=20000422-1.c"

I got one run time failure. The problem is web renamed the operand of post_inc in following insn, which should not occurred.

(insn 34 122 36 2 (set (reg:SI 137 [ D.4191 ])
        (mem/c:SI (post_inc:SI (reg/f:SI 156)) [2 num+0 S4 A32])) /usr/local/google/home/carrot/ssd/trunk3/gcc/testsuite/gcc.c-torture/execute/20000422-1.c:17 740 {*thumb1_movsi_insn}
     (expr_list:REG_INC (reg/f:SI 156)
        (expr_list:REG_EQUAL (mem/c:SI (symbol_ref:SI ("*.LANCHOR0") [flags 0x182]) [2 num+0 S4 A32])
            (nil))))
Comment 1 David Edelsohn 2014-09-03 17:14:54 UTC
Confirmed.
Comment 2 Steven Bosscher 2014-09-03 22:03:13 UTC
I am unable to reproduce this:

Test Run By stevenb on Wed Sep  3 14:56:17 2014
Target is arm-unknown-eabi
Host   is powerpc64-unknown-linux-gnu

                === gcc tests ===

Schedule of variations:
    arm-sim/-march=armv5te/-mthumb/-fweb

Running target arm-sim/-march=armv5te/-mthumb/-fweb
Running /home/stevenb/devel/combined/gcc/testsuite/gcc.c-torture/execute/execute.exp ...
PASS: gcc.c-torture/execute/20000422-1.c   -O0  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O0  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O1  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O1  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O2  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O2  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer -funroll-loops  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -g  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -O3 -g  execution test
PASS: gcc.c-torture/execute/20000422-1.c   -Os  (test for excess errors)
PASS: gcc.c-torture/execute/20000422-1.c   -Os  execution test

                === gcc Summary ===

# of expected passes            16
/home/stevenb/devel/build-arm/gcc/xgcc  version 5.0.0 20140903 (experimental) [trunk revision 214887] (GCC)


What is your command line for configure?
Comment 3 Carrot 2014-09-03 23:41:36 UTC
../trunk3/configure '--build=x86_64-build_unknown-linux-gnu' '--host=x86_64-build_unknown-linux-gnu' '--target=arm-unknown-linux-gnueabi' '--prefix=/usr/local/google/home/carrot/x-tools/arm-unknown-linux-gnueabi' '--with-sysroot=/usr/local/google/home/carrot/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot' '--with-float=soft' '--with-pkgversion=crosstool-NG 1.19.0' '--disable-sjlj-exceptions' '--enable-__cxa_atexit' '--disable-libmudflap' '--disable-libgomp' '--disable-libssp' '--disable-libquadmath' '--disable-libquadmath-support' '--with-gmp=/usr/local/google/home/carrot/crosstool-ng/work1/.build/arm-unknown-linux-gnueabi/buildtools' '--with-mpfr=/usr/local/google/home/carrot/crosstool-ng/work1/.build/arm-unknown-linux-gnueabi/buildtools' '--with-mpc=/usr/local/google/home/carrot/crosstool-ng/work1/.build/arm-unknown-linux-gnueabi/buildtools' '--with-ppl=no' '--with-isl=no' '--with-cloog=no' '--with-libelf=no' '--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' '--enable-threads=posix' '--enable-target-optspace' '--disable-nls' '--disable-multilib' '--with-local-prefix=/usr/local/google/home/carrot/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot' '--enable-c99' '--enable-long-long' '--disable-libitm' 'build_alias=x86_64-build_unknown-linux-gnu' 'host_alias=x86_64-build_unknown-linux-gnu' 'target_alias=arm-unknown-linux-gnueabi' '--disable-libasan' '--disable-libsanitizer' '--enable-languages=c,c++,lto'
Comment 4 Carrot 2014-09-04 03:24:28 UTC
In function df_uses_record, we have:

    ...
    case PRE_DEC:
    case POST_DEC:
    case PRE_INC:
    case POST_INC:
    case PRE_MODIFY:
    case POST_MODIFY:
      gcc_assert (!DEBUG_INSN_P (insn_info->insn));
      /* Catch the def of the register being modified.  */
      df_ref_record (DF_REF_REGULAR, collection_rec, XEXP (x, 0), &XEXP (x, 0),
                     bb, insn_info,
                     DF_REF_REG_DEF,
                     flags | DF_REF_READ_WRITE | DF_REF_PRE_POST_MODIFY);

      /* ... Fall through to handle uses ...  */

    default:
      break;
    }    

  /* Recursively scan the operands of this expression.  */
  {
    const char *fmt = GET_RTX_FORMAT (code);
    int i;

    for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) 
      {    
        if (fmt[i] == 'e') 
          {
            /* Tail recursive case: save a function call level.  */
            if (i == 0)
              {    
                loc = &XEXP (x, 0);
                goto retry;
              }    
            df_uses_record (collection_rec, &XEXP (x, i), ref_type,
                            bb, insn_info, flags);
          }
        ...


For a AUTOINC rtl expression, we create two refs, one def and one use, but only the def gets the flag DF_REF_READ_WRITE, the use doesn't have this flag.

While in web_main, it checks only use refs, but the use ref doesn't have the flag DF_REF_READ_WRITE, so it can't actually catch the AUTOINC cases, and does wrong renaming.
Comment 5 Steven Bosscher 2014-09-04 08:24:31 UTC
(In reply to Carrot from comment #4)
> For a AUTOINC rtl expression, we create two refs, one def and one use, but
> only the def gets the flag DF_REF_READ_WRITE, the use doesn't have this flag.

Then this is fall-out of PR32339.
Comment 6 Carrot 2014-09-04 15:51:23 UTC
(In reply to Steven Bosscher from comment #5)
> (In reply to Carrot from comment #4)
> > For a AUTOINC rtl expression, we create two refs, one def and one use, but
> > only the def gets the flag DF_REF_READ_WRITE, the use doesn't have this flag.
> 
> Then this is fall-out of PR32339.

Since it is intentionally to remove flag DF_REF_READ_WRITE on use, in web_main we should also check all defs with flag DF_REF_READ_WRITE, union it with corresponding use.
Comment 7 Steven Bosscher 2014-09-05 22:14:28 UTC
(In reply to Carrot from comment #6)
> Since it is intentionally to remove flag DF_REF_READ_WRITE on use,

Ah, but I don't think that was the correct fix. The DEF and USE refs should
both have the flag set.
Comment 8 Carrot 2014-09-07 02:45:39 UTC
(In reply to Steven Bosscher from comment #7)
> (In reply to Carrot from comment #6)
> > Since it is intentionally to remove flag DF_REF_READ_WRITE on use,
> 
> Ah, but I don't think that was the correct fix. The DEF and USE refs should
> both have the flag set.

I agree it's more reasonable to set DF_REF_READ_WRITE flag on both use and def, it means we need to revert r125736 and reopen bug 32339.
Comment 9 Carrot 2014-09-09 21:47:26 UTC
The original flag setting code is neither correct. Consider following pre_modify expression:

(pre_modify (r1)                // def1, use1
            (plus (r1)          // use2
                  (r2)))        // use3

GCC will generate 4 df_ref information for this expression as noted, 1 def and 3 use. Current code only set DF_REF_READ_WRITE for def1, this causes web do wrong renaming. The original flag setting code will set DF_REF_READ_WRITE for all def/use in this expression, this is obviously wrong for r2. 

I don't know if this has any relations to bug 32339.
Comment 10 Eric Gallager 2018-07-06 04:19:51 UTC
(In reply to Carrot from comment #9)
> 
> I don't know if this has any relations to bug 32339.

Worth putting under "See Also" anyways just in case
Comment 11 Eric Gallager 2018-10-06 03:37:27 UTC
(In reply to Steven Bosscher from comment #7)
> (In reply to Carrot from comment #6)
> > Since it is intentionally to remove flag DF_REF_READ_WRITE on use,
> 
> Ah, but I don't think that was the correct fix. The DEF and USE refs should
> both have the flag set.

Are you still working on this?
Comment 12 Eric Gallager 2019-01-06 05:01:19 UTC
(In reply to Eric Gallager from comment #11)
> (In reply to Steven Bosscher from comment #7)
> > (In reply to Carrot from comment #6)
> > > Since it is intentionally to remove flag DF_REF_READ_WRITE on use,
> > 
> > Ah, but I don't think that was the correct fix. The DEF and USE refs should
> > both have the flag set.
> 
> Are you still working on this?

Guess not; unassigning and moving to cc