Displaying 20 results from an estimated 59 matches for "ispowerof2".
2017 Sep 13
3
How to add optimizations to InstCombine correctly?
...I end up in an infinite loop and the Instruction I try to
>> replace gets scheduled again and again. What is wrong in my code?
>>
>> // Replace X * (2^C+/-1) with (X << C) -/+ X
>> APInt Plus1 = *IVal + 1;
>> APInt Minus1 = *IVal - 1;
>> int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0;
>>
>> if (isPow2) {
>> APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
>> return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub :
>> BinaryOperat...
2017 Sep 13
2
How to add optimizations to InstCombine correctly?
...the original Instruction in the Worklist.
However, I end up in an infinite loop and the Instruction I try to
replace gets scheduled again and again. What is wrong in my code?
// Replace X * (2^C+/-1) with (X << C) -/+ X
APInt Plus1 = *IVal + 1;
APInt Minus1 = *IVal - 1;
int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0;
if (isPow2) {
APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub :
BinaryOperator::Add, Shl, Op0);
}
Thanks,
Michael
2020 Jul 07
2
[nbdkit PATCH] RFC tests: Avoid odd test behavior under NDEBUG
...h CFLAGS=-DNDEBUG, I'm not sure we need it.
common/include/test-ascii-ctype.c | 1 +
common/include/test-ascii-string.c | 1 +
common/include/test-byte-swapping.c | 1 +
common/include/test-current-dir-name.c | 1 +
common/include/test-isaligned.c | 1 +
common/include/test-ispowerof2.c | 1 +
common/include/test-iszero.c | 1 +
common/include/test-minmax.c | 1 +
common/include/test-nextnonzero.c | 1 +
common/bitmap/test-bitmap.c | 1 +
common/utils/test-quotes.c | 1 +
common/utils/test-vector.c | 1 +
tests/te...
2018 Aug 01
2
Re: [PATCH v2 nbdkit 4/6] common: Add a directory for common code shared by plugins and filters.
...<rjones@redhat.com> wrote:
> Currently this adds two useful header files containing functions which
> will be consumed by filters in later commits.
> ---
> Makefile.am | 5 +++-
> common/include/Makefile.am | 39 ++++++++++++++++++++++++
> common/include/ispowerof2.h | 50 +++++++++++++++++++++++++++++++
> common/include/iszero.h | 60 +++++++++++++++++++++++++++++++++++++
> configure.ac | 1 +
> 5 files changed, 154 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 6a3a377..09dbdb9 100644
&g...
2017 Sep 14
3
How to add optimizations to InstCombine correctly?
...y to
> replace gets scheduled again and again. What is wrong in my
> code?
>
> // Replace X * (2^C+/-1) with (X << C) -/+ X
> APInt Plus1 = *IVal + 1;
> APInt Minus1 = *IVal - 1;
> int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ?
> -1 : 0;
>
> if (isPow2) {
> APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
> Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
> return BinaryOperator::Create(isPow2 >...
2020 Jul 07
0
Re: [nbdkit PATCH] RFC tests: Avoid odd test behavior under NDEBUG
...ions.
ACK
Rich.
> common/include/test-ascii-ctype.c | 1 +
> common/include/test-ascii-string.c | 1 +
> common/include/test-byte-swapping.c | 1 +
> common/include/test-current-dir-name.c | 1 +
> common/include/test-isaligned.c | 1 +
> common/include/test-ispowerof2.c | 1 +
> common/include/test-iszero.c | 1 +
> common/include/test-minmax.c | 1 +
> common/include/test-nextnonzero.c | 1 +
> common/bitmap/test-bitmap.c | 1 +
> common/utils/test-quotes.c | 1 +
> common/utils/test-vector...
2018 Aug 01
0
[PATCH v2 nbdkit 4/6] common: Add a directory for common code shared by plugins and filters.
Currently this adds two useful header files containing functions which
will be consumed by filters in later commits.
---
Makefile.am | 5 +++-
common/include/Makefile.am | 39 ++++++++++++++++++++++++
common/include/ispowerof2.h | 50 +++++++++++++++++++++++++++++++
common/include/iszero.h | 60 +++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
5 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 6a3a377..09dbdb9 100644
--- a/Makefile.am
+++ b/Makefil...
2018 Aug 01
0
Re: [PATCH v2 nbdkit 4/6] common: Add a directory for common code shared by plugins and filters.
...gt;
> > Currently this adds two useful header files containing functions which
> > will be consumed by filters in later commits.
> > ---
> > Makefile.am | 5 +++-
> > common/include/Makefile.am | 39 ++++++++++++++++++++++++
> > common/include/ispowerof2.h | 50 +++++++++++++++++++++++++++++++
> > common/include/iszero.h | 60 +++++++++++++++++++++++++++++++++++++
> > configure.ac | 1 +
> > 5 files changed, 154 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile.am b/Makefile.am
> > in...
2017 Sep 16
2
How to add optimizations to InstCombine correctly?
...gets scheduled again and again. What is wrong in my
> > code?
> >
> > // Replace X * (2^C+/-1) with (X << C) -/+ X
> > APInt Plus1 = *IVal + 1;
> > APInt Minus1 = *IVal - 1;
> > int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ?
> > -1 : 0;
> >
> > if (isPow2) {
> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
> > Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
> > return Bina...
2023 Mar 01
6
[libnbd PATCH 0/6] common: catch up with nbdkit
If we compare the "common" subdirectory between nbdkit @ 6b4178d0fdfe
("ci: Temporarily disable perl in MacOS", 2023-02-27) and libnbd @
d05cd8f384a7 ("Version 1.15.11.", 2023-02-28), we find differences. We
can categorize these differences along two (orthogonal) axes:
- Intentional or unintentional.
Intentional differences are for example when one of the libnbd
2018 Sep 17
2
[PATCH nbdkit v2] common: Introduce round up, down; and divide round
Since we're using ({ .. }) gcc/clang extension, let's rewrite the
rounding.h change too.
Rich.
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...n my
>> > code?
>> >
>> > // Replace X * (2^C+/-1) with (X << C) -/+ X
>> > APInt Plus1 = *IVal + 1;
>> > APInt Minus1 = *IVal - 1;
>> > int isPow2 = Plus1.isPowerOf2() ? 1 :
>> Minus1.isPowerOf2() ?
>> > -1 : 0;
>> >
>> > if (isPow2) {
>> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> > Value *Shl = Builder.CreateShl(Op0,
&g...
2020 Aug 18
0
[PATCH nbdkit 6/9] lib: Use replacement strategy for get_current_dir_name.
...git a/common/include/Makefile.am b/common/include/Makefile.am
index 151c2ae4..a7d0d026 100644
--- a/common/include/Makefile.am
+++ b/common/include/Makefile.am
@@ -38,7 +38,6 @@ EXTRA_DIST = \
ascii-string.h \
byte-swapping.h \
exit-with-parent.h \
- get-current-dir-name.h \
isaligned.h \
ispowerof2.h \
iszero.h \
@@ -56,7 +55,6 @@ TESTS = \
test-ascii-ctype \
test-ascii-string \
test-byte-swapping \
- test-current-dir-name \
test-isaligned \
test-ispowerof2 \
test-iszero \
@@ -79,10 +77,6 @@ test_byte_swapping_SOURCES = test-byte-swapping.c byte-swapping.h
test_byte_swapping_CP...
2018 Sep 17
4
[PATCH nbdkit v2] common: isaligned: Use a macro instead of relying on implicit truncation.
...eletions(-)
diff --git a/common/include/isaligned.h b/common/include/isaligned.h
index e693820..81ce8a7 100644
--- a/common/include/isaligned.h
+++ b/common/include/isaligned.h
@@ -36,16 +36,15 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include "ispowerof2.h"
/* Return true if size is a multiple of align. align must be power of 2.
*/
-static inline bool
-is_aligned (unsigned int size, unsigned int align)
-{
- assert (is_power_of_2 (align));
- return !(size & (align - 1));
-}
+#define IS_ALIGNED(size, align) ({ \
+ as...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...n my
>> > code?
>> >
>> > // Replace X * (2^C+/-1) with (X << C) -/+ X
>> > APInt Plus1 = *IVal + 1;
>> > APInt Minus1 = *IVal - 1;
>> > int isPow2 = Plus1.isPowerOf2() ? 1 :
>> Minus1.isPowerOf2() ?
>> > -1 : 0;
>> >
>> > if (isPow2) {
>> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> > Value *Shl = Builder.CreateShl(Op0,
&g...
2018 Sep 17
0
[PATCH nbdkit v2] common: Introduce round up, down; and divide round up functions.
...LITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef NBDKIT_ROUNDING_H
+#define NBDKIT_ROUNDING_H
+
+#include <stdint.h>
+#include <assert.h>
+
+#include "ispowerof2.h"
+
+/* Round up i to next multiple of n (n must be a power of 2).
+ */
+#define ROUND_UP(i, n) ({ \
+ assert (is_power_of_2 (n)); \
+ ((i) + (n) - 1) & ~((n) - 1); \
+})
+
+/* Round down i to next multiple of n (n must be...
2018 Aug 01
12
[PATCH v2 nbdkit 0/6] Add truncate filter and other fixes.
I have dropped the map filter from this series for now while I try to
get it working.
However I think the truncate filter is in a good shape. This
incorporates all feedback from Eric's review.
Also there are three small fixes to the filter code, all revealed when
I was testing using multiple filters which we'd not done much of
before.
Rich.
2023 Sep 03
1
[PATCH nbdkit] server: Move size parsing code (nbdkit_parse_size) to common/include
This is the first part of a pair of patch series which aim to let us
use nbdkit_parse_size (or rather, an equivalent common function) in
nbdcopy, so we can write:
nbdcopy --request-size=32M ...
We can't do that now which was annoying me earlier in the week.
This commit creates a new function called human_size_parse which is
basically nbdkit_parse_size, and turns nbdkit_parse_size into a
2018 Aug 19
1
Re: [PATCH v3 3/4] common: Add isaligned helper module
...ING IN ANY WAY OUT
> + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#ifndef NBDKIT_ISALIGNED_H
> +#define NBDKIT_ISALIGNED_H
> +
> +#include <assert.h>
> +#include <stdbool.h>
> +
> +#include "ispowerof2.h"
> +
> +/* Return true if size is a multiple of align. align must be power of 2.
> + */
> +static inline bool
> +is_aligned (unsigned int size, unsigned int align)
> +{
> + assert (is_power_of_2 (align));
> + return !(size & (align - 1));
> +}
> +
> +#e...
2023 Sep 03
5
[PATCH libnbd 0/5] copy: Allow human sizes for --queue-size, etc
See companion patch:
Subject: [PATCH nbdkit] server: Move size parsing code (nbdkit_parse_size) to common/include
This is the second part of the patch. It adds the new
human_size_parse function to libnbd and then uses it for parsing
--queue-size, --request-size and --sparse.
The main complication here is that there was already a
common/utils/human-size.h header which ends up (eventually)