Say I have a database looking like this;
Product with columns [ProductName] [Price] [Misc] [Etc]
Order with columns [OrderID] [ProductName] [Quantity] [Misc] [Etc]
ProductName is primary key of Product, of some string type and unique.
OrderID is primary key and of some integer type, and ProductName being a foreign key.
Say I change ...
Suppose I've following Code:
Console.WriteLine("Value1: " + SomeEnum.Value1.ToString() + "\r\nValue2: " +
SomeOtherEnum.Value2.ToString());
Will Compiler Optimize this to:
Console.WriteLine("Value1: " + SomeEnum.Value1 + "\r\nValue2: " +
SomeOtherEnum.Value2);
I've checked it with IL Di...
Hi,
I recently rolled out a new Toolchain on Linux, with gcc 4.5.0 and binutils 2.20 with gold. Now I was curious about this new thing PGO. While it's clear how it works with executables, I've not been able to find an answer on shared libraries. I found two unanswered posts on the gcc mailing list via google, that's all.
So here's what...
I'm using Rice to write a C++ extension for a Ruby gem. The extension is in the form of a shared object (.so) file.
This requires 'mkmf-rice' instead of 'mkmf', but the two (AFAIK) are pretty similar.
By default, the compiler uses the flags -g -O2. Personally, I find this kind of silly, since it's hard to debug with any optimization en...
Hello World!
I am facing a rather peculiar problem. I am working on a compiler for an architecture that doesn't support bitwise operations. However, it handles signed 16 bit integer arithmetics and I was wondering if it would be possible to implement bitwise operations using only:
Addition (c = a + b)
Subtraction (c = a - b)
Division...
A little test program:
#include <iostream>
const float TEST_FLOAT = 1/60;
const float TEST_A = 1;
const float TEST_B = 60;
const float TEST_C = TEST_A / TEST_B;
int main()
{
std::cout << TEST_FLOAT << std::endl;
std::cout << TEST_C << std::endl;
std::cin.ignore();
return 0;
}
Result :
0
0.0166667
Tested on Visual Studio 2...
I'm using and x86 based core to manipulate a 32-bit memory mapped register. My hardware behaves correctly only if the CPU generates 32-bit wide reads and writes to this register. The register is aligned on a 32-bit address and is not addressable at byte granularity.
What can I do to guarantee that my C (or C99) compiler will only gene...
We have some code that looks like this:
inline int calc_something(double x) {
if (x > 0.0) {
// do something
return 1;
} else {
// do something else
return 0;
}
}
Unfortunately, when using the flag /fp:fast, we get calc_something(0)==1 so we are clearly taking the wrong code path. This only happens when we use th...
Can we see optimized code in c++.............(not assembly)??
...
Documentation for __assume says "The most common use of __assume is with the default case of a switch statement, as shown in the following example.".
Is there any other case where __assume can lead to a more efficient (or even a different) code?
When inside of if / else , is compiler automatically "assuming" what is already know becau...
In Visual Studio C/C++ projects, it's easy to modify compiler's optimization settings in "Property Pages | C/C++ | Optimization". For example, we may give different optimization levels such as /O2 and /O3, as well as advanced optimizations like "Omit Frame Pointers".
However, I can't simply find corresponding UIs in C# project of Visual...
Background:
Many years ago, I inherited a codebase that was using the Visual Studio (VC++) flag '/fp:fast' to produce faster code in a particular calculation-heavy library. Unfortunately, '/fp:fast' produced results that were slightly different to the same library under a different compiler (Borland C++). As we needed to produce exactly...
Im just wondering how good the MSVC++ Compiler can optimize code(with Code examples) or what he can't optimize and why.
For example i used the SSE-intrinsics with something like this(var is an __m128 value)(it was for an frustrum-culling test):
if( var.m128_f32[0] > 0.0f && var.m128_f32[1] > 0.0f && var.m128_f32[2] > 0.0f && var.m128_f...
I'm trying to read an avi file in OpenCV 2.1, VS2008 standard for 2 days now with no luck. I constantly get this message in the program console:
Compiler did not align stack variables. Libavcodec has been miscompiled
and may be very slow or crash. This is not a bug in libavcodec,
but in the compiler. You may try recompiling using...
OK OK, I know this is a hack, but this was for a tiny data-manipulation project and I wanted to play around. ;-)
I was always under the impression that the compiler would examine all anonymous types used in a C# program and if the properties were the same, it would only create one class behind the scenes.
So let's say I want to create ...
Below, the result1 and result2 variable values are reporting different values depending upon whether or not
you compile the code with -g or with -O on GCC 4.2.1 and on GCC 3.2.0 (and I have not tried more recent GCC versions):
double double_identity(double in_double)
{
return in_double;
}
...
double result1 = ceil(log(32.0) / log(...
Does the java compiler (the default javac that comes in JDK1.6.0_21) optimize code to prevent the same method from being called with the same arguments over and over? If I wrote this code:
public class FooBar {
public static void main(String[] args) {
foo(bar);
foo(bar);
foo(bar);
}
}
Would the method f...
I need to pass a "General Compiler Design" test from a potential employer and believe the best way to do so would be to get to know a little about all of compiler design. If you think another method would be better, let me know. Now then:
I have intermediate to advanced knowledge of:
C
C++ (not as much as C)
C#
Java
Python
Ruby
Perl
PH...
Hello,
i'm writting handler for OpenGL texture and i'm thinking about safety and performance. Which level of optimization should remove marked if statements?
struct Texture2D {
GLuint ID;
inline Texture2D(): ID(0) {};
inline explicit Texture2D(GLuint id): ID(id) {};
~Texture2D();
void GenTexture(bool regen = false...
Hello, I'm trying to learn how to reverse engineer software and all the tricks to understand how the code looks like before the compiler optimizations.
I found something like this several times:
if (a < 0)
a = -2147483648 - a;
I originally thought it was an abs(): a underflows so you get the positive value. But since a is n...