ICPC missing an optimisation opportunity?

ICPC missing an optimisation opportunity?

Martin K.'s picture

Using either icpc 13.1.1 or 14.0.0 and I'm observing the same optimisation issue. A statement of the form:

A a = A().mutator();

where A has an empty default ctor, could causes the compiler to route the result from the mutator via the temporary, rather than route directly to the lvalue. The drawback in the former case is that there is a superfluous copy to the lvalue.

I've attached a code sample containing two exhibits. In Exibit A the compiler eliminates the temporary; in Exibit B the compiler does not eliminate the temporary.

Compilers tested:

$ icc -V Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.1.1.163 Build 20130313 Copyright (C) 1985-2013 Intel Corporation. All rights reserved. .. $ icc -V Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.080 Build 20130728 Copyright (C) 1985-2013 Intel Corporation. All rights reserved.

CLI options used: -pipe -fno-exceptions -fno-rtti -fstrict-aliasing -unroll-aggressive -mmic -funroll-loops -O3 -DNDEBUG

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Martin K.'s picture

Added attachment missing from OP.

Attachments: 

AttachmentSize
Download out.cpp2.85 KB
Kevin Davis (Intel)'s picture

Thank you for reporting this possible missed optimization opportunity and for the convenient test case. I routed it to Development (see internal tracking id below) and will let you know what I hear.

(Internal tracking id: DPD200247989)

Martin K.'s picture

Thank you for the quick reply, Kevin!

Login to leave a comment.