From patchwork Wed Dec 7 11:59:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 129946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6C49E1007D1 for ; Wed, 7 Dec 2011 23:00:30 +1100 (EST) Received: (qmail 10953 invoked by alias); 7 Dec 2011 12:00:28 -0000 Received: (qmail 10943 invoked by uid 22791); 7 Dec 2011 12:00:27 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Dec 2011 12:00:12 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by smtp.strato.de (jimi mo35) (RZmta 26.10 AUTH) with ESMTPA id a046fbnB7B6uNV ; Wed, 7 Dec 2011 12:59:54 +0100 (MET) Message-ID: <4EDF553A.5040404@gjlay.de> Date: Wed, 07 Dec 2011 12:59:54 +0100 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Mike Stump Subject: [testsuite]: Move pr45830.c to gcc.dg/torture and make it pass for AVR X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org In principle, test case pr45830.c works for target avr, but there is an issue with the -ftree-switch-conversion optimization activated at higher optimization levels: It transforms code size into .data usage and thus exceeds AVRs' RAM size because of big CSWTCH lookup tables located in RAM. The patch moves the test case from gcc.c-torture/execute/ to more modern gcc.dg/torture and adds magic dg-comments as needed. Patch lightly tested with my avr-tools. Ok for trunk? Johann PR tree-optimization/45830 * gcc.c-torture/execute/pr45830.c: Move file from here to... * gcc.dg/torture/pr45830.c: ...here. Add dg-do and dg-additional-options magic. Index: gcc.c-torture/execute/pr45830.c =================================================================== --- gcc.c-torture/execute/pr45830.c (revision 182043) +++ gcc.c-torture/execute/pr45830.c (working copy) @@ -1,97 +0,0 @@ -/* PR tree-optimization/45830 */ - -extern void abort (void); - -long long va, vb, vc, vd, ve; - -__attribute__((noinline)) int -foo (int x) -{ - long long a, b, c, d, e; - switch (x) - { - case 0: - case 3: - case 1: - case 2: - case 4: - a = 1; - b = 129; - c = -12; - d = -4; - e = 128; - break; - case 23: - case 26: - case 19: - case 65: - case 5: - a = 2; - b = 138; - c = 115; - d = 128; - e = -16; - break; - case 21: - case 20: - case 22: - case 38: - case 27: - case 66: - case 45: - case 47: - a = 3; - b = 6; - c = 127; - d = 25; - e = 257; - break; - default: - a = 0; - b = 18; - c = 0; - d = 64; - e = 32768L; - break; - } - va = a; - vb = b; - vc = c; - vd = d; - ve = e; -} - -int -bar (int x) -{ - if (x < 0) - return 3; - if (x < 5) - return 0; - if (x == 5 || x == 19 || x == 23 | x == 26 || x == 65) - return 1; - if ((x >= 20 && x <= 22) || x == 27 || x == 38 - || x == 45 || x == 47 || x == 66) - return 2; - return 3; -} - -long long expected[] = -{ 1, 129, -12, -4, 128, 2, 138, 115, 128, -16, - 3, 6, 127, 25, 257, 0, 18, 0, 64, 32768L }; - -int -main (void) -{ - int i, v; - for (i = -4; i < 70; i++) - { - foo (i); - v = bar (i); - if (va != expected[5 * v] || vb != expected[5 * v + 1] - || vc != expected[5 * v + 2] || vd != expected[5 * v + 3] - || ve != expected[5 * v + 4]) - abort (); - } - return 0; -} Index: gcc.dg/torture/pr45830.c =================================================================== --- gcc.dg/torture/pr45830.c (revision 182043) +++ gcc.dg/torture/pr45830.c (working copy) @@ -1,4 +1,6 @@ /* PR tree-optimization/45830 */ +/* { dg-do run } */ +/* { dg-additional-options "-fno-tree-switch-conversion" { target avr-*-* } } */ extern void abort (void);