From patchwork Wed Sep 13 08:08:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 813210 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-462000-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jtBe9M8y"; 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 3xsZ6y3kWKz9sPm for ; Wed, 13 Sep 2017 18:08: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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=dTJarZcQZtCXolm6s7rrywJUyCvFiqhzcfuLksJVzJtnx6yojoo4/ SngL4aHTY7+gO3A50nCKX/n3ZHqGC506jM/+FweETd2JOTUimzqxhcBMQKWHDvW6 gKR9YBo1DgBdUjD9GgtTbrKBompC40b+9mSFaykzm0nQXMElrbfaEs= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=8b9N0fjph12eT/p7uZSYYxcXFP8=; b=jtBe9M8yE4j+qDBcEnxf //RSuy6k44wLvUl0iyzmB4wuyI36BWOvrpXvYyrrdbnk2CHQwY9dHDgrSa/8v2bZ rNQqubFg+D+d2cdHCJMxNf+akydjcabs2mjf8ntDabHemCP2YORapeE29eRkvsEL vt2ruTx0GaCyam8tS+MeNPk= Received: (qmail 6425 invoked by alias); 13 Sep 2017 08:08:32 -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 6067 invoked by uid 89); 13 Sep 2017 08:08:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=fills, sum X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Sep 2017 08:08:30 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 96C61ABED for ; Wed, 13 Sep 2017 08:08:28 +0000 (UTC) Date: Wed, 13 Sep 2017 10:08:28 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add GIMPLE verification for a few codes Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 This fills in some gaps in GIMPLE verification. It shows that for AVX vector boolean we use VEC_PACK_TRUNC_EXPR to essentially concat two vectors -- I think we shouldn't have done that but instead used { x, y } for this. But even the target got patterns for this so I let this bypass verification for now. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. 2017-09-13 Richard Biener * tree-cfg.c (verify_gimple_assign_binary): Add verification for WIDEN_SUM_EXPR, VEC_WIDEN_MULT_{HI,LO,EVEN,ODD}_EXPR, VEC_PACK_{TRUNC,SAT,FIX_TRUNC}_EXPR. (verify_gimple_assign_ternary): Add verification for DOT_PROD_EXPR. Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 252006) +++ gcc/tree-cfg.c (working copy) @@ -4013,15 +4013,80 @@ verify_gimple_assign_binary (gassign *st || (TYPE_PRECISION (rhs1_type) != TYPE_PRECISION (rhs2_type))); case WIDEN_SUM_EXPR: + { + if (((TREE_CODE (rhs1_type) != VECTOR_TYPE + || TREE_CODE (lhs_type) != VECTOR_TYPE) + && ((!INTEGRAL_TYPE_P (rhs1_type) + && !SCALAR_FLOAT_TYPE_P (rhs1_type)) + || (!INTEGRAL_TYPE_P (lhs_type) + && !SCALAR_FLOAT_TYPE_P (lhs_type)))) + || !useless_type_conversion_p (lhs_type, rhs2_type) + || (GET_MODE_SIZE (element_mode (rhs2_type)) + < 2 * GET_MODE_SIZE (element_mode (rhs1_type)))) + { + error ("type mismatch in widening sum reduction"); + debug_generic_expr (lhs_type); + debug_generic_expr (rhs1_type); + debug_generic_expr (rhs2_type); + return true; + } + return false; + } + case VEC_WIDEN_MULT_HI_EXPR: case VEC_WIDEN_MULT_LO_EXPR: case VEC_WIDEN_MULT_EVEN_EXPR: case VEC_WIDEN_MULT_ODD_EXPR: + { + if (TREE_CODE (rhs1_type) != VECTOR_TYPE + || TREE_CODE (lhs_type) != VECTOR_TYPE + || !types_compatible_p (rhs1_type, rhs2_type) + || (GET_MODE_SIZE (element_mode (lhs_type)) + != 2 * GET_MODE_SIZE (element_mode (rhs1_type)))) + { + error ("type mismatch in vector widening multiplication"); + debug_generic_expr (lhs_type); + debug_generic_expr (rhs1_type); + debug_generic_expr (rhs2_type); + return true; + } + return false; + } + case VEC_PACK_TRUNC_EXPR: + /* ??? We currently use VEC_PACK_TRUNC_EXPR to simply concat + vector boolean types. */ + if (VECTOR_BOOLEAN_TYPE_P (lhs_type) + && VECTOR_BOOLEAN_TYPE_P (rhs1_type) + && types_compatible_p (rhs1_type, rhs2_type) + && (TYPE_VECTOR_SUBPARTS (lhs_type) + == 2 * TYPE_VECTOR_SUBPARTS (rhs1_type))) + return false; + + /* Fallthru. */ case VEC_PACK_SAT_EXPR: case VEC_PACK_FIX_TRUNC_EXPR: - /* FIXME. */ - return false; + { + if (TREE_CODE (rhs1_type) != VECTOR_TYPE + || TREE_CODE (lhs_type) != VECTOR_TYPE + || !((rhs_code == VEC_PACK_FIX_TRUNC_EXPR + && SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs1_type)) + && INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))) + || (INTEGRAL_TYPE_P (TREE_TYPE (rhs1_type)) + == INTEGRAL_TYPE_P (TREE_TYPE (lhs_type)))) + || !types_compatible_p (rhs1_type, rhs2_type) + || (GET_MODE_SIZE (element_mode (rhs1_type)) + != 2 * GET_MODE_SIZE (element_mode (lhs_type)))) + { + error ("type mismatch in vector pack expression"); + debug_generic_expr (lhs_type); + debug_generic_expr (rhs1_type); + debug_generic_expr (rhs2_type); + return true; + } + + return false; + } case MULT_EXPR: case MULT_HIGHPART_EXPR: @@ -4281,6 +4346,27 @@ verify_gimple_assign_ternary (gassign *s return false; case DOT_PROD_EXPR: + { + if (((TREE_CODE (rhs1_type) != VECTOR_TYPE + || TREE_CODE (lhs_type) != VECTOR_TYPE) + && ((!INTEGRAL_TYPE_P (rhs1_type) + && !SCALAR_FLOAT_TYPE_P (rhs1_type)) + || (!INTEGRAL_TYPE_P (lhs_type) + && !SCALAR_FLOAT_TYPE_P (lhs_type)))) + || !types_compatible_p (rhs1_type, rhs2_type) + || !useless_type_conversion_p (lhs_type, rhs3_type) + || (GET_MODE_SIZE (element_mode (rhs3_type)) + < 2 * GET_MODE_SIZE (element_mode (rhs1_type)))) + { + error ("type mismatch in dot product reduction"); + debug_generic_expr (lhs_type); + debug_generic_expr (rhs1_type); + debug_generic_expr (rhs2_type); + return true; + } + return false; + } + case REALIGN_LOAD_EXPR: /* FIXME. */ return false;