From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 156643858430 for ; Mon, 8 Jan 2024 07:56:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 156643858430 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 156643858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704700580; cv=none; b=ny5Y9MLmAh1GgCQWERVPRsGseVzmSdzyqgD7Q8XRy9bgcNO0GmVVVJqMNbFAXL/wFMBI/48H5GhTfIN7E2VVmxTy5BQNmHQGk8ZvbSjOZ9pXLpwgJ7jXBqOFgTPNOZEoTX5ym4EVsyvT3J+sgeXFW0MwE2b/ToXX/yppBVIuvDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704700580; c=relaxed/simple; bh=d0JfooSKpbAg4+8NT/MUb12e8Wyk/RWE33ZVkqam6DU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=mIMSIpVb4zJGtf+itCfSorkJGUEQo99adg2Hg5JCoct6xaw4nhGj3i3mbwg8WZe/x8B5hxLa5tCV752EmO4+zdKVs37xRRh8yTSfedK38r0cOxQbpMwiyf9pcZinActRwXSTjqrcbCp/a8yT4uBTLw0lfOPtVp13m2eUo3cj9ec= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2ccbbb5eb77so16105081fa.2 for ; Sun, 07 Jan 2024 23:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1704700576; x=1705305376; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TV5B94w+rZ0eZm6qFnm3QgpoAn5Sh5I0JYwyABvyiBc=; b=blUDrDCvy2BO2mNL7QT8x7r07LxV67MF565/6qt99poWSOUE7R8KIK2pavCZCbqBOq YFM4kv1uAIqCPFTptRFB/dUzYfe6mmz5+2PHj1EzY8CFQk0+qZzTBgGiPL8uVVY8q+xd WX4i4iHdBWLUbtIPpXFhtIob97h/VwGp3StGXZCe0Thtwi7ljtXhvr4sYG8CXguT1yYT 59oGajUh4NHGXp7Y5p3bS+7pCuZ8j862zKaYUsYnH8SGEMfJTBE5sIqiVQw7dRLS2NEN i59kkcnNLqUlNZuRhF+3M93J88lFAaEv52O9Ak2M+Tbb0EZWTdop400z2m8u3RQq8mLs TNBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704700576; x=1705305376; h=content-transfer-encoding:in-reply-to:autocrypt: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=TV5B94w+rZ0eZm6qFnm3QgpoAn5Sh5I0JYwyABvyiBc=; b=lOs/1yuj2nU0Qx2OWOl2iMjpY/fwJ+iWCR2C2bJ986fF0DK9vK7FAWwfQT2jDELs+J NE5TVH8qSOoz837JwTR+a5xDWAr/xuk0TIZ+D+LVr7fRVBYbAmj8+U7s3doCFAHTe5wl qsBbMKTq44TEyf2FUND7YQHrLWL/X0W3Tk19kfAgoPm/wb30fSwCDQADIeah9ZIjhW4o RrIMYhzTLJj9VbPMTLxmO5nCreJ2cUkZe1qJQI8OYdL9tXjRjtGvn9uD7cuvQwqb+fLq vGy43MKtVkNRTWpiEvEubWBh5v68TSxva6LeZtChaBnjzvDELTg5PWhXAUf3b0ClqjGS PWlA== X-Gm-Message-State: AOJu0YzVSiSVrRRzTo5dyHXqt/ElJb4OgVeaga0scQzcHfIoK4BhkmDW LzGjUtT8YM39haycqPYqu2HRQtFC3AF72AqFVzZ6Ry+z3w== X-Google-Smtp-Source: AGHT+IHhmBEvevdaH5L/PnyzTc9UdtMvYxUiUHUSI5Og71NLAnK/y7+plZuEGMQ+/1NpTswYWZiXTw== X-Received: by 2002:a2e:894d:0:b0:2cd:36ff:4d7c with SMTP id b13-20020a2e894d000000b002cd36ff4d7cmr1341538ljk.9.1704700576543; Sun, 07 Jan 2024 23:56:16 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id y11-20020a056e02118b00b003606cb03c2bsm2379238ili.74.2024.01.07.23.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jan 2024 23:56:15 -0800 (PST) Message-ID: <8662338c-e85a-4b84-a941-31170794dfe5@suse.com> Date: Mon, 8 Jan 2024 08:56:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86: add missing APX logic to cpu_flags_match() Content-Language: en-US To: "Cui, Lili" Cc: "H.J. Lu" , Binutils References: From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3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EGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3026.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 List-Id: On 08.01.2024 04:17, Cui, Lili wrote: >> As already indicated during review, we can't get away without certain >> adjustments here: Without these, respective {evex}-prefixed insns are >> assembled to APX encodings even when APX_F is turned off. >> >> While there also extend the respective comment in the opcode table, to >> explain why this construct is used. >> --- >> Strictly speaking we could go with just cpuid|APX_F in the templates, with the >> assertions dropped and instead an "else" added. But I think we're better off >> this way, for being less prone to introducing mistakes later on. >> >> The resulting diagnostics aren't quite correct (because of not mentioning the >> {evex} prefix, which really is what's the problem there), but improving >> diagnostics is a wider topic anyway. > > Oh, get it, thanks. > Currently, a lot of ugly special handling has been added to i386 in order to merge these vex/evex insns, which increases the complexity of the code. Personally, I don't think it's worth it. Other issues may arise later. Well, if it was just for the saving of a few templates, it probably indeed wouldn't be worth it. But the set of templates saved is quite significant overall, hence why I did it in the first place. The number of templates to consult does, after all, matter when processing a respective insn. >> --- a/gas/config/tc-i386.c >> +++ b/gas/config/tc-i386.c >> @@ -1940,6 +1940,30 @@ cpu_flags_match (const insn_template *t) >> any.bitfield.cpuavx512vl = 0; >> } >> } >> + >> + /* Dual non-APX/APX templates need massaging from what APX_F() in the >> + opcode table has produced. While the direct transformation of the >> + incoming cpuid&(cpuid|APX_F) would be to cpuid&(cpuid) / >> cpuid&(APX_F) >> + respectively, it's cheaper to move to just cpuid / cpuid&APX_F >> + instead. */ >> + if (any.bitfield.cpuapx_f >> + && (any.bitfield.cpubmi || any.bitfield.cpubmi2 >> + || any.bitfield.cpuavx512f || any.bitfield.cpuavx512bw >> + || any.bitfield.cpuavx512dq || any.bitfield.cpuamx_tile >> + || any.bitfield.cpucmpccxadd)) >> + { >> + /* These checks (verifying that APX_F() was properly used in the >> + opcode table entry) make sure there's no need for an "else" to >> + the "if()" below. */ >> + gas_assert (!cpu_flags_all_zero (&all)); >> + cpu = cpu_flags_and (all, any); >> + gas_assert (cpu_flags_equal (&cpu, &all)); >> + >> + if (need_evex_encoding (t)) >> + all = any; >> + > >> + memset (&any, 0, sizeof (any)); > > Wouldn't it make sense to put it in the else branch and clean out APX-F specifically? Just like you did before. > > if (need_evex_encoding (t)) > all = any; > else > any.bitfield.cpuapx_f = 0; That was an alternative I did consider, yes, but the way I've done it is overall more self-consistent imo, at the expense of being less consistent with the AVX/AVX512 logic (the moving of "any" to "all" isn't consistent with that anyway). Jan