Community
cancel
Showing results for 
Search instead for 
Did you mean: 
oiskuu
Beginner
32 Views

problematic idiv

The icc appears to have trouble optimizing with signed 64-bit divisions on x86_64. Sample compiled with icc-11.1.069:
[plain]s_div_rem:
        movq      %rdx, %rcx                                    
        movq      %rdi, %rax                                    
        cqto                                                    
        idivq     %rsi                                          
        movq      %rdi, %rax                                    
        movq      %rdx, (%rcx)                                  
        cqto                                                    
        idivq     %rsi                                          
        ret                                                     

u_div_rem:
        movq      %rdx, %rcx                                    
        movq      %rdi, %rax                                    
        xorl      %edx, %edx                                    
        divq      %rsi                                          
        movq      %rdx, (%rcx)                                  
        ret                                                     
[/plain]
Note that the compiler has failed to eliminate the second idiv. The source code is attached:
0 Kudos
2 Replies
Dale_S_Intel
Employee
32 Views

Sorry for the delay in responding. It looks suspicious to me as well. I'm consulting with our experts on the subject in case there's some subtlety that escapes me, but it could well be a missed optimization opportunity. Thanks for pointing this out, and for the concise test case. I'll let you know what I find.

Thanks!
Dale
Dale_S_Intel
Employee
32 Views

I've filed CQ153925 on this issue, I'll update here with further info.

Thanks!
Dale