From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id B131C3858C62 for ; Sat, 29 Jul 2023 16:13:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B131C3858C62 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cZk17JkYBSnaLkDsNwIbfkxxhcNJbxVgdU7ir7QbgQ8=; b=I5Xw4n61Uxq8mvbA8HQp73BPbD K1g4BqQ53KsGbvDFL6QE2PSZpN2HTdjW0dtB03Pq7ros7kMFqMG/kD8h/M3yIlxIPboCCPCvuL+Rt laO6IAkK3bgNHk8wt8YVpmWRU9t5LeFQ4r5jXkIUOKJ3fOtCNZWrcljYp55MqtDzadMYnzPv/IZWC jjNV4Td9Gkp1tSbpy1oGUjjT2eYnZtU82w1ppGxrmT2bh4aHhjGziUdfdSmoYFBk59xHdsZkzsRpj 59RTyEEItyZK0EalfAhg84KtWMrpOA05T0G5C5tYJcX6So5d4JMBxOfkP2JzyduwF5m/8EF08mp9Y 8HDfq4bA==; Received: from [185.62.158.67] (port=58816 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qPmZP-0006SI-1d for gcc-patches@gcc.gnu.org; Sat, 29 Jul 2023 12:13:31 -0400 From: "Roger Sayle" To: Subject: [Committed] Use QImode for offsets in zero_extract/sign_extract in i386.md (take #2) Date: Sat, 29 Jul 2023 17:13:29 +0100 Message-ID: <002701d9c237$9e0c3410$da249c30$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0028_01D9C23F.FFD11140" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdnCNxyvPFHHiHsxSWOmGyG2xTKvTg== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,MEDICAL_SUBJECT,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: This is a multipart message in MIME format. ------=_NextPart_000_0028_01D9C23F.FFD11140 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch reattempts to change the ZERO_EXTRACTs and SIGN_EXTRACTs in i386.md to consistently use QImode for bit offsets (i.e. third and fourth operands), matching the use of QImode for bit counts in shifts and rotates. This iteration corrects the "ne:QI" vs "eq:QI" mistake in the previous version, which was responsible for PR 110787 and PR 110790 and so was rapidly reverted last weekend. New test cases have been added to check the correct behaviour. This patch has been tested on x86_64-pc-linux-gnu with and without --enable-languages="all", with make bootstrap and make -k check, both with and without --target_board=unix{-m32} with no new failures. Committed to mainline as an obvious fix to the previously approved patch. Sorry again for the temporary inconvenience, and thanks to Rainer Orth for identifying/confirming the problematic patch. 2023-07-29 Roger Sayle gcc/ChangeLog PR target/110790 * config/i386/i386.md (extv): Use QImode for offsets. (extzv): Likewise. (insv): Likewise. (*testqi_ext_3): Likewise. (*btr_2): Likewise. (define_split): Likewise. (*btsq_imm): Likewise. (*btrq_imm): Likewise. (*btcq_imm): Likewise. (define_peephole2 x3): Likewise. (*bt): Likewise (*bt_mask): New define_insn_and_split. (*jcc_bt): Use QImode for offsets. (*jcc_bt_1): Delete obsolete pattern. (*jcc_bt_mask): Use QImode offsets. (*jcc_bt_mask_1): Likewise. (define_split): Likewise. (*bt_setcqi): Likewise. (*bt_setncqi): Likewise. (*bt_setnc): Likewise. (*bt_setncqi_2): Likewise. (*bt_setc_mask): New define_insn_and_split. (bmi2_bzhi_3): Use QImode offsets. (*bmi2_bzhi_3): Likewise. (*bmi2_bzhi_3_1): Likewise. (*bmi2_bzhi_3_1_ccz): Likewise. (@tbm_bextri_): Likewise. gcc/testsuite/ChangeLog PR target/110790 * gcc.target/i386/pr110790-1.c: New test case. * gcc.target/i386/pr110790-2.c: Likewise. ------=_NextPart_000_0028_01D9C23F.FFD11140 Content-Type: text/plain; name="patchqi2.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchqi2.txt" diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md=0A= index 4db210c..efac228 100644=0A= --- a/gcc/config/i386/i386.md=0A= +++ b/gcc/config/i386/i386.md=0A= @@ -3312,8 +3312,8 @@=0A= (define_expand "extv"=0A= [(set (match_operand:SWI24 0 "register_operand")=0A= (sign_extract:SWI24 (match_operand:SWI24 1 "register_operand")=0A= - (match_operand:SI 2 "const_int_operand")=0A= - (match_operand:SI 3 "const_int_operand")))]=0A= + (match_operand:QI 2 "const_int_operand")=0A= + (match_operand:QI 3 "const_int_operand")))]=0A= ""=0A= {=0A= /* Handle extractions from %ah et al. */=0A= @@ -3340,8 +3340,8 @@=0A= (define_expand "extzv"=0A= [(set (match_operand:SWI248 0 "register_operand")=0A= (zero_extract:SWI248 (match_operand:SWI248 1 "register_operand")=0A= - (match_operand:SI 2 "const_int_operand")=0A= - (match_operand:SI 3 "const_int_operand")))]=0A= + (match_operand:QI 2 "const_int_operand")=0A= + (match_operand:QI 3 "const_int_operand")))]=0A= ""=0A= {=0A= if (ix86_expand_pextr (operands))=0A= @@ -3428,8 +3428,8 @@=0A= =0A= (define_expand "insv"=0A= [(set (zero_extract:SWI248 (match_operand:SWI248 0 "register_operand")=0A= - (match_operand:SI 1 "const_int_operand")=0A= - (match_operand:SI 2 "const_int_operand"))=0A= + (match_operand:QI 1 "const_int_operand")=0A= + (match_operand:QI 2 "const_int_operand"))=0A= (match_operand:SWI248 3 "register_operand"))]=0A= ""=0A= {=0A= @@ -10788,8 +10788,8 @@=0A= (match_operator 1 "compare_operator"=0A= [(zero_extract:SWI248=0A= (match_operand 2 "int_nonimmediate_operand" "rm")=0A= - (match_operand 3 "const_int_operand")=0A= - (match_operand 4 "const_int_operand"))=0A= + (match_operand:QI 3 "const_int_operand")=0A= + (match_operand:QI 4 "const_int_operand"))=0A= (const_int 0)]))]=0A= "/* Ensure that resulting mask is zero or sign extended operand. */=0A= INTVAL (operands[4]) >=3D 0=0A= @@ -15965,7 +15965,7 @@=0A= [(set (zero_extract:HI=0A= (match_operand:SWI12 0 "nonimmediate_operand")=0A= (const_int 1)=0A= - (zero_extend:SI (match_operand:QI 1 "register_operand")))=0A= + (match_operand:QI 1 "register_operand"))=0A= (const_int 0))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_USE_BT && ix86_pre_reload_split ()"=0A= @@ -15989,7 +15989,7 @@=0A= [(set (zero_extract:HI=0A= (match_operand:SWI12 0 "register_operand")=0A= (const_int 1)=0A= - (zero_extend:SI (match_operand:QI 1 "register_operand")))=0A= + (match_operand:QI 1 "register_operand"))=0A= (const_int 0))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_USE_BT && ix86_pre_reload_split ()"=0A= @@ -16016,7 +16016,7 @@=0A= (define_insn "*btsq_imm"=0A= [(set (zero_extract:DI (match_operand:DI 0 "nonimmediate_operand" = "+rm")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (const_int 1))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_64BIT && (TARGET_USE_BT || reload_completed)"=0A= @@ -16029,7 +16029,7 @@=0A= (define_insn "*btrq_imm"=0A= [(set (zero_extract:DI (match_operand:DI 0 "nonimmediate_operand" = "+rm")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (const_int 0))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_64BIT && (TARGET_USE_BT || reload_completed)"=0A= @@ -16042,7 +16042,7 @@=0A= (define_insn "*btcq_imm"=0A= [(set (zero_extract:DI (match_operand:DI 0 "nonimmediate_operand" = "+rm")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (not:DI (zero_extract:DI (match_dup 0) (const_int 1) (match_dup 1))))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_64BIT && (TARGET_USE_BT || reload_completed)"=0A= @@ -16059,7 +16059,7 @@=0A= (parallel [(set (zero_extract:DI=0A= (match_operand:DI 0 "nonimmediate_operand")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (const_int 1))=0A= (clobber (reg:CC FLAGS_REG))])]=0A= "TARGET_64BIT && !TARGET_USE_BT"=0A= @@ -16083,7 +16083,7 @@=0A= (parallel [(set (zero_extract:DI=0A= (match_operand:DI 0 "nonimmediate_operand")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (const_int 0))=0A= (clobber (reg:CC FLAGS_REG))])]=0A= "TARGET_64BIT && !TARGET_USE_BT"=0A= @@ -16107,7 +16107,7 @@=0A= (parallel [(set (zero_extract:DI=0A= (match_operand:DI 0 "nonimmediate_operand")=0A= (const_int 1)=0A= - (match_operand 1 "const_0_to_63_operand"))=0A= + (match_operand:QI 1 "const_0_to_63_operand"))=0A= (not:DI (zero_extract:DI=0A= (match_dup 0) (const_int 1) (match_dup 1))))=0A= (clobber (reg:CC FLAGS_REG))])]=0A= @@ -16135,14 +16135,14 @@=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 0 "nonimmediate_operand" "r,m")=0A= (const_int 1)=0A= - (match_operand:SI 1 "nonmemory_operand" "r,"))=0A= + (match_operand:QI 1 "nonmemory_operand" "q,"))=0A= (const_int 0)))]=0A= ""=0A= {=0A= switch (get_attr_mode (insn))=0A= {=0A= case MODE_SI:=0A= - return "bt{l}\t{%1, %k0|%k0, %1}";=0A= + return "bt{l}\t{%k1, %k0|%k0, %k1}";=0A= =0A= case MODE_DI:=0A= return "bt{q}\t{%q1, %0|%0, %q1}";=0A= @@ -16160,13 +16160,36 @@=0A= (const_string "SI")=0A= (const_string "")))])=0A= =0A= +(define_insn_and_split "*bt_mask"=0A= + [(set (reg:CCC FLAGS_REG)=0A= + (compare:CCC=0A= + (zero_extract:SWI48=0A= + (match_operand:SWI48 0 "nonimmediate_operand" "r,m")=0A= + (const_int 1)=0A= + (subreg:QI=0A= + (and:SWI248=0A= + (match_operand:SWI248 1 "register_operand")=0A= + (match_operand 2 "const_int_operand")) 0))=0A= + (const_int 0)))]=0A= + "TARGET_USE_BT=0A= + && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (mode)-1))=0A= + =3D=3D GET_MODE_BITSIZE (mode)-1=0A= + && ix86_pre_reload_split ()"=0A= + "#"=0A= + "&& 1"=0A= + [(set (reg:CCC FLAGS_REG)=0A= + (compare:CCC=0A= + (zero_extract:SWI48 (match_dup 0) (const_int 1) (match_dup 1))=0A= + (const_int 0)))]=0A= + "operands[1] =3D gen_lowpart (QImode, operands[1]);")=0A= +=0A= (define_insn_and_split "*jcc_bt"=0A= [(set (pc)=0A= (if_then_else (match_operator 0 "bt_comparison_operator"=0A= [(zero_extract:SWI48=0A= (match_operand:SWI48 1 "nonimmediate_operand")=0A= (const_int 1)=0A= - (match_operand:SI 2 "nonmemory_operand"))=0A= + (match_operand:QI 2 "nonmemory_operand"))=0A= (const_int 0)])=0A= (label_ref (match_operand 3))=0A= (pc)))=0A= @@ -16196,39 +16219,6 @@=0A= PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));=0A= })=0A= =0A= -(define_insn_and_split "*jcc_bt_1"=0A= - [(set (pc)=0A= - (if_then_else (match_operator 0 "bt_comparison_operator"=0A= - [(zero_extract:SWI48=0A= - (match_operand:SWI48 1 "register_operand")=0A= - (const_int 1)=0A= - (zero_extend:SI=0A= - (match_operand:QI 2 "register_operand")))=0A= - (const_int 0)])=0A= - (label_ref (match_operand 3))=0A= - (pc)))=0A= - (clobber (reg:CC FLAGS_REG))]=0A= - "(TARGET_USE_BT || optimize_function_for_size_p (cfun))=0A= - && ix86_pre_reload_split ()"=0A= - "#"=0A= - "&& 1"=0A= - [(set (reg:CCC FLAGS_REG)=0A= - (compare:CCC=0A= - (zero_extract:SWI48=0A= - (match_dup 1)=0A= - (const_int 1)=0A= - (match_dup 2))=0A= - (const_int 0)))=0A= - (set (pc)=0A= - (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)])=0A= - (label_ref (match_dup 3))=0A= - (pc)))]=0A= -{=0A= - operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);=0A= - operands[0] =3D shallow_copy_rtx (operands[0]);=0A= - PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));=0A= -})=0A= -=0A= ;; Avoid useless masking of bit offset operand.=0A= (define_insn_and_split "*jcc_bt_mask"=0A= [(set (pc)=0A= @@ -16236,8 +16226,8 @@=0A= [(zero_extract:SWI48=0A= (match_operand:SWI48 1 "register_operand")=0A= (const_int 1)=0A= - (and:SI=0A= - (match_operand:SI 2 "register_operand")=0A= + (and:QI=0A= + (match_operand:QI 2 "register_operand")=0A= (match_operand 3 "const_int_operand")))])=0A= (label_ref (match_operand 4))=0A= (pc)))=0A= @@ -16264,23 +16254,23 @@=0A= PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));=0A= })=0A= =0A= -(define_insn_and_split "*jcc_bt_mask_1"=0A= +;; Avoid useless masking of bit offset operand.=0A= +(define_insn_and_split "*jcc_bt_mask_1"=0A= [(set (pc)=0A= - (if_then_else (match_operator 0 "bt_comparison_operator"=0A= + (if_then_else (match_operator 0 "bt_comparison_operator"=0A= [(zero_extract:SWI48=0A= (match_operand:SWI48 1 "register_operand")=0A= (const_int 1)=0A= - (zero_extend:SI=0A= - (subreg:QI=0A= - (and=0A= - (match_operand 2 "int248_register_operand")=0A= - (match_operand 3 "const_int_operand")) 0)))])=0A= + (subreg:QI=0A= + (and:SWI248=0A= + (match_operand:SWI248 2 "register_operand")=0A= + (match_operand 3 "const_int_operand")) 0))])=0A= (label_ref (match_operand 4))=0A= (pc)))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "(TARGET_USE_BT || optimize_function_for_size_p (cfun))=0A= - && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (mode)-1))=0A= - =3D=3D GET_MODE_BITSIZE (mode)-1=0A= + && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (mode)-1))=0A= + =3D=3D GET_MODE_BITSIZE (mode)-1=0A= && ix86_pre_reload_split ()"=0A= "#"=0A= "&& 1"=0A= @@ -16296,10 +16286,9 @@=0A= (label_ref (match_dup 4))=0A= (pc)))]=0A= {=0A= - operands[2] =3D force_reg (GET_MODE (operands[2]), operands[2]);=0A= - operands[2] =3D gen_lowpart (SImode, operands[2]);=0A= operands[0] =3D shallow_copy_rtx (operands[0]);=0A= PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0])));=0A= + operands[2] =3D gen_lowpart (QImode, operands[2]);=0A= })=0A= =0A= ;; Help combine recognize bt followed by cmov=0A= @@ -16310,7 +16299,7 @@=0A= [(zero_extract:SWI48=0A= (match_operand:SWI48 1 "register_operand")=0A= (const_int 1)=0A= - (zero_extend:SI (match_operand:QI 2 "register_operand")))=0A= + (match_operand:QI 2 "register_operand"))=0A= (const_int 0)])=0A= (match_operand:SWI248 3 "nonimmediate_operand")=0A= (match_operand:SWI248 4 "nonimmediate_operand")))]=0A= @@ -16328,7 +16317,6 @@=0A= {=0A= if (GET_CODE (operands[5]) =3D=3D EQ)=0A= std::swap (operands[3], operands[4]);=0A= - operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);=0A= })=0A= =0A= ;; Help combine recognize bt followed by setc=0A= @@ -16337,7 +16325,7 @@=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "register_operand")=0A= (const_int 1)=0A= - (zero_extend:SI (match_operand:QI 2 "register_operand"))))=0A= + (match_operand:QI 2 "register_operand")))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_USE_BT && ix86_pre_reload_split ()"=0A= "#"=0A= @@ -16347,8 +16335,7 @@=0A= (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2))=0A= (const_int 0)))=0A= (set (match_dup 0)=0A= - (eq:QI (reg:CCC FLAGS_REG) (const_int 0)))]=0A= - "operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);")=0A= + (eq:QI (reg:CCC FLAGS_REG) (const_int 0)))])=0A= =0A= ;; Help combine recognize bt followed by setnc=0A= (define_insn_and_split "*bt_setncqi"=0A= @@ -16368,8 +16355,7 @@=0A= (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2))=0A= (const_int 0)))=0A= (set (match_dup 0)=0A= - (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))]=0A= - "operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);")=0A= + (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))])=0A= =0A= (define_insn_and_split "*bt_setnc"=0A= [(set (match_operand:SWI48 0 "register_operand")=0A= @@ -16389,10 +16375,7 @@=0A= (set (match_dup 3)=0A= (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))=0A= (set (match_dup 0) (zero_extend:SWI48 (match_dup 3)))]=0A= -{=0A= - operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);=0A= - operands[3] =3D gen_reg_rtx (QImode);=0A= -})=0A= + "operands[3] =3D gen_reg_rtx (QImode);")=0A= =0A= ;; Help combine recognize bt followed by setnc (PR target/110588)=0A= (define_insn_and_split "*bt_setncqi_2"=0A= @@ -16401,7 +16384,7 @@=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "register_operand")=0A= (const_int 1)=0A= - (zero_extend:SI (match_operand:QI 2 "register_operand")))=0A= + (match_operand:QI 2 "register_operand"))=0A= (const_int 0)))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_USE_BT && ix86_pre_reload_split ()"=0A= @@ -16412,8 +16395,36 @@=0A= (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2))=0A= (const_int 0)))=0A= (set (match_dup 0)=0A= - (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))]=0A= - "operands[2] =3D lowpart_subreg (SImode, operands[2], QImode);")=0A= + (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))])=0A= +=0A= +;; Help combine recognize bt followed by setc=0A= +(define_insn_and_split "*bt_setc_mask"=0A= + [(set (match_operand:SWI48 0 "register_operand")=0A= + (zero_extract:SWI48=0A= + (match_operand:SWI48 1 "register_operand")=0A= + (const_int 1)=0A= + (subreg:QI=0A= + (and:SWI48=0A= + (match_operand:SWI48 2 "register_operand")=0A= + (match_operand 3 "const_int_operand")) 0)))=0A= + (clobber (reg:CC FLAGS_REG))]=0A= + "TARGET_USE_BT=0A= + && (INTVAL (operands[3]) & (GET_MODE_BITSIZE (mode)-1))=0A= + =3D=3D GET_MODE_BITSIZE (mode)-1=0A= + && ix86_pre_reload_split ()"=0A= + "#"=0A= + "&& 1"=0A= + [(set (reg:CCC FLAGS_REG)=0A= + (compare:CCC=0A= + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2))=0A= + (const_int 0)))=0A= + (set (match_dup 3)=0A= + (eq:QI (reg:CCC FLAGS_REG) (const_int 0)))=0A= + (set (match_dup 0) (zero_extend:SWI48 (match_dup 3)))]=0A= +{=0A= + operands[2] =3D gen_lowpart (QImode, operands[2]);=0A= + operands[3] =3D gen_reg_rtx (QImode);=0A= +})=0A= =0C=0A= ;; Store-flag instructions.=0A= =0A= @@ -18708,46 +18719,29 @@=0A= [(parallel=0A= [(set (match_operand:SWI48 0 "register_operand")=0A= (if_then_else:SWI48=0A= - (ne:QI (and:SWI48 (match_operand:SWI48 2 "register_operand")=0A= - (const_int 255))=0A= + (ne:QI (match_operand:QI 2 "register_operand")=0A= (const_int 0))=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "nonimmediate_operand")=0A= - (umin:SWI48 (and:SWI48 (match_dup 2) (const_int 255))=0A= - (match_dup 3))=0A= + (umin:QI (match_dup 2) (match_dup 3))=0A= (const_int 0))=0A= (const_int 0)))=0A= (clobber (reg:CC FLAGS_REG))])]=0A= "TARGET_BMI2"=0A= - "operands[3] =3D GEN_INT ( * BITS_PER_UNIT);")=0A= +{=0A= + operands[2] =3D gen_lowpart (QImode, operands[2]);=0A= + operands[3] =3D GEN_INT ( * BITS_PER_UNIT);=0A= +})=0A= =0A= (define_insn "*bmi2_bzhi_3"=0A= [(set (match_operand:SWI48 0 "register_operand" "=3Dr")=0A= (if_then_else:SWI48=0A= - (ne:QI (and:SWI48 (match_operand:SWI48 2 "register_operand" "r")=0A= - (const_int 255))=0A= + (ne:QI (match_operand:QI 2 "register_operand" "q")=0A= (const_int 0))=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "nonimmediate_operand" "rm")=0A= - (umin:SWI48 (and:SWI48 (match_dup 2) (const_int 255))=0A= - (match_operand:SWI48 3 "const_int_operand"))=0A= - (const_int 0))=0A= - (const_int 0)))=0A= - (clobber (reg:CC FLAGS_REG))]=0A= - "TARGET_BMI2 && INTVAL (operands[3]) =3D=3D * = BITS_PER_UNIT"=0A= - "bzhi\t{%2, %1, %0|%0, %1, %2}"=0A= - [(set_attr "type" "bitmanip")=0A= - (set_attr "prefix" "vex")=0A= - (set_attr "mode" "")])=0A= -=0A= -(define_insn "*bmi2_bzhi_3_1"=0A= - [(set (match_operand:SWI48 0 "register_operand" "=3Dr")=0A= - (if_then_else:SWI48=0A= - (ne:QI (match_operand:QI 2 "register_operand" "r") (const_int 0))=0A= - (zero_extract:SWI48=0A= - (match_operand:SWI48 1 "nonimmediate_operand" "rm")=0A= - (umin:SWI48 (zero_extend:SWI48 (match_dup 2))=0A= - (match_operand:SWI48 3 "const_int_operand"))=0A= + (umin:QI (match_dup 2)=0A= + (match_operand:QI 3 "const_int_operand"))=0A= (const_int 0))=0A= (const_int 0)))=0A= (clobber (reg:CC FLAGS_REG))]=0A= @@ -18764,8 +18758,8 @@=0A= (ne:QI (match_operand:QI 2 "register_operand" "r") (const_int 0))=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "nonimmediate_operand" "rm")=0A= - (umin:SWI48 (zero_extend:SWI48 (match_dup 2))=0A= - (match_operand:SWI48 3 "const_int_operand"))=0A= + (umin:QI (match_dup 2)=0A= + (match_operand:QI 3 "const_int_operand"))=0A= (const_int 0))=0A= (const_int 0))=0A= (const_int 0)))=0A= @@ -18864,8 +18858,8 @@=0A= [(set (match_operand:SWI48 0 "register_operand" "=3Dr")=0A= (zero_extract:SWI48=0A= (match_operand:SWI48 1 "nonimmediate_operand" "rm")=0A= - (match_operand 2 "const_0_to_255_operand")=0A= - (match_operand 3 "const_0_to_255_operand")))=0A= + (match_operand:QI 2 "const_0_to_255_operand")=0A= + (match_operand:QI 3 "const_0_to_255_operand")))=0A= (clobber (reg:CC FLAGS_REG))]=0A= "TARGET_TBM"=0A= {=0A= diff --git a/gcc/testsuite/gcc.target/i386/pr110790-1.c = b/gcc/testsuite/gcc.target/i386/pr110790-1.c=0A= new file mode 100644=0A= index 0000000..71733c3=0A= --- /dev/null=0A= +++ b/gcc/testsuite/gcc.target/i386/pr110790-1.c=0A= @@ -0,0 +1,33 @@=0A= +/* { dg-do run } */=0A= +/* { dg-options "-O2" } */=0A= +typedef unsigned long int mp_limb_t;=0A= +typedef const mp_limb_t * mp_srcptr;=0A= +=0A= +__attribute__((noipa))=0A= +int=0A= +refmpn_tstbit_bad (mp_srcptr ptr, unsigned long bit)=0A= +{=0A= + return (((ptr)[(bit)/(32 - 0)] & (((mp_limb_t) 1L) << ((bit)%(32 - = 0)))) !=3D 0);=0A= +}=0A= +=0A= +__attribute__((noipa, optimize(0)))=0A= +int=0A= +refmpn_tstbit_good (mp_srcptr ptr, unsigned long bit)=0A= +{=0A= + return (((ptr)[(bit)/(32 - 0)] & (((mp_limb_t) 1L) << ((bit)%(32 - = 0)))) !=3D 0);=0A= +}=0A= +=0A= +__attribute__((noipa))=0A= +int=0A= +refmpn_tstbit (mp_srcptr ptr, unsigned long bit)=0A= +{=0A= + if (refmpn_tstbit_bad (ptr, bit) !=3D refmpn_tstbit_good (ptr, bit)) {=0A= + __builtin_trap();=0A= + }=0A= + return refmpn_tstbit_bad (ptr, bit);=0A= +}=0A= +=0A= +int main(){=0A= + unsigned long num[] =3D { 0x3801ff9f, 0x0, 0x0, 0x0 };=0A= + refmpn_tstbit(num, 0);=0A= +}=0A= diff --git a/gcc/testsuite/gcc.target/i386/pr110790-2.c = b/gcc/testsuite/gcc.target/i386/pr110790-2.c=0A= new file mode 100644=0A= index 0000000..8b9d650=0A= --- /dev/null=0A= +++ b/gcc/testsuite/gcc.target/i386/pr110790-2.c=0A= @@ -0,0 +1,13 @@=0A= +/* { dg-do compile } */=0A= +/* { dg-options "-O2" } */=0A= +typedef unsigned long int mp_limb_t;=0A= +typedef const mp_limb_t * mp_srcptr;=0A= +=0A= +int=0A= +refmpn_tstbit_bad (mp_srcptr ptr, unsigned long bit)=0A= +{=0A= + return (((ptr)[(bit)/(32 - 0)] & (((mp_limb_t) 1L) << ((bit)%(32 - = 0)))) !=3D 0);=0A= +}=0A= +=0A= +/* { dg-final { scan-assembler "bt\[ql\]" } } */=0A= +/* { dg-final { scan-assembler "setc" } } */=0A= ------=_NextPart_000_0028_01D9C23F.FFD11140--