c - Prevent call to v/ucomisd before sqrt -


i optimizing code, , coming this

#include <math.h>  typedef double vector __attribute__((vector_size(16)));  double norm_vector(vector u) {   vector w = u*u;   return sqrt(w[0]+w[1]); } 

i discovered compiling with

gcc -xc -std=gnu11 -o3  -wall -wextra -fno-verbose-asm -march=haswell 

prior call sqrt vucomisd instruction executed

norm_vector:         vmulpd  xmm0, xmm0, xmm0         vhaddpd xmm1, xmm0, xmm0         vsqrtsd xmm0, xmm0, xmm1         vucomisd        xmm0, xmm0         jp      .l13         ret .l13:         sub     rsp, 8         vmovapd xmm0, xmm1         call    sqrt         add     rsp, 8         ret 

is taking care argument of sqrt non-negative? in case want avoid call (since definition argument positive), how this?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -