From patchwork Sun Dec 17 04:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 82324 Return-Path: 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 877DE3858424 for ; Sun, 17 Dec 2023 04:54:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id DBC1B3858D28 for ; Sun, 17 Dec 2023 04:54:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBC1B3858D28 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 DBC1B3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702788874; cv=none; b=P33sqgf0FXoJH+ST/xcGlM4w/YiFLoN5R1Krl+QHT0VuDoiQ24v629ZwwachacCl+e7jDUk3/gqf2FBRve1B8NPc5zhKIKIDH+mGQimc1ZTyET0oDl+EnkFInv9L0bQS+9JtmKgrR7cd/VpA+6/6pWbE8y62TOCvhXx6KtvEyAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702788874; c=relaxed/simple; bh=RLknZfWmV7/OEcppK8COcIvyAO4ddJUbG6QSmTVnjyE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=v983H0yQ8v5k67Fl98qKKmaepXxdTDESl4++Fzn/YoynHLMw3+KiW6XzTjrJb8neBYY99xQO0yw/lxUjCn8EnAb2sBTJ1sc+eKPGGGQ8yyDt8i9/xKWPG2ue4OoMz2AEPNzjvGIU72vmcIPiqTTSXVH/TCJVhtS4pliKcbS1J9E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d075392ff6so13794595ad.1 for ; Sat, 16 Dec 2023 20:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702788871; x=1703393671; darn=sourceware.org; h=in-reply-to:from:to:references:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=Y9gnjK/FhX3OAQjw8dIZXdWnbxDHXlmstcnJOHBaTcc=; b=Vq9+DtX6HaqWjgT3pWC/5AdVVV7iSyrpvfaxNu311t0yUeBo+MLwp0RsC2nkkoBV47 K+Gh6o7dB9WbO53RmQAwzSmSKmUWNo6P0CwfI4xebujo+zeWCnxxTDvcCVjOFNWXlT65 q1ooF5beN73O/ZNXwv1QHI92PteZ6Y74xVoYl3FDz/mtXgXKuIkqf8z5eBOipGMnoPNL 9CV+BW0cw2POfBKybH7OMR1oefTjQ1KfMx1oJtNG6/a5QL5Ve0oQNkXo0Vk0LbFrlwbZ su4UHbZ8eqRcpprK3trvrK6VshJ84hvB7StxAKTmLf7G6RTLWonSKIKE/TRqDMJwFY/h FFbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702788871; x=1703393671; h=in-reply-to:from:to:references:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Y9gnjK/FhX3OAQjw8dIZXdWnbxDHXlmstcnJOHBaTcc=; b=X2ln8pVB1DwzUuJo3+cMTRDYZhOR9TKP+JX78pMzmVBjYdk3VFmTmorKL0EMhU1qMS Mg5JrQR4d+C8mv4HnrWT1Sn+bwm5HnhtyJ/Jk7ERoC0b7lvtcFa13gTz+uyuXrbbxG2U hS/Zp/UjirNricLStVYoXG9xzpNgCQwuoctTbLEDH9wIqLm+Cm7pvPOz8pK2Ipyh9LYI m7+KvNA3EaFbO9uLRjCnNLlvrOlI7a1AfLP5glHANAvvU7cRBPjaCQZETRgHwd2p3/+Z v0dSa/9TZkYDsOsIlEMiTQhk+H1CPnwwAncYaAHerFOdWMK6LQuf6IZeyfomofIXVD5B N9Ag== X-Gm-Message-State: AOJu0YwFptaIroioFQX4QTMvtcAmDVmyli+yx4APRU5tMbnBSm9vRKny q3f5OJ1B+p2s7z57B4a38AWQQ+oZQoA= X-Google-Smtp-Source: AGHT+IFlSw6UBdLmOAhKq7+Ait1WVy4thm/2SeT/uQE8rIdXbpqWoBns9b59eskP2Gih539d1cI0Bw== X-Received: by 2002:a17:903:32c5:b0:1d0:6ffd:6118 with SMTP id i5-20020a17090332c500b001d06ffd6118mr17651935plr.58.1702788871121; Sat, 16 Dec 2023 20:54:31 -0800 (PST) Received: from [172.31.1.103] ([172.56.168.60]) by smtp.gmail.com with ESMTPSA id q16-20020a170902edd000b001d3aa447c96sm446117plk.73.2023.12.16.20.54.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Dec 2023 20:54:30 -0800 (PST) Message-ID: <6de3406e-b76a-4599-b946-10e431a2dd75@gmail.com> Date: Sat, 16 Dec 2023 21:54:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Fwd: Yet another fix for mcore-sim Content-Language: en-US References: To: apinski--- via Gdb-patches From: Jeff Law In-Reply-To: X-Forwarded-Message-Id: X-Spam-Status: No, score=-7.6 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, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Someday I'll type "sourceware.org" correctly on a consistent basis. -------- Forwarded Message -------- Subject: Yet another fix for mcore-sim Date: Sat, 16 Dec 2023 21:52:12 -0700 From: Jeff Law To: gdb-patches@sourcware.org This came up testing the CRC optimization work from Mariam@RAU. Basically to optimize some CRC loops into table lookups or carryless multiplies, we may need to do a bit reflection, which on the mcore processor is done using a rotate instruction. Unfortunately the simulator implementation of rotates has the exact same problem as we saw with right shifts. The input value may have been sign extended from 32 to 64 bits. When we rotate the extended value, we get those sign extension bits and thus the wrong result. The fix is the same. Rather than using a "long", use a uint32_t for the type of the temporary. This fixes a handful of tests in the GCC testsuite: > mcore-sim: gcc.c-torture/execute/20100805-1.c -O0 execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -O1 execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -O2 execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -O3 -g execution test > mcore-sim: gcc.c-torture/execute/20100805-1.c -Os execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O0 execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O1 execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O2 execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -O3 -g execution test > mcore-sim: gcc.c-torture/execute/20180112-1.c -Os execution test > mcore-sim: gcc.dg/20050922-1.c execution test > mcore-sim: gcc.dg/crc-25.c execution test > mcore-sim: gcc.dg/crc-26.c execution test > mcore-sim: gcc.dg/crc-8.c execution test > mcore-sim: gcc.dg/pr57233.c execution test The crc-* tests are Mariam's CRC optimizer tests. The rest are regression tests already in the GCC testsuite. OK for the trunk? Jeff diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index 8bfb745a11f..94e0a1675be 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -1015,7 +1015,7 @@ step_once (SIM_DESC sd, SIM_CPU *cpu) case 0x38: case 0x39: /* xsr, rotli */ { unsigned imm = IMM5; - unsigned long tmp = gr[RD]; + uint32_t tmp = gr[RD]; if (imm == 0) { int32_t cbit;