Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
1685 Discussions

a=b=c; or b=c; a=b; which has higher time efficiency?

fatalme
Beginner
133 Views
a=b=c;
or
b=c;
a=b;
Thanks.
0 Kudos
4 Replies
Ilnar
Beginner
133 Views

both constructions are equal, first one is just shorter syntacs of the second one

Dost__Conrad_W
Beginner
133 Views
The compiler will optimize them to the same code.
jimdempseyatthecove
Black Belt
133 Views
Quoting conradca
The compiler will optimize them to the same code.

Excepting when b and a are volatile.

dwms
Beginner
133 Views
An interesting exercise would be writing the code to do both and then reviewing the assembly generated by the compiler.
Assuming this is not a complex data type, don't forget:
a=c;
b=c;
Reply