NetBSD Problem Report #50570

From www@NetBSD.org  Fri Dec 18 18:32:15 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BC0347ACDD
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 18 Dec 2015 18:32:15 +0000 (UTC)
Message-Id: <20151218183214.73D947ACDF@mollari.NetBSD.org>
Date: Fri, 18 Dec 2015 18:32:14 +0000 (UTC)
From: jdbaker@mylinuxisp.com
Reply-To: jdbaker@consolidated.net
To: gnats-bugs@NetBSD.org
Subject: powerpc gcc 4.8.4 4.8.5 -O3 -maltivec internal compiler error
X-Send-Pr-Version: www-1.0

>Number:         50570
>Notify-List:    jdbaker@consolidated.net
>Category:       toolchain
>Synopsis:       powerpc gcc 4.8.4 4.8.5 -O3 -maltivec internal compiler error
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 18 18:35:01 +0000 2015
>Last-Modified:  Tue Jan 29 06:31:55 +0000 2019
>Originator:     John D. Baker
>Release:        NetBSD/macppc-7.99.24
>Organization:
>Environment:
NetBSD sawtooth.technoskunk.fur 7.99.24 NetBSD 7.99.24 (GENERIC) #3: Tue Dec 15 23:53:57 CST 2015  sysop@x3650.technoskunk.fur:/r0/build/current/obj/macppc/sys/arch/macppc/compile/GENERIC macppc
>Description:
First encountered in pkg/49600 and discussed in the thread starting
here:

  http://mail-index.netbsd.org/pkgsrc-users/2015/12/17/msg022725.html

but more properly here:

  http://mail-index.netbsd.org/pkgsrc-users/2015/12/18/msg022733.html

with a test case here:

  http://mail-index.netbsd.org/pkgsrc-users/2015/12/18/msg022740.html

Compiling certain code with both "-O3" and "-maltivec" provokes an
internal compiler error:

$ cc -O3 -maltivec -o avecbug.o avecbug.c 
rs6000_secondary_reload_inner:17198, type = load
(parallel [
        (set (reg:V8HI 82 5)
            (mem:V8HI (and:SI (reg:SI 65 lr [orig:1093 D.2414 ] [1093])
                    (const_int -16 [0xfffffffffffffff0])) [1 MEM[(uint16_t *)_890 & 4294967280B]+0 S16 A128]))
        (clobber (reg:SI 16 16))
    ])
avecbug.c: In function 'vp9_temporal_filter_apply_c':
avecbug.c:46:1: internal compiler error: in rs6000_secondary_reload_fail, at config/rs6000/rs6000.c:16989
 }
 ^
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://www.NetBSD.org/support/send-pr.html> for instructions.

>How-To-Repeat:
Test case--compile with "-O3 -maltivec" using gcc 4.8.4 (7.0) or
gcc 4.8.5 (7.0_STABLE, -current) on any NetBSD powerpc platform.

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

void vp9_temporal_filter_apply_c(uint8_t *frame1,
                                 unsigned int stride,
                                 uint8_t *frame2,
                                 unsigned int block_width,
                                 unsigned int block_height,
                                 int strength,
                                 int filter_weight,
                                 unsigned int *accumulator,
                                 uint16_t *count) {
  unsigned int i, j, k;
  int modifier;
  int byte = 0;
  const int rounding = strength > 0 ? 1 << (strength - 1) : 0;

  for (i = 0, k = 0; i < block_height; i++) {
    for (j = 0; j < block_width; j++, k++) {
      int src_byte = frame1[byte];
      int pixel_value = *frame2++;

      modifier   = src_byte - pixel_value;
      // This is an integer approximation of:
      // float coeff = (3.0 * modifer * modifier) / pow(2, strength);
      // modifier =  (int)roundf(coeff > 16 ? 0 : 16-coeff);
      modifier  *= modifier;
      modifier  *= 3;
      modifier  += rounding;
      modifier >>= strength;

      if (modifier > 16)
        modifier = 16;

      modifier = 16 - modifier;
      modifier *= filter_weight;

      count[k] += modifier;
      accumulator[k] += modifier * pixel_value;

      byte++;
    }

    byte += stride - block_width;
  }
}

>Fix:
Workaround:

omit either one of "-maltivec" or "-O3" (or reduce optimization to "-O2"
or less).

>Release-Note:

>Audit-Trail:
From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/50570: powerpc gcc 4.8.4 4.8.5 -O3 -maltivec internal
 compiler error
Date: Tue, 17 May 2016 23:20:22 -0500 (CDT)

 GCC 5.3.0 (as of 7.99.29 or so) does not exhibit the problem.

 See also pkg/49600.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/50570: powerpc gcc 4.8.4 4.8.5 -O3 -maltivec internal
 compiler error
Date: Tue, 17 May 2016 23:47:38 -0500 (CDT)

 Note that compiling the test program with GCC 5.3.0 should be done as:

   $ cc -O3 -maltivec -c avecbug.c

 Otherwise, it will complain:

   $ cc -O3 -maltivec -o avecbug.o avecbug.c 
   /usr/lib/crt0.o: In function `___start':
   (.text+0x1a4): undefined reference to `main'

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.