Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

C++ Loop Optimization Bug

Andreas_S_5
Beginner
259 Views

Dear all,

I stumbled upon a bug where icpc apparently causes a loop not to be executed. I've attached a minimal example which reproduces the behavior. I've tested with icpc 15.0.3 20150407. The bug is present with -O2 and -O3, but not -O1 nor -Os:

 

gentryx@neuromancer ~ $ # expected output:

10:49:11 - 0
gentryx@neuromancer ~ $ g++ -O3 test.cpp -o test && ./test   
max: (250, 150), min: (150, 50)

10:49:19 - 0
gentryx@neuromancer ~ $ # buggy behavior:

10:49:41 - 0
gentryx@neuromancer ~ $ icpc -O2 test.cpp -o test && ./test  
max: (150, -1000), min: (1000, 50)

10:49:45 - 0
gentryx@neuromancer ~ $ icpc -O3 test.cpp -o test && ./test  
max: (150, -1000), min: (1000, 50)

10:49:48 - 0

 
0 Kudos
1 Reply
Shenghong_G_Intel
259 Views

Hi Andreas,

I can reproduce this issue with 2015 U3 compiler, but it works with 2016 initial release.

Could you please upgrade to v16.0 initial release and verify?

$ source /opt/intel/compilers_and_libraries_2016.0.109/linux/bin/compilervars.sh intel64
$ icpc temp.cpp -O3 && ./a.out
max: (250, 150), min: (150, 50)
$ source /opt/intel/composer_xe_2015.3.187/bin/compilervars.sh intel64
$ icpc temp.cpp -O3 && ./a.out
max: (150, -1000), min: (1000, 50)
$

Thanks,

Shenghong

0 Kudos
Reply