From 16d44e5c4cca370c73fad06813570c261cc47777 Mon Sep 17 00:00:00 2001 From: Yan Da Date: Thu, 7 Apr 2022 15:28:02 +0800 Subject: [PATCH] Verify power-of-2 --- include/triton/ir/Traits.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/triton/ir/Traits.h b/include/triton/ir/Traits.h index 534722d71..a470e2bb3 100644 --- a/include/triton/ir/Traits.h +++ b/include/triton/ir/Traits.h @@ -25,6 +25,9 @@ public: if (numElements > 1048576) return op->emitError("Maximum allowed number of elements is 1048576, but ") << *op << " has more than that"; + if ((numElements & (numElements - 1)) != 0) + return op->emitError("Number of elements must be power-of-two, but ") + << *op << " doesn't follow the rule"; } } @@ -36,6 +39,9 @@ public: if (numElements > 1048576) return op->emitError("Maximum allowed number of elements is 1048576, but ") << *op << " has more than that"; + if ((numElements & (numElements - 1)) != 0) + return op->emitError("Number of elements must be power-of-two, but ") + << *op << " doesn't follow the rule"; } }