From patchwork Mon May 13 17:24:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 243466 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 3D7222C008F for ; Tue, 14 May 2013 03:24:42 +1000 (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:content-type; q= dns; s=default; b=DEnXIcGPAkl9QP332aRzdkLxWAfu/vAJ0PqafHVi6UThJT bxeCQC13tF31RSFV/JDVLNTID26jqBvnA52T1Oqp+HOEmwgL2fhw5CAmtHyfV7AJ YUbSwB9Ip7P59+MzZWh0zd0idUXfKEq3A+AKZEyvJq6yuKkQxX2pNGrCfygZs= 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:content-type; s= default; bh=thk0GgRJytw3lm9V/tRXN7QCSuM=; b=a15ulrHeE/6vc8AmqNsA IMllRdl6Ec2IiyDCDuX78Irh0Qy0p/RKD/Dn1YGl+JEILYBI/RmmwC4qmQMgTSEZ 1pL/lme9UiKdvqaU28NLVAkXJOMJEmVCqqse0NSMnU78IAN+hA1rTXsh1i22sd+f qBo3s2tDShtTthODR9/Pg4E= Received: (qmail 4400 invoked by alias); 13 May 2013 17:24:36 -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 4390 invoked by uid 89); 13 May 2013 17:24:35 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS, TW_ZJ autolearn=ham version=3.3.1 Received: from mail-da0-f54.google.com (HELO mail-da0-f54.google.com) (209.85.210.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 13 May 2013 17:24:34 +0000 Received: by mail-da0-f54.google.com with SMTP id z17so570152dal.41 for ; Mon, 13 May 2013 10:24:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.66.155.138 with SMTP id vw10mr6476356pab.91.1368465873319; Mon, 13 May 2013 10:24:33 -0700 (PDT) Received: by 10.70.10.34 with HTTP; Mon, 13 May 2013 10:24:33 -0700 (PDT) Date: Mon, 13 May 2013 19:24:33 +0200 Message-ID: Subject: [4.7 PATCH, i386]: Fix PR57264, cld not emitted when string instructions used, and '-mcld' on command line From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" X-Virus-Found: No Hello! This PR again exposes the problem when STOS instruction is generated from the combine pass. The insn is not generated from corresponding expander, so ix86_current_function_needs_cld flag never gets set. Consequently, the CLD insn is not emitted in the prologue. The problematic combination is prevented by Jakub's PR55686 patch in 4.8+ branches, so attached patch backports it to 4.7 branch. 2013-05-13 Uros Bizjak PR target/57264 Backport from mainline 2013-01-22 Jakub Jelinek PR target/55686 * config/i386/i386.md (UNSPEC_STOS): New. (strset_singleop, *strsetdi_rex_1, *strsetsi_1, *strsethi_1, *strsetqi_1): Add UNSPEC_STOS. testsuite/ChangeLog: 2013-05-13 Uros Bizjak PR target/57264 * gcc.target/i386/pr57264.c: New test. Patch was tested on x86_64-pc-linux-gnu {-m32} on 4.7 branch, and committed to 4.7 branch. The testcase will be forward ported to 4.8 and mainline SVN. Uros. Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 198835) +++ config/i386/i386.md (working copy) @@ -109,6 +109,7 @@ UNSPEC_CALL_NEEDS_VZEROUPPER UNSPEC_PAUSE UNSPEC_LEA_ADDR + UNSPEC_STOS ;; For SSE/MMX support: UNSPEC_FIX_NOTRUNC @@ -15912,7 +15913,8 @@ [(parallel [(set (match_operand 1 "memory_operand" "") (match_operand 2 "register_operand" "")) (set (match_operand 0 "register_operand" "") - (match_operand 3 "" ""))])] + (match_operand 3 "" "")) + (unspec [(const_int 0)] UNSPEC_STOS)])] "" "ix86_current_function_needs_cld = 1;") @@ -15921,7 +15923,8 @@ (match_operand:DI 2 "register_operand" "a")) (set (match_operand:DI 0 "register_operand" "=D") (plus:DI (match_dup 1) - (const_int 8)))] + (const_int 8))) + (unspec [(const_int 0)] UNSPEC_STOS)] "TARGET_64BIT && !(fixed_regs[AX_REG] || fixed_regs[DI_REG])" "stosq" @@ -15934,7 +15937,8 @@ (match_operand:SI 2 "register_operand" "a")) (set (match_operand:P 0 "register_operand" "=D") (plus:P (match_dup 1) - (const_int 4)))] + (const_int 4))) + (unspec [(const_int 0)] UNSPEC_STOS)] "!(fixed_regs[AX_REG] || fixed_regs[DI_REG])" "stos{l|d}" [(set_attr "type" "str") @@ -15946,7 +15950,8 @@ (match_operand:HI 2 "register_operand" "a")) (set (match_operand:P 0 "register_operand" "=D") (plus:P (match_dup 1) - (const_int 2)))] + (const_int 2))) + (unspec [(const_int 0)] UNSPEC_STOS)] "!(fixed_regs[AX_REG] || fixed_regs[DI_REG])" "stosw" [(set_attr "type" "str") @@ -15958,7 +15963,8 @@ (match_operand:QI 2 "register_operand" "a")) (set (match_operand:P 0 "register_operand" "=D") (plus:P (match_dup 1) - (const_int 1)))] + (const_int 1))) + (unspec [(const_int 0)] UNSPEC_STOS)] "!(fixed_regs[AX_REG] || fixed_regs[DI_REG])" "stosb" [(set_attr "type" "str") Index: testsuite/gcc.target/i386/pr57264.c =================================================================== --- testsuite/gcc.target/i386/pr57264.c (revision 0) +++ testsuite/gcc.target/i386/pr57264.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -mcld" } */ + +void test (int x, int **pp) +{ + while (x) + { + int *ip = *pp; + int *op = *pp; + while (*ip) + { + int v = *ip++; + *op++ = v + 1; + } + } +} + +/* { dg-final { scan-assembler-not "stosl" } } */