diff mbox series

[4/6] add helper is_pow2()

Message ID 20201127222516.44915-5-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series 'bits translation' simplification | expand

Commit Message

Luc Van Oostenryck Nov. 27, 2020, 10:25 p.m. UTC
Add is_pow2() to test if a pseudo is a power of 2.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/simplify.c b/simplify.c
index d729b390ae76..0d9391e21a56 100644
--- a/simplify.c
+++ b/simplify.c
@@ -52,6 +52,15 @@ 
 // Utilities
 // ^^^^^^^^^
 
+///
+// check if a pseudo is a power of 2
+static inline bool is_pow2(pseudo_t src)
+{
+	if (src->type != PSEUDO_VAL)
+		return false;
+	return is_power_of_2(src->value);
+}
+
 ///
 // find the trivial parent for a phi-source
 static struct basic_block *phi_parent(struct basic_block *source, pseudo_t pseudo)