public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-414] MATCH: Port CLRSB part of builtin_zero_pattern
@ 2023-05-02 21:49 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2023-05-02 21:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:078339fc04f5de59e55de8c54f4504b7672d60d0

commit r14-414-g078339fc04f5de59e55de8c54f4504b7672d60d0
Author: Andrew Pinski <apinski@marvell.com>
Date:   Fri Apr 28 12:45:19 2023 -0700

    MATCH: Port CLRSB part of builtin_zero_pattern
    
    This ports the clrsb builtin part of builtin_zero_pattern
    to match.pd. A simple pattern to port.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
    gcc/ChangeLog:
    
            * match.pd (a != 0 ? CLRSB(a) : CST -> CLRSB(a)): New
            pattern.

Diff:
---
 gcc/match.pd | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index b14b7017c9a..08a4f8ebdc1 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7787,6 +7787,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (cond (ne @0 integer_zerop@1) (func@3 (convert? @0)) integer_zerop@2)
   @3))
 
+/* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins
+   where CST is precision-1. */
+(for func (CLRSB)
+ (simplify
+  (cond (ne @0 integer_zerop@1) (func@4 (convert?@3 @0)) INTEGER_CST@2)
+  (if (wi::to_widest (@2) == TYPE_PRECISION (TREE_TYPE (@3)) - 1)
+   @4)))
+
 #if GIMPLE
 /* a != 0 ? CLZ(a) : CST -> .CLZ(a) where CST is the result of the internal function for 0. */
 (for func (CLZ)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-02 21:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02 21:49 [gcc r14-414] MATCH: Port CLRSB part of builtin_zero_pattern Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).