Bug 38495 - [4.4 Regression] ACATS tests cxa4004 cxa4005 cxa4026 fail
Summary: [4.4 Regression] ACATS tests cxa4004 cxa4005 cxa4026 fail
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.4.0
: P1 major
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ra, wrong-code
Depends on:
Blocks:
 
Reported: 2008-12-11 22:44 UTC by Chris Proctor
Modified: 2009-01-09 17:58 UTC (History)
5 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-12-11 23:18:44


Attachments
Reduced testcase (782 bytes, text/plain)
2008-12-17 17:19 UTC, Eric Botcazou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Proctor 2008-12-11 22:44:03 UTC
The current results of an ACATS run on i686-pc-linux-gnu are as follows:

make: Entering directory `/home/chrisp/build/gcc'
                === acats configuration ===
target gcc is /home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/
Reading specs from /home/chrisp/build/gcc/specs Target: i686-pc-linux-gnu Configured with: /usr/src/gcc/configure --prefix=/opt/test --exec-prefix=/opt/test/i86 --enable-shared --enable-threads=posix --enable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,ada --enable-libada Thread model: posix gcc version 4.4.0 20081211 (experimental) [trunk revision 142692] (GCC)
host=i386-redhat-linux
target=i686-pc-linux-gnu
gnatmake is /home/chrisp/build/gcc/gnatmake

                === acats support ===
Generating support files... done.
Compiling support files... done.

                === acats tests ===
Running chapter a ...
Running chapter c2 ...
Running chapter c3 ...
Running chapter c4 ...
Running chapter c5 ...
Running chapter c6 ...
Running chapter c7 ...
Running chapter c8 ...
Running chapter c9 ...
Running chapter ca ...
Running chapter cb ...
Running chapter cc ...
Running chapter cd ...
Running chapter ce ...
Running chapter cxa ...
FAIL:   cxa4004
FAIL:   cxa4005
FAIL:   cxa4026
Running chapter cxb ...
Running chapter cxf ...
Running chapter cxg ...
Running chapter cxh ...
Running chapter cz ...
Running chapter d ...
Running chapter e ...
Running chapter gcc ...
Running chapter l ...
                === acats Summary ===
# of expected passes            2312
# of unexpected failures        3
*** FAILURES: cxa4004 cxa4005 cxa4026 

The detailed results are:

splitting /home/chrisp/build/gcc/testsuite/ada/acats/tests/cxa/cxa4004.a into:
   cxa4004.adb
BUILD cxa4004.adb
gnatmake --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/" -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4004.adb -largs --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/"
/home/chrisp/build/gcc/xgcc -c -B/home/chrisp/build/gcc/ -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4004.adb
gnatbind -I/home/chrisp/build/gcc/testsuite/ada/acats/support -x cxa4004.ali
gnatlink cxa4004.ali --GCC=/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/
RUN cxa4004

,.,. CXA4004 ACATS 2.5 08-12-12 09:16:03
---- CXA4004 Check that the subprograms defined in package
                Ada.Strings.Fixed are available, and that they produce
                correct results.
   * CXA4004 Incorrect result from Move with Justify = Center-1.
   * CXA4004 Incorrect result from Move with Justify = Center-2.
**** CXA4004 FAILED ****************************.
/usr/src/gcc/gcc/testsuite/ada/acats/run_all.sh: line 15: 15883 Segmentation fault      $*
FAIL:   cxa4004

splitting /home/chrisp/build/gcc/testsuite/ada/acats/tests/cxa/cxa4005.a into:
   cxa4005.adb
BUILD cxa4005.adb
gnatmake --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/" -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4005.adb -largs --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/"
/home/chrisp/build/gcc/xgcc -c -B/home/chrisp/build/gcc/ -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4005.adb
gnatbind -I/home/chrisp/build/gcc/testsuite/ada/acats/support -x cxa4005.ali
gnatlink cxa4005.ali --GCC=/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/
RUN cxa4005

,.,. CXA4005 ACATS 2.5 08-12-12 09:16:04
---- CXA4005 Check that the subprograms defined in package
                Ada.Strings.Fixed are available, and that they produce
                correct results.
   * CXA4005 Incorrect result, Replace_Slice - Justify=Center - 1.
   * CXA4005 Incorrect result from Replace_Slice with Justify = Center -
                2.
   * CXA4005 Incorrect result from Delete - Justify = Center.
   * CXA4005 Incorrect result from Trim with Justify = Center.
**** CXA4005 FAILED ****************************.
/usr/src/gcc/gcc/testsuite/ada/acats/run_all.sh: line 15: 15921 Segmentation fault      $*
FAIL:   cxa4005

splitting /home/chrisp/build/gcc/testsuite/ada/acats/tests/cxa/cxa4026.a into:
   cxa4026_0.ads
   cxa4026_0.adb
   cxa4026.adb
BUILD cxa4026.adb
gnatmake --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/" -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4026.adb -largs --GCC="/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/"
/home/chrisp/build/gcc/xgcc -c -B/home/chrisp/build/gcc/ -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4026.adb
/home/chrisp/build/gcc/xgcc -c -B/home/chrisp/build/gcc/ -gnatws -O2 -I/home/chrisp/build/gcc/testsuite/ada/acats/support cxa4026_0.adb
gnatbind -I/home/chrisp/build/gcc/testsuite/ada/acats/support -x cxa4026.ali
gnatlink cxa4026.ali --GCC=/home/chrisp/build/gcc/xgcc -B/home/chrisp/build/gcc/
RUN cxa4026

,.,. CXA4026 ACATS 2.5 08-12-12 09:16:30
---- CXA4026 Check that procedures Trim, Head, and Tail, as well as the
                versions of subprograms Translate, Index, and Count,
                which use the Character_Mapping_Function input
                parameter,produce correct results.
   * CXA4026 Incorrect result from Procedure Trim, trim side = right,
                justify = center, default pad.
   * CXA4026 Incorrect result from Procedure Trim, trim side = both,
                default justify, pad = *.
   * CXA4026 Incorrect result from Procedure Head, justify = center, pad
                = $.
   * CXA4026 Incorrect result from Procedure Head, justify = right,
                default pad.
   * CXA4026 Incorrect result from Procedure Tail, justify = center, pad
                = a.
   * CXA4026 Incorrect result from Procedure Tail, justify = right,
                default pad.
   * CXA4026 Incorrect result from Procedure Tail, justify = right, pad
                = A.
**** CXA4026 FAILED ****************************.
FAIL:   cxa4026


These 3 failures started occurring after the changes made in r142207.  None of the other changes made to correct fallout from this change have affect this.
It appears none of the regression testers enable Ada, it is a shame it is not enabled by default.

This is a regression from  4.3 and from earlier in the head.
Comment 2 Eric Botcazou 2008-12-17 17:15:50 UTC
a-strfix.adb is miscompiled at -O2 -gnatp on i686 (not i586).
Comment 3 Eric Botcazou 2008-12-17 17:19:11 UTC
Created attachment 16917 [details]
Reduced testcase

To be gnatchop-ed and compiled at -O2 -gnatp -mtune=i686.
Comment 4 Eric Botcazou 2008-12-17 17:35:32 UTC
Vlad, I'd again need your help for this one, it's apparently a stack slot
sharing problem.  Ada testcase and instructions have been filed.

The problematic excerpt of assembly is:

	movl	%esi, -28(%ebp)	#, %sfp        -28(%ebp) <--- tfirst_fpad
	subl	$1, %esi	#, q__move__B_4__L_5__T90b___U
	cmpl	%esi, %eax	# q__move__B_4__L_5__T90b___U, i
	jg	.L53	#,
	movzbl	-57(%ebp), %ebx	# %sfp,
	movl	-36(%ebp), %esi	# %sfp,
	movb	%bl, (%esi)	#,
	je	.L53	#,
	leal	1(%eax), %ebx	#,
	addl	$1, %esi	#, ivtmp.268
	movl	%ecx, -52(%ebp)	# j, %sfp
	movl	%ebx, %ecx	#, ivtmp.266
	movzbl	-57(%ebp), %ebx	# %sfp,
	movl	%edi, -48(%ebp)	# prephitmp.345, %sfp
	movl	-28(%ebp), %edi	# %sfp, tfirst_fpad
	movl	%eax, -44(%ebp)	# i, %sfp
	movl	%esi, %eax	# ivtmp.268, ivtmp.268
	movl	%edx, %esi	# tlast.59, tlast.59
	movb	%bl, -40(%ebp)	#, %sfp
	movl	-64(%ebp), %ebx	# %sfp, source
	movzbl	-40(%ebp), %edx	# %sfp, pad
	.p2align 4,,7
	.p2align 3
.L54:
	addl	$1, %ecx	#, ivtmp.266
	movb	%dl, (%eax)	# pad,* ivtmp.268
	addl	$1, %eax	#, ivtmp.268
	cmpl	%edi, %ecx	# tfirst_fpad, ivtmp.266
	jne	.L54	#,
	movb	%dl, -28(%ebp)	# pad, %sfp      -28(%ebp) <--- pad
	movl	-48(%ebp), %edi	# %sfp, prephitmp.345
	movl	%esi, %edx	# tlast.59, tlast.59
	movl	%ebx, -64(%ebp)	# source, %sfp
	movzbl	-28(%ebp), %ebx	# %sfp,
	movl	-52(%ebp), %ecx	# %sfp, j
	movl	-44(%ebp), %eax	# %sfp, i
	movb	%bl, -57(%ebp)	#, %sfp
.L53:
	movl	-28(%ebp), %esi	# %sfp,      -28(%ebp) ---> tfirst_fpad

The shared slot is -28(%ebp) and the second line with the <--- overwrites the
value written by the first <--- line, which is needed by the ---> line.

If you change the second line to make it use -57(%ebp), with proper reloading
a few lines below, the test passes.


The problematic insn is

insn 1086 1085 1087 127 (set (mem/c:QI (plus:SI (reg/f:SI 6 bp)
                (const_int -28 [0xffffffe4])) [13 %sfp+-4 S1 A32])
        (reg/v:QI 1 dx [orig:192 pad ] [192])) 50 {*movqi_1} (nil))

which originally was

(insn 1086 0 0 (set (reg/v:QI 452 [orig:192 pad ] [192])
        (reg/v:QI 344 [orig:192 pad ] [192])) -1 (nil))

so the problematic pseudo seems to be 452:

scanning new insn with uid = 1082.
      Creating newreg=452 from oldreg=192
    Creating temporary allocno a379r452

and I'm under the impression that it's wrongly coalesced to pseudo 275:

      Coalescing spilled allocnos a379r452->a39r275
Comment 5 Vladimir Makarov 2008-12-19 23:30:48 UTC
Eric, thanks for analysis.  It saved a lot of my time.

The problem was in wrong final live ranges of a379r452 therefore the conflicts was not recognized and the pseudos were coalesced.  One pseudo is a temporary pseudo used for breaking register shuffle cycle (it is actually a rare case) on a CFG edge (loop exit).  And another pseudo is destination of removed store insn on the loop exit.  In normal case it should not conflict with the temporary pseudo because the temporary lives only on the edge and another pseudo lives only after the edge destination.  But it should conflict with the temporary in this case because we removed the store and another pseudo lives through all loop.  The suspicious code looks like 

  EXECUTE_IF_SET_IN_BITMAP (live_through, FIRST_PSEUDO_REGISTER, regno, bi)
    {
      a = node->regno_allocno_map[regno];
      if (ALLOCNO_MEM_OPTIMIZED_DEST (a) == NULL)
        {
          ALLOCNO_LIVE_RANGES (a)
            = ira_create_allocno_live_range (a, start, ira_max_point - 1,
                                             ALLOCNO_LIVE_RANGES (a));
          if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
            fprintf
              (ira_dump_file,
               "    Adding range [%d..%d] to live through allocno a%dr%d\n",
               start, ira_max_point - 1, ALLOCNO_NUM (a),
               REGNO (ALLOCNO_REG (a)));
        }

I'll send a patch solving the problem after its testing.
Comment 6 H.J. Lu 2008-12-21 15:14:18 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2008-12/msg01094.html
Comment 7 Vladimir Makarov 2009-01-09 17:52:16 UTC
Subject: Bug 38495

Author: vmakarov
Date: Fri Jan  9 17:52:03 2009
New Revision: 143214

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143214
Log:
2008-01-09  Vladimir Makarov  <vmakarov@redhat.com>

	PR rtl-optimization/38495
	* ira-emit.c (print_move_list, ira_debug_move_list): New
	functions.
	(add_range_and_copies_from_move_list): Print all added ranges.
	Add ranges to memory optimized destination.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ira-emit.c

Comment 8 Jakub Jelinek 2009-01-09 17:58:47 UTC
Fixed.