From patchwork Thu Apr 14 02:56:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1617014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=OSo/Zhoa; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kf3yV5CQXz9sG4 for ; Thu, 14 Apr 2022 12:56:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 725483857348 for ; Thu, 14 Apr 2022 02:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 725483857348 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649905005; bh=U3VxXa5AS4NgVFSVdNFtC+4HgnKKZGhPb1gB/zerxdE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OSo/Zhoa++tsILlxc4DVh+z/Dftds6php0wK3uLuejbwFiO0QgjKq6s3Q2uCM2ry1 aRqa4pN9noWREqwZ6Sl5SpAWPsnHYRIWPBL54fGwsa1f9N68vynGeFUpb55cnFptgg yWwVjzlmqzl4D+YGptiqtL3l1F9jrijqcykp7AXE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 683943858C2C for ; Thu, 14 Apr 2022 02:56:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 683943858C2C Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-T07kQ4b6Mtq7Wc0yJ5QbjA-1; Wed, 13 Apr 2022 22:56:23 -0400 X-MC-Unique: T07kQ4b6Mtq7Wc0yJ5QbjA-1 Received: by mail-qv1-f69.google.com with SMTP id m15-20020a0562141bcf00b00443ddcd8a0fso3345178qvc.12 for ; Wed, 13 Apr 2022 19:56:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=U3VxXa5AS4NgVFSVdNFtC+4HgnKKZGhPb1gB/zerxdE=; b=hf+X13TqQYEH56ziRj+1/iItj8vfENb+1CtpB6Rp5QZ34/etINSZREWttNlf6QCig0 z188aZK46+9BJ/flFSyZDNr6C6NW/RtgUPzs0zQTOhg6at+Tt2HA36HM1GfPU1BxHFCp s5dXLg4ch/GUQRFmG73khTGrfWvi3jz++rDINFC9SEL/pl9gYo07HkR0lKRUwYjOuxT/ wIki4w2Kcq1yP3uyGsCveCxLgGeJGKTygy4z14nSA0BE3Dvm3ewbP76y4Pf+UdHk3NdF WUKKpuz3EMgJ+IJy+CzW+NeMOGcqpMQavMZy87PpeCguyjIZxkzcSbiokbNA8pPWFphR WbsA== X-Gm-Message-State: AOAM5301Quak5SCQR0ejFTm04xeMdaMiw2lggtb5N2b+rGlZXydTFymn +WpMSW2XeANBNa1eIKs8OXOlsR2X3jZNtf1kgdgr09la7Q1bLG38lYuriZrW557IxhnKo7JRLto pzFtI3+k+JzCzkrYk1dUcSok1u/B7prHy2NYHgEpqzYk21FPo93ksYYsdfddXUbDOLg== X-Received: by 2002:a05:620a:bc9:b0:67b:e954:e3e2 with SMTP id s9-20020a05620a0bc900b0067be954e3e2mr413413qki.491.1649904982880; Wed, 13 Apr 2022 19:56:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOFMAhBhZpLgWcnRctjh/AJMlVRf+SdUdmOwfvJzmnWLDUHcSFN+6a+T0HDjvygtPc7/VkqA== X-Received: by 2002:a05:620a:bc9:b0:67b:e954:e3e2 with SMTP id s9-20020a05620a0bc900b0067be954e3e2mr413398qki.491.1649904982481; Wed, 13 Apr 2022 19:56:22 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id q125-20020a378e83000000b0069bf8409e6fsm364627qkd.28.2022.04.13.19.56.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 19:56:21 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: alignment of local typedef in template [PR65211] Date: Wed, 13 Apr 2022 22:56:18 -0400 Message-Id: <20220414025618.3289724-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Because common_handle_aligned_attribute only applies the alignment to the TREE_TYPE of a typedef, not the DECL_ORIGINAL_TYPE, we need to copy it explicitly in tsubst. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/65211 gcc/cp/ChangeLog: * pt.cc (tsubst_decl) [TYPE_DECL]: Copy TYPE_ALIGN. gcc/testsuite/ChangeLog: * g++.target/i386/vec-tmpl1.C: New test. --- gcc/cp/pt.cc | 6 ++++++ gcc/testsuite/g++.target/i386/vec-tmpl1.C | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.target/i386/vec-tmpl1.C base-commit: 1824da60663b4532199ecd051d8ba6da8995821d diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index adc863de702..dde62ee052d 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -15084,6 +15084,12 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) { DECL_ORIGINAL_TYPE (r) = NULL_TREE; set_underlying_type (r); + + /* common_handle_aligned_attribute doesn't apply the alignment + to DECL_ORIGINAL_TYPE. */ + if (TYPE_USER_ALIGN (TREE_TYPE (t))) + TREE_TYPE (r) = build_aligned_type (TREE_TYPE (r), + TYPE_ALIGN (TREE_TYPE (t))); } layout_decl (r, 0); diff --git a/gcc/testsuite/g++.target/i386/vec-tmpl1.C b/gcc/testsuite/g++.target/i386/vec-tmpl1.C new file mode 100644 index 00000000000..d512072a2a2 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/vec-tmpl1.C @@ -0,0 +1,16 @@ +// PR c++/65211 +// { dg-final { scan-assembler-not "movdqa" } } + +typedef unsigned v4ui __attribute__ ((vector_size(16), aligned (16))); + +template +static v4ui t1(unsigned *dest_data) +{ + typedef unsigned v4ui_1 __attribute__ ((vector_size (16), aligned (4))); + return ((const v4ui_1*)dest_data)[0]; +} + +v4ui f(unsigned int *array) +{ + return t1<1>(array+7); +}