From patchwork Thu Jun 21 20:32:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 932936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480226-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="G8wgxFQg"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BYKk3gFLz9s3C for ; Fri, 22 Jun 2018 06:32:41 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; q=dns; s=default; b=a0tWefqWdUMOm4ZTmHH6DqJBKMGlQj0QJE3ko9Pw7a7 Gheaaqkyaiki+eudbZnP5umZlTf1r9AWAXyhlV4PkuOFdg8Jp5OjXAYlmvuVbj1z 8mWVQzzxM16KynJinchrzaZxo2yhl0uC9YRc72J4TH1XTgkflN/acYcVjsH4b8V4 = 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 :subject:from:to:cc:date:content-type:mime-version:message-id; s=default; bh=cglZKZV7+RzVbOs6u8AG8xiOjI4=; b=G8wgxFQgg36B3wKxq k46n7EwQVs6fxHLp4eKl0PUe/bvVueD3NXGbi2Xx/GNjUWfTHjV345FPnf4GoWEh SY5EGQF6XbdJvmAKvy1QwiA9Eit12bjjtweHbvi254LYaURF/23+vNkOFtx3kSfS 0XnkkfzwhxeZf7BGdZ3T/r/w0U= Received: (qmail 65424 invoked by alias); 21 Jun 2018 20:32:34 -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 65406 invoked by uid 89); 21 Jun 2018 20:32:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=get_mode, xexp, voidmode, VOIDmode X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jun 2018 20:32:32 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5LKTWiR088346 for ; Thu, 21 Jun 2018 16:32:30 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jrftuqpfn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 21 Jun 2018 16:32:29 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jun 2018 16:32:29 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 21 Jun 2018 16:32:27 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5LKWQtX9699758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Jun 2018 20:32:26 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBFF9AC05B; Thu, 21 Jun 2018 16:33:40 -0400 (EDT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F1D2AC059; Thu, 21 Jun 2018 16:33:40 -0400 (EDT) Received: from ragesh3a.rchland.ibm.com (unknown [9.10.86.85]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 21 Jun 2018 16:33:40 -0400 (EDT) Subject: [PATCH, rs6000] PR target/86222 fix truncation issue with constants when compiling -m32 From: Aaron Sawdey To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Bill Schmidt Date: Thu, 21 Jun 2018 15:32:25 -0500 Mime-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18062120-0064-0000-0000-0000031EA453 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009234; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01050346; UDB=6.00538272; IPR=6.00829317; MB=3.00021791; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-21 20:32:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062120-0065-0000-0000-000039AC083D Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-21_09:, , signatures=0 X-IsSubscribed: yes expand_strn_compare was not using gen_int_mode or trunc_int_for_mode to properly truncate to Pmode when creating contants in the generate rtx. This lead to an improper constant and the ICE in PR/86222. Testing on ppc64 with -m32, -m32 -mpowerpc64 and -m64. If regstrap passes, ok for trunk and backport to 8? Thanks, Aaron 2018-06-19 Aaron Sawdey * config/rs6000/rs6000-string.c (expand_strn_compare): Handle -m32 correctly. Index: gcc/config/rs6000/rs6000-string.c =================================================================== --- gcc/config/rs6000/rs6000-string.c (revision 261850) +++ gcc/config/rs6000/rs6000-string.c (working copy) @@ -1925,20 +1925,15 @@ /* -m32 -mpowerpc64 results in word_mode being DImode even though otherwise it is 32-bit. The length arg to strncmp is a size_t which will be the same size as pointers. */ - rtx len_rtx; - if (TARGET_64BIT) - len_rtx = gen_reg_rtx (DImode); - else - len_rtx = gen_reg_rtx (SImode); + rtx len_rtx = gen_reg_rtx (Pmode); + emit_move_insn (len_rtx, gen_int_mode (bytes, Pmode)); - emit_move_insn (len_rtx, bytes_rtx); - tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP); emit_library_call_value (XEXP (DECL_RTL (fun), 0), target, LCT_NORMAL, GET_MODE (target), force_reg (Pmode, src1_addr), Pmode, force_reg (Pmode, src2_addr), Pmode, - len_rtx, GET_MODE (len_rtx)); + len_rtx, Pmode); } rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label); @@ -2126,18 +2121,12 @@ } else { - rtx len_rtx; - if (TARGET_64BIT) - len_rtx = gen_reg_rtx (DImode); - else - len_rtx = gen_reg_rtx (SImode); - - emit_move_insn (len_rtx, GEN_INT (bytes - compare_length)); + rtx len_rtx = gen_reg_rtx (Pmode); + emit_move_insn (len_rtx, gen_int_mode (bytes-compare_length, Pmode)); tree fun = builtin_decl_explicit (BUILT_IN_STRNCMP); emit_library_call_value (XEXP (DECL_RTL (fun), 0), target, LCT_NORMAL, GET_MODE (target), - src1, Pmode, src2, Pmode, - len_rtx, GET_MODE (len_rtx)); + src1, Pmode, src2, Pmode, len_rtx, Pmode); } rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label);