http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60646
--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Tue, Mar 25, 2014 at 03:36:35PM +0000, kargl at gcc dot gnu.org wrote: > > Can you be a little more specific on what you want > to investigate? AFAIK, the general handling of > complex division is done be the middle-end. > > % cat l.f90 > subroutine loo(z1,z2,z3) > complex z1, z2, z3 > z3 = z1 / z2 > end subroutine loo > % gfc4x -fdump-tree-all -c l.f90 > > l.f90.cplxlower0 is definitely coming from the > middle-end. > It looks like the middle-end is using the Smith algorithm as described in the paper. The middle definitely has some issues. The attached programs were used to test the values given in Figure 6 of the paper. The compile command line was gfortran -o z -O k.f90 cdiv.f90 and I ran the test on x86_64-*-freebsd (ie., no i387 extended precision in sight). The output includes 'Expected', 'MiddleEnd', and 'Folding', where the first is the expected value, the second is from the gcc middle-end, and last is from gfortran's constant folding. The first column is the real part and the second is the imaginary part. Expected = 1.112536929253601-308 -1.112536929253601-308 MiddleEnd = 1.112536929253601-308 -1.112536929253601-308 Folding = 1.112536929253601-308 -1.112536929253601-308 Expected = 8.988465674311580+307 0.000000000000000E+00 MiddleEnd = 8.988465674311580+307 0.000000000000000E+00 Folding = 8.988465674311580+307 0.000000000000000E+00 Expected = 1.433436634993795+104 -3.645561009778199-304 MiddleEnd = 1.433436634993795+104 0.000000000000000E+00 Folding = 1.433436634993795+104 -3.645561009778199-304 Expected = 8.988465674311580+307 0.000000000000000E+00 MiddleEnd = Infinity 0.000000000000000E+00 Folding = 8.988465674311580+307 0.000000000000000E+00 Expected = 3.757668132438133+109 -1.976262583364986-323 MiddleEnd = 3.757668132438133+109 0.000000000000000E+00 Folding = 3.757668132438133+109 -1.976262583364986-323 Expected = 1.976262583364986-323 1.048576000000000E+06 MiddleEnd = 1.976262583364986-323 1.048576000000000E+06 Folding = 1.976262583364986-323 1.048576000000000E+06 Expected = 3.898125604559113+289 8.174961907852354+295 MiddleEnd = 3.898125604560000+289 8.174961907854212+295 Folding = 3.898125604559113+289 8.174961907852354+295 Expected = 6.000000000000000E-01 2.000000000000000E-01 MiddleEnd = 5.000000000000000E-01 5.000000000000000E-01 Folding = 6.000000000000000E-01 2.000000000000000E-01 Expected = 1.953125000000000E-03 -1.953125000000000E-03 MiddleEnd = 0.000000000000000E+00 -0.000000000000000E+00 Folding = 1.953125000000000E-03 -1.953125000000000E-03 Expected = 1.029511517893606E-84 6.971459875150762-220 MiddleEnd = 1.029511517893606E-84 7.082117968407124-220 Folding = 1.029511517893606E-84 6.971459875150762-220