https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91734
Bug ID: 91734 Summary: gcc skip an if statement with "-O1 -ffast-math" Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chinoune.mehdi at hotmail dot com Target Milestone: --- Building this program with gcc [8,9] "-O1 -ffast-math" makes the result overflows. #include <stdio.h> #include <float.h> #include <math.h> #include <complex.h> void foo(float complex z, float *y){ float const sqrt_flt_min = sqrtf( FLT_MIN ); float az; az = cabsf(z); //az = cabsf(z/sqrt_flt_min) * sqrt_flt_min; if( az<FLT_MIN ) az = cabsf(z/sqrt_flt_min) * sqrt_flt_min; printf("az = %.8e\n",az); *y = 1.f/az; } int main(){ float complex z; float y; z = 1.e-19f + 0.*I; foo(z,&y); printf("y = %.7e\n",y); return 0; } gcc-9 -O1 -fno-math-errno -funsafe-math-optimizations -ffinite-math-only -fdump-tree-optimized cbug_skip_if.c -o test.x -lm ./test.x az = 0.00000000e+00 y = inf cbug_skip_if.c.231t.optimized ;; Function foo (foo, funcdef_no=32, decl_uid=4150, cgraph_uid=33, symbol_order=32) foo (complex float z, float * y) { double _3; float _4; float cabs_17; float cabs_18; float cabs_19; float cabs_20; float cabs_21; float powroot_22; <bb 2> [local count: 1073741824]: cabs_17 = REALPART_EXPR <z_6(D)>; cabs_18 = cabs_17 * cabs_17; cabs_19 = IMAGPART_EXPR <z_6(D)>; cabs_20 = cabs_19 * cabs_19; cabs_21 = cabs_18 + cabs_20; powroot_22 = __builtin_sqrtf (cabs_21); _3 = (double) powroot_22; __printf_chk (1, "az = %.8e\n", _3); _4 = 1.0e+0 / powroot_22; *y_10(D) = _4; return; } ;; Function main (main, funcdef_no=33, decl_uid=4154, cgraph_uid=34, symbol_order=33) (executed once) main () { float y; float y.0_1; double _2; <bb 2> [local count: 1073741824]: foo (__complex__ (9.9999996826552253889678874634872052240552875446155667305e-20, 0.0), &y); y.0_1 = y; _2 = (double) y.0_1; __printf_chk (1, "y = %.7e\n", _2); y ={v} {CLOBBER}; return 0; } There is no if statement!