Message ID | f84887dd-1d9e-e53f-b171-494426634026@arm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4646F385737B for <patchwork@sourceware.org>; Wed, 12 Oct 2022 17:29:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4646F385737B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665595790; bh=ZWluQjPMjcNISdrF2vjjEN5L/B6MRKOlHdFi6PUV3PM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZKDdUxX7tHAShTFW/TginJgHoZV4r7m4pb/rlNt1IAuxtzs9mQi0Ef0Ui42j7fLr5 vjpI03OFX1XJP2bT58X1mC9fUKPpknYmZsa3CM0LmIxAxO+H5Xuy2GnaRr9q3BkAfZ IulbeJneV7LeFKwAYBpbr3reU/z2u9/Nc/366LH0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 19DA83858D38 for <gcc-patches@gcc.gnu.org>; Wed, 12 Oct 2022 17:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19DA83858D38 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C17BA165C; Wed, 12 Oct 2022 10:29:21 -0700 (PDT) Received: from [10.57.1.129] (unknown [10.57.1.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE7263F766; Wed, 12 Oct 2022 10:29:14 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------fJm0cLPiTWVHUP5MZO87FYxe" Message-ID: <f84887dd-1d9e-e53f-b171-494426634026@arm.com> Date: Wed, 12 Oct 2022 18:29:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-US To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org> Subject: ifcvt: Fix bitpos calculation in bitfield lowering [PR107229] X-Spam-Status: No, score=-20.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: "Andre Vieira \(lists\) via Gcc-patches" <gcc-patches@gcc.gnu.org> Reply-To: "Andre Vieira \(lists\)" <andre.simoesdiasvieira@arm.com> Cc: Richard Sandiford <richard.sandiford@arm.com>, Richard Biener <rguenther@suse.de> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
ifcvt: Fix bitpos calculation in bitfield lowering [PR107229]
|
|
Commit Message
Andre Vieira (lists)
Oct. 12, 2022, 5:29 p.m. UTC
Hi, The bitposition calculation for the bitfield lowering in loop if conversion was not taking DECL_FIELD_OFFSET into account, which meant that it would result in wrong bitpositions for bitfields that did not end up having representations starting at the beginning of the struct. Bootstrappend and regression tested on aarch64-none-linux-gnu and x86_64-pc-linux-gnu. gcc/ChangeLog: PR tree-optimization/107229 * gcc/tree-if-conv.cc (get_bitfield_rep): Fix bitposition calculation. gcc/testsuite/ChangeLog: * gcc.dg/vect/pr107229-1.c: New test. * gcc.dg/vect/pr107229-2.c: New test. * gcc.dg/vect/pr107229-3.c: New test.
Comments
On Wed, 12 Oct 2022, Andre Vieira (lists) wrote: > Hi, > > The bitposition calculation for the bitfield lowering in loop if conversion > was not > taking DECL_FIELD_OFFSET into account, which meant that it would result in > wrong bitpositions for bitfields that did not end up having representations > starting at the beginning of the struct. > > Bootstrappend and regression tested on aarch64-none-linux-gnu and > x86_64-pc-linux-gnu. + { + tree bf_pos = fold_build2 (MULT_EXPR, bitsizetype, + DECL_FIELD_OFFSET (field_decl), + build_int_cst (bitsizetype, 8)); + bf_pos = fold_build2 (PLUS_EXPR, bitsizetype, bf_pos, + DECL_FIELD_BIT_OFFSET (field_decl)); + tree rep_pos = fold_build2 (MULT_EXPR, bitsizetype, + DECL_FIELD_OFFSET (rep_decl), + build_int_cst (bitsizetype, 8)); + rep_pos = fold_build2 (PLUS_EXPR, bitsizetype, rep_pos, + DECL_FIELD_BIT_OFFSET (rep_decl)); you can use the invariant that DECL_FIELD_OFFSET of rep_decl and field_decl are always the same. Also please use BITS_PER_UNIT instead of '8'. Richard.
Hi Andre, > The bitposition calculation for the bitfield lowering in loop if conversion > was not > taking DECL_FIELD_OFFSET into account, which meant that it would result in > wrong bitpositions for bitfields that did not end up having representations > starting at the beginning of the struct. > > Bootstrappend and regression tested on aarch64-none-linux-gnu and > x86_64-pc-linux-gnu. I tried this patch together with the one for PR tree-optimization/107226 on sparc-sun-solaris2.11 to check if it cures the bootstrap failure reported in PR tree-optimization/107232. While this restores bootstrap, several of the new tests FAIL: +FAIL: gcc.dg/vect/vect-bitfield-read-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-1.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-2.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-2.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-3.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 2 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-3.c scan-tree-dump-times vect "vectorized 2 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-4.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-4.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-read-6.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-1.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-2.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-2.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-3.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-3.c scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-5.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 +FAIL: gcc.dg/vect/vect-bitfield-write-5.c scan-tree-dump-times vect "vectorized 1 loops" 1 For vect-bitfield-read-1.c, the dump has gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining pattern def statement: patt_31 = patt_30 >> 1; gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining statement: patt_31 = patt_30 >> 1; gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: operand _ifc__27 & 4294967294, type of def: internal gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: vectype vector(2) unsigned int gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: operand 1, type of def: constant gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: op not supported by target. gcc.dg/vect/vect-bitfield-read-1.c:23:1: missed: not vectorized: relevant stmt not supported: patt_31 = patt_30 >> 1; gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: bad operation or unsupported loop bound. gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ***** Analysis failed with vector mode V2SI Rainer
Hi Rainer, Thanks for reporting, I was actually expecting these! I thought about pre-empting them by using a positive filter on the tests for aarch64 and x86_64 as I knew those would pass, but I thought it would be better to let other targets report failures since then you get a testsuite that covers more targets than just what I'm able to check. Are there any sparc architectures that would support these or should I just xfail sparc*-*-* ? For instance: I also saw PR107240 for which one of the write tests fails on Power 7 BE. I'm suggesting adding an xfail for that one Kind regards, Andre On 13/10/2022 12:39, Rainer Orth wrote: > Hi Andre, > >> The bitposition calculation for the bitfield lowering in loop if conversion >> was not >> taking DECL_FIELD_OFFSET into account, which meant that it would result in >> wrong bitpositions for bitfields that did not end up having representations >> starting at the beginning of the struct. >> >> Bootstrappend and regression tested on aarch64-none-linux-gnu and >> x86_64-pc-linux-gnu. > I tried this patch together with the one for PR tree-optimization/107226 > on sparc-sun-solaris2.11 to check if it cures the bootstrap failure > reported in PR tree-optimization/107232. While this restores bootstrap, > several of the new tests FAIL: > > +FAIL: gcc.dg/vect/vect-bitfield-read-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-1.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-2.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-2.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-3.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 2 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-3.c scan-tree-dump-times vect "vectorized 2 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-4.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-4.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-read-6.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-1.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-2.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-2.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-3.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-3.c scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-5.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 > +FAIL: gcc.dg/vect/vect-bitfield-write-5.c scan-tree-dump-times vect "vectorized 1 loops" 1 > > For vect-bitfield-read-1.c, the dump has > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining pattern def statement: patt_31 = patt_30 >> 1; > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining statement: patt_31 = patt_30 >> 1; > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: operand _ifc__27 & 4294967294, type of def: internal > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: vectype vector(2) unsigned int > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: operand 1, type of def: constant > gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: op not supported by target. > gcc.dg/vect/vect-bitfield-read-1.c:23:1: missed: not vectorized: relevant stmt not supported: patt_31 = patt_30 >> 1; > gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: bad operation or unsupported loop bound. > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ***** Analysis failed with vector mode V2SI > > Rainer >
On Thu, 13 Oct 2022, Andre Vieira (lists) wrote: > Hi Rainer, > > Thanks for reporting, I was actually expecting these! I thought about > pre-empting them by using a positive filter on the tests for aarch64 and > x86_64 as I knew those would pass, but I thought it would be better to let > other targets report failures since then you get a testsuite that covers more > targets than just what I'm able to check. > > Are there any sparc architectures that would support these or should I just > xfail sparc*-*-* ? > > For instance: I also saw PR107240 for which one of the write tests fails on > Power 7 BE. I'm suggesting adding an xfail for that one for the failure below we seem to require vectorizing shifts for which I think we have a vect_* target to check? > Kind regards, > Andre > > On 13/10/2022 12:39, Rainer Orth wrote: > > Hi Andre, > > > >> The bitposition calculation for the bitfield lowering in loop if conversion > >> was not > >> taking DECL_FIELD_OFFSET into account, which meant that it would result in > >> wrong bitpositions for bitfields that did not end up having representations > >> starting at the beginning of the struct. > >> > >> Bootstrappend and regression tested on aarch64-none-linux-gnu and > >> x86_64-pc-linux-gnu. > > I tried this patch together with the one for PR tree-optimization/107226 > > on sparc-sun-solaris2.11 to check if it cures the bootstrap failure > > reported in PR tree-optimization/107232. While this restores bootstrap, > > several of the new tests FAIL: > > > > +FAIL: gcc.dg/vect/vect-bitfield-read-1.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-1.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-2.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-2.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-3.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 2 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-3.c scan-tree-dump-times vect > > "vectorized 2 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-4.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-4.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-read-6.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-1.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-1.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-2.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-2.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-3.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-3.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-5.c -flto -ffat-lto-objects > > scan-tree-dump-times vect "vectorized 1 loops" 1 > > +FAIL: gcc.dg/vect/vect-bitfield-write-5.c scan-tree-dump-times vect > > "vectorized 1 loops" 1 > > > > For vect-bitfield-read-1.c, the dump has > > > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining pattern def > > statement: patt_31 = patt_30 >> 1; > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining statement: > > patt_31 = patt_30 >> 1; > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: > > operand _ifc__27 & 4294967294, type of def: internal > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: > > vectype vector(2) unsigned int > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: > > operand 1, type of def: constant > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: op not supported by > > target. > > gcc.dg/vect/vect-bitfield-read-1.c:23:1: missed: not vectorized: relevant > > stmt not supported: patt_31 = patt_30 >> 1; > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: bad operation or > > unsupported loop bound. > > gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ***** Analysis failed with > > vector mode V2SI > > > > Rainer > > >
On 13/10/2022 15:15, Richard Biener wrote: > On Thu, 13 Oct 2022, Andre Vieira (lists) wrote: > >> Hi Rainer, >> >> Thanks for reporting, I was actually expecting these! I thought about >> pre-empting them by using a positive filter on the tests for aarch64 and >> x86_64 as I knew those would pass, but I thought it would be better to let >> other targets report failures since then you get a testsuite that covers more >> targets than just what I'm able to check. >> >> Are there any sparc architectures that would support these or should I just >> xfail sparc*-*-* ? >> >> For instance: I also saw PR107240 for which one of the write tests fails on >> Power 7 BE. I'm suggesting adding an xfail for that one > for the failure below we seem to require vectorizing shifts for which I > think we have a vect_* target to check? 'vect_shift' no sparc on the list of supported targets, so that should do it, I'll add it when I add my fix for powerpc too. > >> Kind regards, >> Andre >> >> On 13/10/2022 12:39, Rainer Orth wrote: >>> Hi Andre, >>> >>>> The bitposition calculation for the bitfield lowering in loop if conversion >>>> was not >>>> taking DECL_FIELD_OFFSET into account, which meant that it would result in >>>> wrong bitpositions for bitfields that did not end up having representations >>>> starting at the beginning of the struct. >>>> >>>> Bootstrappend and regression tested on aarch64-none-linux-gnu and >>>> x86_64-pc-linux-gnu. >>> I tried this patch together with the one for PR tree-optimization/107226 >>> on sparc-sun-solaris2.11 to check if it cures the bootstrap failure >>> reported in PR tree-optimization/107232. While this restores bootstrap, >>> several of the new tests FAIL: >>> >>> +FAIL: gcc.dg/vect/vect-bitfield-read-1.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-1.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-2.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-2.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-3.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 2 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-3.c scan-tree-dump-times vect >>> "vectorized 2 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-4.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-4.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-read-6.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-1.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-1.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-2.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-2.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-3.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-3.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-5.c -flto -ffat-lto-objects >>> scan-tree-dump-times vect "vectorized 1 loops" 1 >>> +FAIL: gcc.dg/vect/vect-bitfield-write-5.c scan-tree-dump-times vect >>> "vectorized 1 loops" 1 >>> >>> For vect-bitfield-read-1.c, the dump has >>> >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining pattern def >>> statement: patt_31 = patt_30 >> 1; >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ==> examining statement: >>> patt_31 = patt_30 >> 1; >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: >>> operand _ifc__27 & 4294967294, type of def: internal >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: >>> vectype vector(2) unsigned int >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: vect_is_simple_use: >>> operand 1, type of def: constant >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: op not supported by >>> target. >>> gcc.dg/vect/vect-bitfield-read-1.c:23:1: missed: not vectorized: relevant >>> stmt not supported: patt_31 = patt_30 >> 1; >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: missed: bad operation or >>> unsupported loop bound. >>> gcc.dg/vect/vect-bitfield-read-1.c:25:23: note: ***** Analysis failed with >>> vector mode V2SI >>> >>> Rainer >>>
diff --git a/gcc/testsuite/gcc.dg/vect/pr107229-1.c b/gcc/testsuite/gcc.dg/vect/pr107229-1.c new file mode 100644 index 0000000000000000000000000000000000000000..67b432383d057a630746aa00af50c25fcb527d8e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr107229-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long d; + int : 8; + int : 27; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr107229-2.c b/gcc/testsuite/gcc.dg/vect/pr107229-2.c new file mode 100644 index 0000000000000000000000000000000000000000..88bffb63d5e8b2d7bcdeae223f4ec6ea4f611bc9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr107229-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long f; + long g; + long d; + int : 8; + int : 27; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr107229-3.c b/gcc/testsuite/gcc.dg/vect/pr107229-3.c new file mode 100644 index 0000000000000000000000000000000000000000..4abd8c14531b40e9dbe9802a8f9a0eabba673c9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr107229-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* PR tree-optimization/107229. */ + +int a, c; +struct { + long f; + long g; + long d; + int : 8; + int : 32; + int : 2; + int e : 21; +} f; +void g(int b) { a = a & 1; } +int main() { + while (c) + g(f.e); + return 0; +} diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index e468a4659fa28a3a31c3390cf19bee65f4590b80..33160ddef80cbd75c2a927fb50bddd792bbf5dd4 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -3298,10 +3298,20 @@ get_bitfield_rep (gassign *stmt, bool write, tree *bitpos, *struct_expr = TREE_OPERAND (comp_ref, 0); if (bitpos) - *bitpos - = fold_build2 (MINUS_EXPR, bitsizetype, - DECL_FIELD_BIT_OFFSET (field_decl), - DECL_FIELD_BIT_OFFSET (rep_decl)); + { + tree bf_pos = fold_build2 (MULT_EXPR, bitsizetype, + DECL_FIELD_OFFSET (field_decl), + build_int_cst (bitsizetype, 8)); + bf_pos = fold_build2 (PLUS_EXPR, bitsizetype, bf_pos, + DECL_FIELD_BIT_OFFSET (field_decl)); + tree rep_pos = fold_build2 (MULT_EXPR, bitsizetype, + DECL_FIELD_OFFSET (rep_decl), + build_int_cst (bitsizetype, 8)); + rep_pos = fold_build2 (PLUS_EXPR, bitsizetype, rep_pos, + DECL_FIELD_BIT_OFFSET (rep_decl)); + + *bitpos = fold_build2 (MINUS_EXPR, bitsizetype, bf_pos, rep_pos); + } return rep_decl;