From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 54A9638319D9 for ; Sat, 17 Dec 2022 00:36:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54A9638319D9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1034.google.com with SMTP id t11-20020a17090a024b00b0021932afece4so7673152pje.5 for ; Fri, 16 Dec 2022 16:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=g8SnzURZbl84E8vdKqcBTbbMzn0QcoSOeUfjOiwk0RY=; b=FEoV4uaLHLhwLOBkRgaxxn/aqNYlWaDTH4ULpH90MEDYAEDdI1hnDU4xgFna1wHbaf FafSIVzlPm9OHKdIYTPh3znCn3RIoydoYQ+wWiQLinKZuUzWy0/WjYXFpiVbgggbm0+Q DGMPK+kR14k95D2WOk4vZm6+rxRczDBLK8lT9hnAAjTPQeUVe+KdeXxykrwJPH4OfDTG 7KYDMDwERuezBLZaijI/jCcSRIJ05khUhPALc2JE9cZEmRoO5k8p2rNVdMqNeOQk3WGZ HPL70716hmtvwMWB4zOam8X7s1Feg1ErBgM5STVuB+yAl27zHNm/VMzWCjEDhevb/Nks CjPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g8SnzURZbl84E8vdKqcBTbbMzn0QcoSOeUfjOiwk0RY=; b=L8kp6Ws28k63T4O4R3A9BAOsztmX5+Fk8LnGThcAlwmpSTnX1IDoX1GCOGjwERr2xJ JAVKvRTVtTjeIXgPpbCKO1hLCLXE+Nd6tSl30I9JojxcxZLYcge6/tQZY+09SeZap1MT Q9xEF7h2wGoUulCI9HUTUgg3jRnjVFCntlOCdOiiXlCmlC/+2rAwb2Srx9AJXrsogjf9 Gvk36DR1H0XQn89viDxUdn1woxrnShqNozkI4cO23P1RZrXmctnmypWMeZgqDR0XGCI3 HZq1IBM7k7/fYEdGdtaa6s8VqM1bxr3+g56j/zEL6SxzOplC0+IuNzf6AXw6ZJMvNnEo iHmA== X-Gm-Message-State: AFqh2kpG5boRGA2PyLBjksFhG9A+wDTg0z56tzry5tOnc3xo61rGc3R2 Z8xvWL6XCPihrVO2dCGdkn4= X-Google-Smtp-Source: AMrXdXudnyJrqVOWrPvkTegW7RpM9Gr6qT3o+Kbxso1Ov3rwpucW7JqQwNyv/+nSu8R8uXN/+h32Lw== X-Received: by 2002:a17:902:a984:b0:189:7919:de3c with SMTP id bh4-20020a170902a98400b001897919de3cmr306881plb.43.1671237393316; Fri, 16 Dec 2022 16:36:33 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f2c900b00189667acf15sm2204300plc.162.2022.12.16.16.36.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 16:36:32 -0800 (PST) Message-ID: Date: Fri, 16 Dec 2022 17:36:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] tree-optimization/106904 - bogus -Wstringopt-overflow with vectors Content-Language: en-US To: Richard Biener , gcc-patches@gcc.gnu.org Cc: Jakub Jelinek References: <20221207135418.F35F4136B4@imap1.suse-dmz.suse.de> From: Jeff Law In-Reply-To: <20221207135418.F35F4136B4@imap1.suse-dmz.suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On 12/7/22 06:54, Richard Biener via Gcc-patches wrote: > The following avoids CSE of &ps->wp to &ps->wp.hwnd confusing > -Wstringopt-overflow by making sure to produce addresses to the > biggest container from vectorization. For this I introduce > strip_zero_offset_components which turns &ps->wp.hwnd into > &(*ps) and use that to base the vector data references on. > That will also work for addresses with variable components, > alternatively emitting pointer arithmetic via calling > get_inner_reference and gimplifying that would be possible > but likely more intrusive. > > This is by no means a complete fix for all of those issues > (avoiding ADDR_EXPRs in favor of pointer arithmetic might be). > Other passes will have similar issues. > > In theory that might now cause false negatives. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > Any opinion? > > Thanks, > Richard. > > PR tree-optimization/106904 > * tree.h (strip_zero_offset_components): Declare. > * tree.cc (strip_zero_offset_components): Define. > * tree-vect-data-refs.cc (vect_create_addr_base_for_vector_ref): > Strip zero offset components before building the address. > > * gcc.dg/Wstringop-overflow-pr106904.c: New testcase. So you're just canonicalizing to the widest container for a zero offset access. While it may not fix everything, that seems like a good thing in general when we can do so. I wouldn't be surprised if other passes could do the same thing to fix some of the missed CSE opportunities. jeff