{"id":1839964,"url":"http://patchwork.ozlabs.org/api/patches/1839964/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20230926224712.3858055-1-juzhe.zhong@rivai.ai/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20230926224712.3858055-1-juzhe.zhong@rivai.ai>","list_archive_url":null,"date":"2023-09-26T22:47:12","name":"DSE: Fix ICE when the mode with access_size don't exist on the target[PR111590]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e89759ef5f47143f16c905076251279d16814fa1","submitter":{"id":84155,"url":"http://patchwork.ozlabs.org/api/people/84155/?format=json","name":"钟居哲","email":"juzhe.zhong@rivai.ai"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20230926224712.3858055-1-juzhe.zhong@rivai.ai/mbox/","series":[{"id":375013,"url":"http://patchwork.ozlabs.org/api/series/375013/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=375013","date":"2023-09-26T22:47:12","name":"DSE: Fix ICE when the mode with access_size don't exist on the target[PR111590]","version":1,"mbox":"http://patchwork.ozlabs.org/series/375013/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1839964/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1839964/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org;\n envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=none (p=none dis=none) header.from=rivai.ai","sourceware.org; spf=pass smtp.mailfrom=rivai.ai"],"Received":["from server2.sourceware.org (server2.sourceware.org\n [IPv6:2620:52:3:1:0:246e:9693:128c])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4RwFHs47j2z1ypJ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 27 Sep 2023 08:47:36 +1000 (AEST)","from server2.sourceware.org (localhost [IPv6:::1])\n\tby sourceware.org (Postfix) with ESMTP id E01C5385DC28\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 26 Sep 2023 22:47:33 +0000 (GMT)","from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239])\n by sourceware.org (Postfix) with ESMTPS id 5BB363858C27\n for <gcc-patches@gcc.gnu.org>; Tue, 26 Sep 2023 22:47:20 +0000 (GMT)","from rios-cad122.hadoop.rioslab.org ( [58.60.1.26])\n by bizesmtp.qq.com (ESMTP) with\n id ; Wed, 27 Sep 2023 06:47:13 +0800 (CST)"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 5BB363858C27","X-QQ-mid":"bizesmtp73t1695768435tg61pv0u","X-QQ-SSF":"01400000002000G0V000B00A0000000","X-QQ-FEAT":"HH6/KuQOBEaGlCfbkddzjKi3yzMnc2mht/2tFhNScZO9bFH8WdZZZ6igxXF5H\n GsijkkGjF5tNep/IRbXA44iPaeuZNcQeEPbmy8dWibSnMSn/Qnb6A52lDHuLhw0rCXZDf1/\n LW/rfVXtjfjUg7LykWoZToJTfJ5+tuE9hbxdFW5rwl71tiPYSIz3bXt0TgGLeUy0+IO7SWQ\n nECzF3hb9obQgSDC8eZR5Wx2acgbju1O1W9IjBuwj7QkNvf+yvYn0I2A/WwULqKPV9zF6Vp\n usju0PBo+/ML5xENXCGeNuOVpYXrTLYIFZrY+pge1zIxVQFn5fzU5nwe7tx7svwx5/wRq1Q\n 67ojB9dndI806pxSmMOuAWJQc1pM1Zd94M8rGAYO4cc976I2b/Sui28w97oxw==","X-QQ-GoodBg":"2","X-BIZMAIL-ID":"11059668070761644867","From":"Juzhe-Zhong <juzhe.zhong@rivai.ai>","To":"gcc-patches@gcc.gnu.org","Cc":"richard.sandiford@arm.com,\n\tJuzhe-Zhong <juzhe.zhong@rivai.ai>","Subject":"[PATCH] DSE: Fix ICE when the mode with access_size don't exist on\n the target[PR111590]","Date":"Wed, 27 Sep 2023 06:47:12 +0800","Message-Id":"<20230926224712.3858055-1-juzhe.zhong@rivai.ai>","X-Mailer":"git-send-email 2.36.3","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-QQ-SENDSIZE":"520","Feedback-ID":"bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0","X-Spam-Status":"No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE,\n RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP,\n WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6","X-Spam-Checker-Version":"SpamAssassin 3.4.6 (2021-04-09) on\n server2.sourceware.org","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <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>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"hen doing fortran test with 'V' extension enabled on RISC-V port.\nI saw multiple ICE: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111590\n\nThe root cause is on DSE:\n\ninternal compiler error: in smallest_mode_for_size, at stor-layout.cc:356\n0x1918f70 smallest_mode_for_size(poly_int<2u, unsigned long>, mode_class)\n        ../../../../gcc/gcc/stor-layout.cc:356\n0x11f75bb smallest_int_mode_for_size(poly_int<2u, unsigned long>)\n        ../../../../gcc/gcc/machmode.h:916\n0x3304141 find_shift_sequence\n        ../../../../gcc/gcc/dse.cc:1738\n0x3304f1a get_stored_val\n        ../../../../gcc/gcc/dse.cc:1906\n0x3305377 replace_read\n        ../../../../gcc/gcc/dse.cc:2010\n0x3306226 check_mem_read_rtx\n        ../../../../gcc/gcc/dse.cc:2310\n0x330667b check_mem_read_use\n        ../../../../gcc/gcc/dse.cc:2415\n\nAfter investigations, DSE is trying to do optimization like this following codes:\n\n(insn 86 85 87 9 (set (reg:V4DI 168)\n        (mem/u/c:V4DI (reg/f:DI 171) [0  S32 A128])) \"bug.f90\":6:18 discrim 6 1167 {*movv4di}\n     (expr_list:REG_EQUAL (const_vector:V4DI [\n                (const_int 4 [0x4])\n                (const_int 1 [0x1]) repeated x2\n                (const_int 3 [0x3])\n            ])\n        (nil)))\n\n(set (mem) (reg:V4DI 168))\n\nThen it ICE on: auto new_mode = smallest_int_mode_for_size (access_size * BITS_PER_UNIT);\n\nThe access_size may be 24 or 32. We don't have such integer modes with these size so it ICE.\n\nTODO: The better way maybe make DSE use native_encode_rtx/native_decode_rtx\n      but I don't know how to do that.  So let's quickly fix this issue, we\n      can improve the fix later.\n\ngcc/ChangeLog:\n\n\t* dse.cc (find_shift_sequence): Check the mode with access_size exist on the target.\n\nAuthored-By: Richard Sandiford <richard.sandiford@arm.com>\n\n---\n gcc/dse.cc | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)","diff":"diff --git a/gcc/dse.cc b/gcc/dse.cc\nindex 8b07be17674..1a85dae1f8c 100644\n--- a/gcc/dse.cc\n+++ b/gcc/dse.cc\n@@ -1733,7 +1733,8 @@ find_shift_sequence (poly_int64 access_size,\n   /* If a constant was stored into memory, try to simplify it here,\n      otherwise the cost of the shift might preclude this optimization\n      e.g. at -Os, even when no actual shift will be needed.  */\n-  if (store_info->const_rhs)\n+  if (store_info->const_rhs\n+      && known_le (access_size, GET_MODE_SIZE (MAX_MODE_INT)))\n     {\n       auto new_mode = smallest_int_mode_for_size (access_size * BITS_PER_UNIT);\n       auto byte = subreg_lowpart_offset (new_mode, store_mode);\n","prefixes":[]}