From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 534583858D35 for ; Mon, 15 Jan 2024 09:21:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 534583858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 534583858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705310505; cv=none; b=P4wDG1hGdiN/7G1+0ArfrCl1IxQrwrohHv0SXR8AfPQD8sMZ+teMt4QCrc91Ksdldil413VHpxmuhuOn9/NM1aYLRmgEUNUq2c876l0ajGrmhSMlo68E8qxUNSlE1n0R/bVj3m/rzuk59ifRX9w15xdhFWHBS1boJiksdPt/kj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705310505; c=relaxed/simple; bh=wDz1Vpc64A0kK4aFTAVVRpdgwVfX0yYEFKExqXLfE3U=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=mObzk94Kh+c6vgSsum8HULOHJHbjNNTtzM2oo6BW0oFOQ6bauxbRER88hVF/KTrsRG+e+jPHKH5ZTFZdceYhanTm4rjl/O5M3gN+sr3Eq5l37ZENanUYZxMLOXlFcmBjn4yuc0HtaOtRkW8zk3cMBx+geMQUK+p/Z4aZQPu/AKw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2cd703e9014so72978381fa.1 for ; Mon, 15 Jan 2024 01:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705310501; x=1705915301; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WShjIkYcqwKwffaDSCBHEOH/aoVb7UBpdSJhp9fjD2w=; b=MIxpZKhZhy3kUUqDVMS2skYUhULHqqdpU+DwIkTPoeEn0N3zNvZTPwAB/udyTmRGCZ XbTZQqEwomifD70yjhGdAFqR2zGjE2etEXJNgO8PklOmktgc0t9SCTwhtSJRDeeZftp8 JpPh4cPYzgUxhDy1bhjaXD3egPAGH0g7ri/zmh9A/fsBV2d8DWmjqtBK7P+tNCJ6dfmM pOtgrr9V/TOVAOet7rHvmBxOwRgXCB8wT54pKj/FBfNBJ9ixbo+y/5QlHgMihc6WdPIH kKUX00L731MvjzyKJvIwOYH27WmvoNhmlCMuMJ0wAPsvTsRk9lVrU3GoGXtrwWzAVyiX 33Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705310501; x=1705915301; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WShjIkYcqwKwffaDSCBHEOH/aoVb7UBpdSJhp9fjD2w=; b=c7Y3PQ3BKgtCxM4ADPLcGNbtDM6po2hv/O07UqLBnyFuIu0j2aSnb9qSKNvIz0+MzZ mnVsW6v+ZTuI3VOnG9tFgge1beb1utF8UZlzVvI++Z3OSsvK2VLtE9yETKdmzIRYgzqB yfmPEeLoopa0LoY9d9haosFGMsKUX7qkvQNl5OUCOm3hbrdEY2Ln4xsGTQrTHDoNZfjd m0PzwREedz6fqs2CV8Kf3/FnQmYX0J+M0plV3Ba7aCcD9++Iy/NrHwpPsscxyzUn1WVf nEwYl5s+8q9Q1ZNgy+dLCGiImyvNquIz+sCdT5ZB7jWids8aT1z2oZllmtinFxJIveq9 afwg== X-Gm-Message-State: AOJu0YxabK8wT0wbGmqiUI/6Z+qpFdhzMUHw/2GQ10n63bBrrdLy2ySp DU3MMdoooSasm5vgyl7QJ9h9Qdc7rnLabDSWlyM= X-Google-Smtp-Source: AGHT+IGL96C+R/FVGuQ8J29GJ/wpeCR3a/9lnY8ebiROXoe4toCKgAr360c6lzknV40LyeSNJ8aciOdolZRTUvCHRt0= X-Received: by 2002:a2e:8059:0:b0:2cc:74c2:3af2 with SMTP id p25-20020a2e8059000000b002cc74c23af2mr2421699ljg.28.1705310500561; Mon, 15 Jan 2024 01:21:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Mon, 15 Jan 2024 10:16:23 +0100 Message-ID: Subject: Re: How to compress the size of a field in a structure? To: Hanke Zhang Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Jan 13, 2024 at 8:46=E2=80=AFAM Hanke Zhang via Gcc wrote: > > Hi, I'm attempting to compress the size of a field in a structure for > memory-friendly purposes. I created an IPA pass to achieve this, but I > ran into some issues as follows: > > // original > struct Foo { > long a1; > int a2; > }; > > // modified > struct Foo_update { > int a1; > int a2; > }; > > For the example structure Foo, I use `TREE_TYPE (field) =3D > integer_type_node` to compress the type of a1 from `long` to `int`. > > But I don't know how to update its corresponding SSA variables, > because the number of them is huge. Is there any way to do it quickly? There's no way to map back a structure field to all of its [implicit] uses. But the set of variables to adjust should fall out trivially of the analysis phase = that determines whether the transform is valid (which is indeed the most complic= ated part). It might be possible to restrict the transform to certain objects (rather than the "type"). There were several similar attempts on doing "struct reorg", the most recen= t by people from amerecomputing IIRC. I've always commented that trying to do this on the types (and computing sth like "type escape") is wrong, analysis= and transform should be on individual instances of the type instead - those you= can actually analyze. Richard. > > Thanks > Hanke Zhang