]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MATCH: Port CLRSB part of builtin_zero_pattern
authorAndrew Pinski <apinski@marvell.com>
Fri, 28 Apr 2023 19:45:19 +0000 (12:45 -0700)
committerAndrew Pinski <apinski@marvell.com>
Tue, 2 May 2023 21:46:39 +0000 (14:46 -0700)
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.

gcc/match.pd

index b14b7017c9a5abac7c43ae241ef3ea7c6cf33543..08a4f8ebdc1e8fb82bebd27f0ca3bae539ce5bdd 100644 (file)
@@ -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)