From patchwork Mon Nov 11 20:10:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 290482 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4AA942C0386 for ; Tue, 12 Nov 2013 07:10:37 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=LEFrAs4DrIiAXJJ2LEADHF63tZHO4iPC5O82htwMOqO ZZSQp7gWppd5T6xS2AhmuqOrkw7tkdcjsjcVfWaX7wRfOb9tyUBE06uKbqEYvHiz UHhTCFPH5GqHc753ddZ5WnfXvaTeGe+rZs6M4J64WhKIoitR2IOHClfwJs/OWdDY = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=xG2n/RzXYuP5Q3TWZUrJNdBxQRc=; b=NC0zcco++aBWPMV91 mRs2UzEfggxs1XTOHyK2UqB7I5pF7TILF6uXrZaOK/V2j18TJDfPa4cTQLZn/q8T 0bWtKzlTbirrvQHUnYOTgicFeBBtVPZTiqARPtlKPKebmshmOjaO6Kv+9AWqREO1 p5YtZBQpg4hw8F87asBgFxpMaM= Received: (qmail 9551 invoked by alias); 11 Nov 2013 20:10:28 -0000 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 Received: (qmail 9527 invoked by uid 89); 11 Nov 2013 20:10:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_40, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-oa0-f52.google.com Received: from Unknown (HELO mail-oa0-f52.google.com) (209.85.219.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 11 Nov 2013 20:10:27 +0000 Received: by mail-oa0-f52.google.com with SMTP id o6so1657835oag.11 for ; Mon, 11 Nov 2013 12:10:19 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.116.230 with SMTP id jz6mr27428388oeb.21.1384200619412; Mon, 11 Nov 2013 12:10:19 -0800 (PST) Received: by 10.182.137.136 with HTTP; Mon, 11 Nov 2013 12:10:19 -0800 (PST) Date: Mon, 11 Nov 2013 21:10:19 +0100 Message-ID: Subject: [PATCH, i38]: Fix PR58853, ICE in expand_set_or_movmem_prologue_epilogue_by_misaligned_moves From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Cc: Jan Hubicka , "H.J. Lu" Hello! Attached patch fixes a typo in ix86_expand_set_or_movmem, where a wrong define was used in a condition. The patch also adds additional condition (as proposed by H.J.) as a correctness improvement (although patched gcc bootstraps and regression tests OK without). I took the liberty to rename a couple of (long) constants and to fix some typos while there. 2013-11-11 Uros Bizjak H.J. Lu PR target/58853 * config/i386/x86-tune.def (X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Rename from TARGET_MISALIGNED_MOVE_STRING_PROLOGUES. * config/i386/i386.h (TARGET_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Rename from TARGET_MISALIGNED_MOVE_STRING_PROLOGUES_EPILOGUES. Update for renamed X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES. * config/i386/i386.c (ix86_expand_set_or_movmem): Use TARGET_MISALIGNED_MOVE_STRING_PRO_EPILOGUES to calculate misaligned_prologue_used. Check that desired_aling <= epilogue_size_needed. testsuite/ChangeLog: 2013-11-11 Uros Bizjak PR target/58853 * gcc.target/i386/pr58853.c: New test. Patch was approved by Honza in the PR. Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 204676) +++ config/i386/i386.c (working copy) @@ -23761,13 +23761,15 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx c } gcc_assert (desired_align >= 1 && align >= 1); - /* Misaligned move sequences handles both prologues and epilogues at once. - Default code generation results in smaller code for large alignments and - also avoids redundant job when sizes are known precisely. */ - misaligned_prologue_used = (TARGET_MISALIGNED_MOVE_STRING_PROLOGUES - && MAX (desired_align, epilogue_size_needed) <= 32 - && ((desired_align > align && !align_bytes) - || (!count && epilogue_size_needed > 1))); + /* Misaligned move sequences handle both prologue and epilogue at once. + Default code generation results in a smaller code for large alignments + and also avoids redundant job when sizes are known precisely. */ + misaligned_prologue_used + = (TARGET_MISALIGNED_MOVE_STRING_PRO_EPILOGUES + && MAX (desired_align, epilogue_size_needed) <= 32 + && desired_align <= epilogue_size_needed + && ((desired_align > align && !align_bytes) + || (!count && epilogue_size_needed > 1))); /* Do the cheap promotion to allow better CSE across the main loop and epilogue (ie one load of the big constant in the Index: config/i386/i386.h =================================================================== --- config/i386/i386.h (revision 204676) +++ config/i386/i386.h (working copy) @@ -353,8 +353,8 @@ extern unsigned char ix86_tune_features[X86_TUNE_L #define TARGET_PROMOTE_QImode ix86_tune_features[X86_TUNE_PROMOTE_QIMODE] #define TARGET_FAST_PREFIX ix86_tune_features[X86_TUNE_FAST_PREFIX] #define TARGET_SINGLE_STRINGOP ix86_tune_features[X86_TUNE_SINGLE_STRINGOP] -#define TARGET_MISALIGNED_MOVE_STRING_PROLOGUES_EPILOGUES \ - ix86_tune_features[TARGET_MISALIGNED_MOVE_STRING_PROLOGUES] +#define TARGET_MISALIGNED_MOVE_STRING_PRO_EPILOGUES \ + ix86_tune_features[X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES] #define TARGET_QIMODE_MATH ix86_tune_features[X86_TUNE_QIMODE_MATH] #define TARGET_HIMODE_MATH ix86_tune_features[X86_TUNE_HIMODE_MATH] #define TARGET_PROMOTE_QI_REGS ix86_tune_features[X86_TUNE_PROMOTE_QI_REGS] Index: config/i386/x86-tune.def =================================================================== --- config/i386/x86-tune.def (revision 204676) +++ config/i386/x86-tune.def (working copy) @@ -257,13 +257,13 @@ DEF_TUNE (X86_TUNE_AVOID_MEM_OPND_FOR_CMOVE, "avoi as MOVS and STOS (without a REP prefix) to move/set sequences of bytes. */ DEF_TUNE (X86_TUNE_SINGLE_STRINGOP, "single_stringop", m_386 | m_P4_NOCONA) -/* TARGET_MISALIGNED_MOVE_STRING_PROLOGUES: Enable generation of compace - prologues and epilogues by issuing a misaligned moves. This require - target to handle misaligned moves and partial memory stalls resonably - well. - FIXME: This actualy may be a win on more targets than listed here. */ -DEF_TUNE (TARGET_MISALIGNED_MOVE_STRING_PROLOGUES, - "misaligned_move_string_prologues", +/* X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES: Enable generation of + compact prologues and epilogues by issuing a misaligned moves. This + requires target to handle misaligned moves and partial memory stalls + reasonably well. + FIXME: This may actualy be a win on more targets than listed here. */ +DEF_TUNE (X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES, + "misaligned_move_string_pro_epilogues", m_386 | m_486 | m_CORE_ALL | m_AMD_MULTIPLE | m_GENERIC) /* X86_TUNE_USE_SAHF: Controls use of SAHF. */ Index: testsuite/gcc.target/i386/pr58853.c =================================================================== --- testsuite/gcc.target/i386/pr58853.c (revision 0) +++ testsuite/gcc.target/i386/pr58853.c (working copy) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-minline-all-stringops" } */ +/* { dg-additional-options "-mtune=pentiumpro" { target { ia32 } } } */ + +void +my_memcpy (char *dest, const char *src, int n) +{ + __builtin_memcpy (dest, src, n); +}