0 0 votes please explain each optimization too! Compiler Design + – Gate Fever 2.0k views answer comment Share Follow Print See all 12 Comments 12 12 Comments reply Gate Fever commented Dec 15, 2018 reply Follow flag anyone??? 0 0 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag is it not in the course ???? reason for downvote?? 0 0 replyShare kumar.dilip commented Dec 15, 2018 reply Follow flag I think D is correct ??? 0 0 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag yes, thats correct! can u explain! 0 0 replyShare kumar.dilip commented Dec 15, 2018 reply Follow flag Code can written like this x = 0; y = 10; for(int i = 0;i<5;i++) { x++; y = y<<1; } 0 0 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag can u pls tell me what does all these optimizations mean?? means i dont know what is constant folding , loop unrolling etc? 0 0 replyShare kumar.dilip commented Dec 15, 2018 i reshown by kumar.dilip Dec 15, 2018 reply Follow flag Gate Fever wait for a minute I will explain.. 0 0 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag no problem, take ur time! 0 0 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag @kumar.dilip u havent replied yet 0 0 replyShare kumar.dilip commented Dec 15, 2018 reply Follow flag 1. operation y = y*2 ( this is costly operation compare to ) y = y <<1 , so we can replace that operation. this is called strength reduction. 2. y = 10 remove it from high-frequency( like loop) region to low frequency is called code motion. 3.we can write both the operation y = y<<1 and x++ in the single loop ( loop unrolling) 4. x = x*0, can be written like this x = 0 ( constant folding) 4 4 replyShare Gate Fever commented Dec 15, 2018 reply Follow flag okay,thanks! 0 0 replyShare Hira Thakur commented Nov 15, 2023 reply Follow flag on what basis we should judge that $x$ is a costlier operator and $y$ is a cheaper operator? 0 0 replyShare Please log in or register to add a comment.