From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id E1C2F3940CFB for ; Tue, 31 Jan 2023 13:22:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1C2F3940CFB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x334.google.com with SMTP id k16so10331846wms.2 for ; Tue, 31 Jan 2023 05:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vZlFXV43J8B9Dk18oVhtG38L2+GjcTs3TcLbtzeXF4U=; b=HoMaUlNZ2QldvQWIJSLt0IXES0NmKDfGQm9Zkp9nRignHa92ZXngG0m5o+iqeUEbfk mPIttDMbroDM2CQOzlbr0IEi80KJy2qRr/YtS6Fbinn4eEfwbrBU/BkYXKn3Sl57ROjk yz0K4Z3kn4XlC7JyuBPgEmzt+RIFVD1buHzkp/WKVQ5ZTgdcezr1A9RC8UNBVneBZSOq ZHOZQJsPIqKXgHndKbrlXQWlHEpV72nfBiBrduDjy1kJ2/ydFE+EhFhkNVQYna/RoIr5 VLTEolEUBweRUFwWU1aaCMH94mUn48SDp52nhEHHPuz4BuaPs+Lpkayx/G7N1p0a0q1n wtOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vZlFXV43J8B9Dk18oVhtG38L2+GjcTs3TcLbtzeXF4U=; b=05VwEmsskIVCKWwEVwQDFfNZ0uAaGwt0MemHoGSgpn8rPJayPG2i8xtm6SiiLW0Sgw R8AyUKISgPn1vXblj3BFyyehZ6mBlX9f6ILWeyR9KP081eolxH4WtZe9i+m4iJWbhyej mBVuxT92XR2We5h+eJDzJMg5kNWdgeuQYIU3MJBGGJsM5/gSs4FHYS/flKRPAKl/+vlM 9cNYf1/WxuAYhWNBy1WIlQDtqfSL+e6SBxaPxvC3+A/8FNHFLYoB2MJMQFafbYX5BdOZ 6BRG2LT7B0DL/flJHjBo97l3jeEr9+fz/gqXuF4vztcjDb9ePFIyk68GALG1zUvA+6w/ 6mpg== X-Gm-Message-State: AFqh2krj/nShbbho69ctA/EPDlEccoJ0Fa7Fclo8t7LxrIP2MJuUawkH exel9K5D5eZyXQRqCT3wfdKv X-Google-Smtp-Source: AMrXdXv1nDjovwkYycIiC+fO3NwSOqYAgw1ekoJcmQXagX6M/49EvM5RItg2w89pI57Z92BAThvP6A== X-Received: by 2002:a05:600c:538e:b0:3da:516:19ed with SMTP id hg14-20020a05600c538e00b003da051619edmr53159999wmb.29.1675171336507; Tue, 31 Jan 2023 05:22:16 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id p7-20020a1c5447000000b003dc433355aasm12466768wmi.18.2023.01.31.05.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:22:16 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, liushuyu Subject: [COMMITTED] gccrs: backend: correctly formulate the exit condition ... Date: Tue, 31 Jan 2023 14:25:59 +0100 Message-Id: <20230131132559.662754-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: From: liushuyu ... previously the exit condition was treated the same as the loop condition (which is the inverse condition of the exit condition). Now this is corrected. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Properly formulate exit condition when compiling while loops. Signed-off-by: Zixing Liu Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/backend/rust-compile-expr.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index ea146731cbe..d58e2258947 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -727,8 +727,11 @@ CompileExpr::visit (HIR::WhileLoopExpr &expr) tree condition = CompileExpr::Compile (expr.get_predicate_expr ().get (), ctx); + tree exit_condition + = fold_build1_loc (expr.get_locus ().gcc_location (), TRUTH_NOT_EXPR, + boolean_type_node, condition); tree exit_expr - = ctx->get_backend ()->exit_expression (condition, expr.get_locus ()); + = ctx->get_backend ()->exit_expression (exit_condition, expr.get_locus ()); ctx->add_statement (exit_expr); tree code_block_stmt -- 2.39.1