constantfolding Questions

1

Solved

The following is a minimal reproducible example of code that I had to generate an 'array' (whose 1-byte elements are packed into the resulting uint_fast64_t) of 3D coordinates within octree branche...
Marshy asked 17/1, 2024 at 3:38

2

Solved

Given a command like, perl -MO=Deparse -E'use constant FOO => 42; print FOO()' How can I disable constant folding such that print 42; Shows me print FOO(); Or the like. Ideally, I would like ...
Biquadratic asked 4/2, 2021 at 1:55

1

Solved

Given these two evals which only change Module::FOO() and FOO(). # Symbols imported, and used locally. eval qq[ package Foo$num; Module->import(); my \$result = Module::FOO() * Module::FOO()...
Botswana asked 28/1, 2021 at 4:35

1

Solved

I just realized that CPython seems to treat constant expressions, which represent the same value, differently with respect to constant folding. For example: >>> import dis >>> di...
Lacy asked 2/5, 2019 at 2:23

1

Having had a look at previous questions 1, 2 , I was wondering if I can force the compiler to perform a constant folding for the following code which prints prime numbers. #include <iostream&gt...
Elinoreeliot asked 17/2, 2018 at 8:28

2

I have a const variable in my embedded C program. It's defined and initialized with 0 in program code. It's placed in a special ROM area via linker script. One can change the content of the special...
Michaelamichaele asked 10/4, 2016 at 12:21

1

Solved

I have a string literal in my program, I'm trying to create an amateur checksum to ensure the string literal was not replaced in the portable executable. To do this, I create a hash of the string ...
Preparation asked 6/9, 2015 at 17:1

2

Based on this interesting question: Addition of int and uint and toying around with constant folding as mentioned in Nicholas Carey's answer, I've stumbled upon a seemingly inconsistent behavior of...
Arabel asked 15/10, 2014 at 15:21

1

Solved

Here's my code: int f(double x) { return isnan(x); } If I #include <cmath> I get this assembly: xorl %eax, %eax ucomisd %xmm0, %xmm0 setp %al This is reasonably clever: ucomisd sets th...
Af asked 26/9, 2014 at 5:27

2

Solved

For the following C source code: #include <math.h> int main(void) { double x; x = log(0.0); return 0; } When I compile with gcc -lm, I got: /tmp/ccxxANVH.o: In function `main': a.c:...
Unjust asked 18/6, 2014 at 20:35

4

It seems that gcc has some limitation on complex constant folding. Here is an example: static inline unsigned int DJBHash(const char *str) { int i; unsigned int hash = 5381; for(i = 0; i < ...

2

Solved

const int buf_length = 255; char buf[ buf_length + 1 ]; snprintf(buf, buf_length, "%d Next on [%s] %s:", channel, station_channel(channel), station_name(channel)); strncat(buf, "(", buf_length - ...
Seve asked 26/8, 2013 at 1:5

3

Solved

assert(0.1 + 0.2 != 0.3); // shall be true is my favorite check that a language uses native floating point arithmetic. C++ #include <cstdio> int main() { printf("%d\n", (0.1 + 0.2 != 0....
Pontonier asked 29/7, 2011 at 14:3

1

Solved

I saw some codes in slf4j as show below. I don't know why to avoid constant folding in here. Is it necessary to do that? or just best practice. what's the benefit of doing this? Thanks. /** * D...
Pineda asked 15/1, 2011 at 18:0

2

I'm wondering, does -MO=Deparse show you all of the Perl optimizations, and why doesn't this get folded in Perl 5.10? $ perl -MO=Deparse -e'[qw/foo bar baz/]->[0]' ['foo', 'bar', 'baz']->[0]...
Ocko asked 24/8, 2010 at 21:32

2

Possible Duplicate: is there any concept called “Constant Folding” in java? Hi I have come across line Java compiler uses something known as Constant Folding.What is this?...
Burrows asked 15/2, 2010 at 5:34

2

Solved

is there any concept called "Constant Folding" in java? if yes what is it?
Palter asked 6/1, 2010 at 11:26
1

© 2022 - 2025 — McMap. All rights reserved.