Why doesn’t GCC optimize out deletion of null pointers in C++?

According to C++14 [expr.delete]/7: If the value of the operand of the delete-expression is not a null pointer value, then: [ …omitted… ] Otherwise, it is unspecified whether the deallocation function will be called. So both compilers do comply with the standard, because it’s unspecified whether operator delete is called for deletion of a null … Read more

JIT not optimizing loop that involves Integer.MAX_VALUE

I have not dug up the Java Language Specification, but I’d guess that it has to do with this difference: i++ < (Integer.MAX_VALUE – 1) never overflows. Once i reaches Integer.MAX_VALUE – 1 it is incremented to Integer.MAX_VALUE and then the loop terminates. i++ < Integer.MAX_VALUE contains an integer overflow. Once i reaches Integer.MAX_VALUE, it … Read more

Using Assembly Language in C/C++

The only time it’s useful to revert to assembly language is when the CPU instructions don’t have functional equivalents in C++ (e.g. single-instruction-multiple-data instructions, BCD or decimal arithmetic operations) AND the compiler doesn’t provide extra functions to wrap these operations (e.g. C++11 Standard has atomic operations including compare-and-swap, <cstdlib> has div/ldiv et al for getting … Read more

SIMD instructions lowering CPU frequency

The frequency impact depends on the width of the operation and the specific instruction used. There are three frequency levels, so-called licenses, from fastest to slowest: L0, L1 and L2. L0 is the “nominal” speed you’ll see written on the box: when the chip says “3.5 GHz turbo”, they are referring to the single-core L0 … Read more

Java program runs slower when code that is never executed is commented out

The commented code affects how inlining is handled. If functionB gets longer/bigger (more bytecode instructions) it will not be inlined into functionA. So @J3D1 was able to use VMOptions to manually switch off inlining for functionB(): -XX:CompileCommand=dontinline,com.jd.benchmarking.StrangeBeh‌​aviour::functionB This appears to eliminate the delay with the shorter function. with the vm options you can display inlining … Read more

Optimize in CMake by default

First off: recommended usage of CMake is to always specify CMAKE_BUILD_TYPE explicitly on the command line (if and only if using a single-configuration generator). Your use case deviates from this best practice, so treat this answer as “how you can do it,” not necessarily as “how you should do it.” To address the first issue, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)