From patchwork Wed Jul 10 07:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1958742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BmVBkAp7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJqlQ5ynBz1xqj for ; Wed, 10 Jul 2024 17:50:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 32A6538708EF for ; Wed, 10 Jul 2024 07:50:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 9D0BA385841E for ; Wed, 10 Jul 2024 07:49:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D0BA385841E 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 9D0BA385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720597790; cv=none; b=XQyKin5GLlG5B1G1EhhaN6Zp1QOg/S9YmjfYaTYbcmAyzaJgPl6F+TTWsiBWfaz4UR0Nhf8ywNDb1dR7CUa7uibvt8YSrMG3yyJHTCSXDmYYuaipgF37fykRtjyiTuopg0tPCF2xNw6nc3lM+fK998X0YTJX6h0jPHNKFPWgWb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720597790; c=relaxed/simple; bh=3TkpKtTGVnW1e1IjhOqLbckU4DLBHZqAhkA8QqfTu1o=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ddk857sx4sjGzEuS5P08OM9h/K4QlsTzKYAf79iH8bJhta0ghlaJrQ3y7PMkEKQRZMJ/Dq9ey/9VnpuYs2RXashOVFWRM80mkjjfH6Gm0ltqQRe2UyzbQR6ddyKRPLu0h7fnr5n3crZ7ajY4NQSnuwMiGNmrcc2to/lfUj0ZRNk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2eea8ea8bb0so49728081fa.1 for ; Wed, 10 Jul 2024 00:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720597787; x=1721202587; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Cx4n0bBSScI13yWHbti6u/cpq+AlsLOSqqSfKLj+88w=; b=BmVBkAp7NH6sDMXwnjmklYC2xEoUlBa3N0Fq7+pNXOlryayUIMEFqB1GSF6foEJfCc gqzoh2P37kyh9v5VUL7f/grAbuzqfmiZzwp50FhBn23u0sAZJh8KjubyNp/58vKhiXKL Hs5QUcMRwckMkjiZU6O2cmQ+TxI62mN/5u3N+IebnUl6BKD2jUtxTg6GTkixqYj9Symh KsO5EWAsRXn1KC6jzALlyjH9emnSaaCgk+ZLsH27yD2IZH9AehHXU+AHSjYTOphXiKZn WS5ktiJNNsVZ6WIsfbdjOXh1RFkfFKTXO0E8v3wEhXm2javAlNEUXylAAskl4al/GBGr 3Uqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720597787; x=1721202587; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Cx4n0bBSScI13yWHbti6u/cpq+AlsLOSqqSfKLj+88w=; b=VPJSYPS1EW9XYrSV+gLqMUxrVTbSHTUn/6o9Hhb8+H16H5S1CNheqO06vpKzvBu9i2 Ph7Bigo3sb7OebQ8TrBWt4hzvd4sX96YNF8xzGWQSHk/aDwVrEmNrbRW68K8U+FSGYZQ g9GBKSn2lh4c4+wN5F4QjShYPhz+wr7GrJVKA+8+C12mcNGb25FE3DxpTAm/+4yMNwLg yK+yTOxxnsWEIupMLu3op5dhUyup4qCD8nM6/strLHRnZjQPuAIlBB0iv+Q9GzzYxiXK H8gV/1nJ5oChRXvz6TCxXeXbe4lbd9pCgljdf7Dtjn4ZSYoxy1eVTBmZ+UcjHma0sJgI hsAw== X-Gm-Message-State: AOJu0Yx3O88+BTZVJm7G87bF2TWVyD8jbdlhQ0/60k8thFPacW0fB4jC mY+lwOyATt87MwvsByDuVzQCjecvkpJxX8a42GvTZHi6UYP35gLSlY4pScCFJFvkRSnSKt4kWhS 9a5P5WlXTXxtAE1LM89b5NCIw4U/fGHr9tTc= X-Google-Smtp-Source: AGHT+IGs73RzGxbe7pF1SkinSeSKrLlYi439lLzopT6k6CR5lyjW0MgsLsBtMscMAyWvkqkkCh/xMN8tBPwV4DJRmbU= X-Received: by 2002:a2e:8849:0:b0:2ed:5af6:e846 with SMTP id 38308e7fff4ca-2eeb31891e9mr36391171fa.50.1720597786323; Wed, 10 Jul 2024 00:49:46 -0700 (PDT) MIME-Version: 1.0 From: Uros Bizjak Date: Wed, 10 Jul 2024 09:49:34 +0200 Message-ID: Subject: [PATCH] middle-end: Fix stalled swapped condition code value [PR115836] To: "gcc-patches@gcc.gnu.org" Cc: Richard Biener X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org emit_store_flag_1 calculates scode (swapped condition code) at the beginning of the function from the value of code variable. However, code variable may change before scode usage site, resulting in invalid stalled scode value. Move calculation of scode value just before its only usage site to avoid stalled scode value. PR middle-end/115836 gcc/ChangeLog: * expmed.cc (emit_store_flag_1): Move calculation of scode just before its only usage site. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Also tested with original and minimized preprocessed source. Unfortunately, even with the minimized source, the compilation takes ~5 minutes, and IMO such a trivial fix does not warrant that high resource consumption. OK for master and release branches? Uros. diff --git a/gcc/expmed.cc b/gcc/expmed.cc index 8bbbc94a98c..154964bd068 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -5632,11 +5632,9 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, enum insn_code icode; machine_mode compare_mode; enum mode_class mclass; - enum rtx_code scode; if (unsignedp) code = unsigned_condition (code); - scode = swap_condition (code); /* If one operand is constant, make it the second one. Only do this if the other operand is not constant as well. */ @@ -5751,6 +5749,8 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, if (GET_MODE_CLASS (mode) == MODE_FLOAT) { + enum rtx_code scode = swap_condition (code); + tem = emit_cstore (target, icode, scode, mode, compare_mode, unsignedp, op1, op0, normalizep, target_mode); if (tem)