From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 24C143858C62 for ; Thu, 6 Oct 2022 23:19:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 24C143858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x429.google.com with SMTP id y8so3387871pfp.13 for ; Thu, 06 Oct 2022 16:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Yf1f9ZRIvtpsN65jne812AZBDh0hc/3J/VgrszWALEA=; b=eBhgVkffbGpbEKmMaC98hExxgbABp3KBrUBwylAnQTJ+DnL7aWojx7a51esgyatJ4y ZM90xmXhYu2DVIpvezAoB3H3xSt03TfLSPjgBWlSLx5eKg4e3R4f6SWx3g72Og4/kNR8 JRIVcnwNKYu4T5EeMEi6w5N/v6Y32eKeWWaMnKZ6V4P9LRcRuRjs0QApYCfxOSKopGSd kzZ+6KtJZhMhGmYtcY+UTWqITrXtbUfFhrILbN9pW9/FBB0xkCcrcTYbjf2jrY+XX8r8 XD98OHMkmF5acgNcos5rr/TY8oKpgljUkDbaZuapWkb5jijGKC2TKXiftpSwWlpHn/Fe XN5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=Yf1f9ZRIvtpsN65jne812AZBDh0hc/3J/VgrszWALEA=; b=uHkB1WINFxpUE5STfre7Ar/5EhtL/NknldT0NzF0drLba+F5IapDK4smjaI/k7xqdy cwvdIDceIk/K49tU3tiy3E7cj88q8bK9E5qzIryUDP+66vW/XP6lXZW9n79Lgjt/pn0N xQpJbrdfst09CqLnwhpk2rYpgzTBc7b7Czh1x2KfZK4hQY81B/M3WGga5Gpxwans2Yse neXmz1JOLNI/xum1LeX/vI9At2SaT2BK/lqKqZH7eAPMMtlQaT+V/Bh4f4HXYB6357SG cjed2LJB/ss21mupdmTvBus1QWrpK8GvxzCkT0ucauamRXZBIe+EoQTnzJDy6nI0u+eg BgTQ== X-Gm-Message-State: ACrzQf24n3E+xbdRBkLDVt2tJSL4CV97L41qipQfkjETqEJhFLBRRujU i+Xm/5DgYL5yTHCs9jpXxdnmHLE/pVVU2tnH9zo= X-Google-Smtp-Source: AMsMyM6qPIseeuwqy05qUMYZEfxdyGN6Jfuh7PhNC+l8gQfaQ+9i6s3iXPKgDatAf9aH5rdYtg7XBmI7V2XmR/HI6l0= X-Received: by 2002:a65:5b05:0:b0:439:a0ae:7e6a with SMTP id y5-20020a655b05000000b00439a0ae7e6amr1920718pgq.16.1665098341860; Thu, 06 Oct 2022 16:19:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Thu, 6 Oct 2022 16:18:49 -0700 Message-ID: Subject: Re: Need help with match.pd crash To: Michael Collison Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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 Thu, Oct 6, 2022 at 4:00 PM Michael Collison wrote: > > I am trying to improve code generation for coremark to match a recent > improvement that was made in LLVM. > > I added the following transformation to match.pd which attempts to > replace a branch with straight line code: > > /* (cond (and (x , 0x1) == 0), y, (z ^ y) ) -> (-(and (x , 0x1)) & z ) ^ > y */ > (simplify > (cond (eq (bit_and @0 integer_onep@1) > integer_zerop) > @2 > (bit_xor:c @3 @2)) > (bit_xor (bit_and (negate (bit_and @0 @1)) @3) @2)) > I suspect you are missing a convert as @0/@1 might be a different type from type (@2/@3's type). Try: (simplify (cond (eq (bit_and @0 integer_onep@1) integer_zerop) @2 (bit_xor:c @3 @2)) (bit_xor (bit_and (negate (convert:type (bit_and @0 @1))) @3) @2)) But I am not 100% sure that match.pd (phiopt since that is where the transformation is really happening) is the right place for this. I suspect a better place is rtl level inside either simplify-rtl.cc and/or inside ifcvt.cc. Because on some targets has conditional moves which might be better than doing an and/neg/and/xor. AARCH64 and MIPS are good examples of that (I know because I spent time making sure GCC produces the conditional moves for coremarks for those targets inside crc8). Thanks, Andrew Pinski > I get a internal error, but in stepping through the debugger I can see > the pattern matches, but fails when when it tries to further simplify > and match another pattern in match.pd: > > /* x & C -> x if we know that x & ~C == 0. */ > #if GIMPLE > (simplify > (bit_and SSA_NAME@0 INTEGER_CST@1) > (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) > && wi::bit_and_not (get_nonzero_bits (@0), wi::to_wide (@1)) == 0) > @0)) > #endif > > The crash occurs in wi::bit_and_not. Before digging further I want to > ask if there is a problem with the way I wrote the transformation? > > >