From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 37AC8385742A for ; Mon, 13 Jun 2022 03:49:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37AC8385742A Received: by mail-oi1-x230.google.com with SMTP id l81so6410854oif.9 for ; Sun, 12 Jun 2022 20:49:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LQkbqPlVtPRMcMOm9fONwzmQ03g+CHskJY0KSolvSvk=; b=cDkjKWbrKmmiwpDWW+QGPAzD1sFkLpDNpJDZSFnq/4dzChp4nb+eRQHKkntFewcnKo U/Fk1Y5ryd7x7KlEp7HffqwkuSevxgo7cgQn3se62LvYaUMNl/PDNYQEZuQ9syVFe1X8 E6e8J8ZY+NSt4inRMF3PvvoXfglIXQiZpOVAAzeSep1CJe/Qblk04rcWqVydlle2pb+3 41BJOBfxq+3yAww7X8SJKoy7ImZ5svFsC7rY1wJXOHj9vncfKcJ/jvsjHmw34r/v8HwV Hts3Bsi5nHO9rH7Kb0y+rwaAbK5QBtEWRw3Ne45WBlr0nyJ7g77FRuPJvTZkd5SiZRLe o56w== X-Gm-Message-State: AOAM532u+V+xBil5L/p/9k4GV0xzsEi1A6XAPMTm33A5ADUwNcqx7ogC jBq3NPd9j9ED8kdu6YWraT2l7riZAEsLUV8Je6A= X-Google-Smtp-Source: ABdhPJyDG+k7ExKqGt09/zGT6z9bNoNt88E4yrnIDdCjjcd3uF5mgvWdixcsiStCcZZ1wXVpSaUdGcXShe7Y28qyPMY= X-Received: by 2002:aca:3203:0:b0:32e:b45e:131b with SMTP id y3-20020aca3203000000b0032eb45e131bmr5678597oiy.210.1655092198363; Sun, 12 Jun 2022 20:49:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Max Filippov Date: Sun, 12 Jun 2022 20:49:47 -0700 Message-ID: Subject: Re: [PATCH 4/4] xtensa: Optimize bitwise AND operation with some specific forms of constants To: "Takayuki 'January June' Suwa" Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2022 03:50:02 -0000 Hi Suwa-san, On Sat, Jun 11, 2022 at 11:43 PM Takayuki 'January June' Suwa wrote: > > This patch offers several insn-and-split patterns for bitwise AND with > register and constant that cannot fit into a "MOVI Ax, simm12" instruction, > but can be represented as: > > i. 1's least significant N bits and the others 0's (17 <= N <= 31) > ii. 1's most significant N bits and the others 0's (12 <= N <= 31) > iii. M 1's sequence of bits and trailing N 0's bits > (1 <= M <= 16, 1 <= N <= 30) > > And also offers shortcuts for conditional branch if each of the > abovementioned > operations is (not) equal to zero. > > gcc/ChangeLog: > > * config/xtensa/predicates.md (shifted_mask_operand): > New predicate. > * config/xtensa/xtensa.md (*andsi3_const_pow2_minus_one): > New insn-and-split pattern. > (*andsi3_const_negative_pow2, *andsi3_const_shifted_mask, > *masktrue_const_pow2_minus_one, *masktrue_const_negative_pow2, > *masktrue_const_shifted_mask): Ditto. > --- > gcc/config/xtensa/predicates.md | 11 +++ > gcc/config/xtensa/xtensa.md | 165 ++++++++++++++++++++++++++++++++ > 2 files changed, 176 insertions(+) This change produces a bunch of regression test failures in big-endian configuration: FAIL: gcc.c-torture/execute/20020108-1.c -O1 execution test FAIL: gcc.c-torture/execute/20020108-1.c -O2 execution test FAIL: gcc.c-torture/execute/20020108-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20020108-1.c -Os execution test FAIL: gcc.c-torture/execute/20020108-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20040629-1.c -O1 execution test FAIL: gcc.c-torture/execute/20040629-1.c -O2 execution test FAIL: gcc.c-torture/execute/20040629-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20040629-1.c -Os execution test FAIL: gcc.c-torture/execute/20040629-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20040705-1.c -O1 execution test FAIL: gcc.c-torture/execute/20040705-1.c -O2 execution test FAIL: gcc.c-torture/execute/20040705-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20040705-1.c -Os execution test FAIL: gcc.c-torture/execute/20040705-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20040705-2.c -O1 execution test FAIL: gcc.c-torture/execute/20040705-2.c -O2 execution test FAIL: gcc.c-torture/execute/20040705-2.c -O3 -g execution test FAIL: gcc.c-torture/execute/20040705-2.c -Os execution test FAIL: gcc.c-torture/execute/20040705-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20040709-1.c -O1 execution test FAIL: gcc.c-torture/execute/20040709-1.c -O2 execution test FAIL: gcc.c-torture/execute/20040709-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/20040709-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20040709-1.c -Os execution test FAIL: gcc.c-torture/execute/20040709-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20040709-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/20180921-1.c -O1 execution test FAIL: gcc.c-torture/execute/20180921-1.c -O2 execution test FAIL: gcc.c-torture/execute/20180921-1.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.c-torture/execute/20180921-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/20180921-1.c -Os execution test FAIL: gcc.c-torture/execute/20180921-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/20180921-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/pr60454.c -O1 execution test FAIL: gcc.c-torture/execute/pr60454.c -O2 execution test FAIL: gcc.c-torture/execute/pr60454.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr60454.c -Os execution test FAIL: gcc.c-torture/execute/pr60454.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr61306-2.c -O1 execution test FAIL: gcc.c-torture/execute/pr64718.c -O1 execution test FAIL: gcc.c-torture/execute/pr65215-1.c -O1 execution test FAIL: gcc.c-torture/execute/pr65215-1.c -O2 execution test FAIL: gcc.c-torture/execute/pr65215-1.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr65215-1.c -Os execution test FAIL: gcc.c-torture/execute/pr65215-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr65215-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/pr65215-3.c -O1 execution test FAIL: gcc.c-torture/execute/pr65215-4.c -O1 execution test FAIL: gcc.c-torture/execute/pr65215-4.c -O2 execution test FAIL: gcc.c-torture/execute/pr65215-4.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr65215-4.c -Os execution test FAIL: gcc.c-torture/execute/pr65215-4.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr65215-4.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/pr79388.c -O1 execution test FAIL: gcc.c-torture/execute/pr79388.c -O2 execution test FAIL: gcc.c-torture/execute/pr79388.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr79388.c -Os execution test FAIL: gcc.c-torture/execute/pr79388.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr93908.c -O1 execution test FAIL: gcc.c-torture/execute/pr93908.c -O2 execution test FAIL: gcc.c-torture/execute/pr93908.c -O3 -g execution test FAIL: gcc.c-torture/execute/pr93908.c -Os execution test FAIL: gcc.c-torture/execute/pr93908.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.c-torture/execute/pr93908.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.c-torture/execute/struct-ini-2.c -O1 execution test FAIL: gcc.c-torture/execute/struct-ini-2.c -O2 execution test FAIL: gcc.c-torture/execute/struct-ini-2.c -O3 -g execution test FAIL: gcc.c-torture/execute/struct-ini-2.c -Os execution test FAIL: gcc.c-torture/execute/struct-ini-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O1 execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O2 execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O3 -g execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -Os execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/atomic/c11-atomic-exec-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/20050826-1.c execution test FAIL: gcc.dg/sso/s3.c -Wno-scalar-storage-order -O1 -fno-inline output pattern test FAIL: gcc.dg/sso/t2.c -Wno-scalar-storage-order -O1 -fno-inline output pattern test FAIL: gcc.dg/sso/t2.c -Wno-scalar-storage-order -O2 output pattern test FAIL: gcc.dg/sso/t2.c -Wno-scalar-storage-order -O3 -finline-functions output pattern test FAIL: gcc.dg/sso/t2.c -Wno-scalar-storage-order -Os output pattern test FAIL: gcc.dg/sso/t2.c -Wno-scalar-storage-order -Og -g output pattern test FAIL: gcc.dg/torture/pr30665-2.c -O2 execution test FAIL: gcc.dg/torture/pr30665-2.c -O3 -g execution test FAIL: gcc.dg/torture/pr30665-2.c -Os execution test FAIL: gcc.dg/torture/pr30665-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test FAIL: gcc.dg/torture/pr30665-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test FAIL: gcc.dg/torture/pr69714.c -O1 execution test FAIL: gcc.dg/torture/vshuf-v8qi.c -O2 execution test FAIL: gcc.dg/tree-ssa/pr80803.c execution test FAIL: gcc.dg/tree-ssa/pr80898-2.c execution test E.g. for the test gcc.c-torture/execute/struct-ini-2.c the following assembly code is generated now: .file "struct-ini-2.c" .text .literal_position .literal .LC0, x .literal .LC2, 8192 .literal .LC3, abort@PLT .literal .LC4, exit@PLT .align 4 .global main .type main, @function main: entry sp, 32 l32r a8, .LC0 l16ui a8, a8, 0 l32r a9, .LC2 extui a10, a8, 16, 4 slli a10, a10, 12 extui a9, a9, 0, 16 beq a10, a9, .L2 l32r a8, .LC3 callx8 a8 .L2: movi a9, 0xf0 and a9, a8, a9 movi.n a10, 0x30 beq a9, a10, .L3 l32r a8, .LC3 callx8 a8 .L3: extui a8, a8, 0, 4 beqi a8, 4, .L4 l32r a8, .LC3 callx8 a8 .L4: movi.n a10, 0 l32r a8, .LC4 callx8 a8 .size main, .-main .global x .data .align 4 .type x, @object .size x, 4 x: .byte 32 .byte 52 .zero 2 .ident "GCC: (GNU) 13.0.0 20220612 (experimental)" and the following code was generated before this change: .file "struct-ini-2.c" .text .literal_position .literal .LC0, x .literal .LC1, -4096 .literal .LC2, 8192 .literal .LC3, abort@PLT .literal .LC4, exit@PLT .align 4 .global main .type main, @function main: entry sp, 32 l32r a8, .LC0 l16ui a8, a8, 0 l32r a9, .LC2 l32r a10, .LC1 and a10, a8, a10 extui a9, a9, 0, 16 beq a10, a9, .L2 l32r a8, .LC3 callx8 a8 .L2: movi a9, 0xf0 and a9, a8, a9 movi.n a10, 0x30 beq a9, a10, .L3 l32r a8, .LC3 callx8 a8 .L3: extui a8, a8, 0, 4 beqi a8, 4, .L4 l32r a8, .LC3 callx8 a8 .L4: movi.n a10, 0 l32r a8, .LC4 callx8 a8 .size main, .-main .global x .data .align 4 .type x, @object .size x, 4 x: .byte 32 .byte 52 .zero 2 .ident "GCC: (GNU) 13.0.0 20220612 (experimental)" -- Thanks. -- Max