From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 9B9483858D3C for ; Fri, 24 Nov 2023 11:09:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B9483858D3C 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 9B9483858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700824194; cv=none; b=wwLMhZ8MhaWG9I2+f5vd1ml3edT0gOeCGPOQvNx4b4LZ707o36/3eRa+L0eSJ4G2Xe436qOi1OC8oBgyxFyf7GhSmK8eeZM7wOmsuQM+zT/ZMyi6xqTLIEYyxvlUlnyqEdHRiYeVlIk+LfzLDCAvUJB6t6MA5T1JKm/v4EVNUh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700824194; c=relaxed/simple; bh=m0p0+zp1nkRWZrE87a7yUQQB8YWmLczJRODR1CiKQUk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=QBIEagXoBpnnGsrWRO3Qygb4/7wtjWWYuguBHz/IV2ADeG4cAkayQQAAs2UF+17oUUbY2tDD4Pc5fY+kUKjNhlk4wszxrr1VquVdSqyGoDIl8X1eWvLZGlZQXwFzqJFdvkxwSOM/YpwYeC+rpLjA6056CWLsYOLam0EGMqCgaMs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54917ef6c05so2436727a12.1 for ; Fri, 24 Nov 2023 03:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700824191; x=1701428991; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sX0DJr40+BamaVKpor5vn3oGcAQyAZjbwh1caVHpbtg=; b=dZTB6RTk8TvE8vOtBQTKSN4B3zwprysFGWXcVVGhkJbyMsEqsBvH725/xodjCpd4QG p4jEXp3EU3zTKCRTe943l2aWSixkUmINXEicOr6dTzsFJnTLaAuH5EruQj4msiWjiwWP aPL68fQG/vstt/CMwmyNIBHGIutWpIYicDf36w/mwj3/IbdjRqezU0ZVqjF20dyGeIcL wKgyLsrmxDjHrfnxISJOXDgKidun8UGBCxEneMwfCIGBgKMxqbYmjjn/m98Ccwi22Ehb jfKIf+HLnIKrQPyZb+Zfu1Rzk7idZFlW3GJnGaH//r0rE2zHMTSOL3aIME2D1kVqdKGW nyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700824191; x=1701428991; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sX0DJr40+BamaVKpor5vn3oGcAQyAZjbwh1caVHpbtg=; b=kfPkskTJR5igrW3OcZeiYumHGtM7LPQPBULfDeB1f+DSUR0qUqz0Lqu4E2QliJlrEl KgeSW9jqW2UGqRLmJ/P+w+Fans8bbaFpWhAiwpS5h3iEz/iA0d2RtRJGWHmuph/1KQ35 WSKvJM/AnCqmxVnkFfVIc1F8BefcWe7N1bEGr74CXCmPJ5ka298ypF1cIZXWg+Mf4TlQ qOS/26FWJD0aF/IpIW1B6N8lr0s/GfOZy+N7oeXjmxBpFN4q2kfjKwGd103IV+Ntcty6 OyhFYcmKKA5cWafQj5u+AKekfy32iFh3SfJulHfDZ41PSQA9mgwny++6tTtjAdMnZgqr Iwrw== X-Gm-Message-State: AOJu0Yy8evgoFe+QE/SHWir9zFjFviuajUWsKsfgbZBNeYHeAHF4hgoE egEk2EWqZn2pRh9FS21MkPAD7Xl6Chwq4qgeHV02xTI6shg= X-Google-Smtp-Source: AGHT+IE0YoHQHpR/nNg7WQqBuIv+OT5WPNq6OZd45kgx8v2Uu43VS2VsS9tmgqCypnf1QKDSoRPS5lsH6P3ywj2etdM= X-Received: by 2002:a50:cd95:0:b0:534:8bdf:a258 with SMTP id p21-20020a50cd95000000b005348bdfa258mr1573699edi.31.1700824190922; Fri, 24 Nov 2023 03:09:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Uros Bizjak Date: Fri, 24 Nov 2023 12:09:39 +0100 Message-ID: Subject: Re: [PATCH] i386: Fix ICE during cbranchv16qi4 expansion [PR112681] To: Jakub Jelinek Cc: Hongtao Liu , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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 Fri, Nov 24, 2023 at 9:31=E2=80=AFAM Jakub Jelinek wr= ote: > > Hi! > > The following testcase ICEs, because cbranchv16qi4 expansion calls > ix86_expand_branch with op1 being a pre-AVX unaligned memory and > ix86_expand_branch emits a xorv16qi3 instruction without making sure > the operand predicates are satisfied. > While I could manually check if the argument (or both?) doesn't > match vector_operand predicate (apparently this one or bcst_vector_operan= d > is used in all integral 16+ bytes *xorv*3 instructions) force it into a > register, but as all gen_xorv*3 expanders call > ix86_expand_vector_logical_operator, it seems easier to just call that > function which ensures the right thing happens. Calling the individual > gen_xorv*3 functions would mean ugly switch on the modes and using high > level expand_simple_binop here seems too high level to me. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2023-11-23 Jakub Jelinek > > PR target/112681 > * config/i386/i386-expand.cc (ix86_expand_branch): Use > ix86_expand_vector_logical_operator to expand vector XOR rather t= han > gen_rtx_SET on gen_rtx_XOR. > > * gcc.target/i386/sse4-pr112681.c: New test. OK. Thanks, Uros. > > --- gcc/config/i386/i386-expand.cc.jj 2023-11-21 09:31:35.792395304 +01= 00 > +++ gcc/config/i386/i386-expand.cc 2023-11-23 20:57:57.128721762 +01= 00 > @@ -2453,7 +2453,8 @@ ix86_expand_branch (enum rtx_code code, > /* Generate XOR since we can't check that one operand is zero > vector. */ > tmp =3D gen_reg_rtx (mode); > - emit_insn (gen_rtx_SET (tmp, gen_rtx_XOR (mode, op0, op1))); > + rtx ops[3] =3D { tmp, op0, op1 }; > + ix86_expand_vector_logical_operator (XOR, mode, ops); > tmp =3D gen_lowpart (p_mode, tmp); > emit_insn (gen_rtx_SET (gen_rtx_REG (CCZmode, FLAGS_REG), > gen_rtx_UNSPEC (CCZmode, > --- gcc/testsuite/gcc.target/i386/sse4-pr112681.c.jj 2023-11-23 21:01:= 57.983361917 +0100 > +++ gcc/testsuite/gcc.target/i386/sse4-pr112681.c 2023-11-23 21:01:= 42.054584121 +0100 > @@ -0,0 +1,11 @@ > +/* PR target/112681 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -msse4 -mno-avx" } */ > + > +struct S { void *c; char d[16]; } a, b; > + > +int > +foo (void) > +{ > + return __builtin_memcmp (a.d, b.d, sizeof (a.d)) !=3D 0; > +} > > Jakub >