"James Van Buskirk" wrote in message news:s2hpql$pd9$1...@dont-email.me...
> Suppose we have a data segment:
> i2468: dd 2, 4, 6, 8
> f5101520: dd 5.0, 10.0, 15.0, 20.0
> Then eax = n, ecx = m, xmm2(0:31) = c
> sub eax, ecx
> movd xmm0, eax
> vpbroadcastd xmm0, xmm0
> movdqa xmm1, [i2468]
> pcmpgta xmm1, xmm2
> vpbroadcastd xmm2, xmm2
> movaps xmm3, [f5101520]
> cmpleps xmm2, xmm3
> vptest xmm1, xmm2
> jnc skip
> call f
> skip:
> Hopefully the interested reader can check my untested code above.
Testing revealed a couple of typos. Therefore:
D:\gfortran\clf\condition>type test.asm
format MS64 COFF
section '.text' code readable executable align 16
extrn f
public testme
testme:
sub edx, ecx
movd xmm0, edx
vpbroadcastd xmm0, xmm0
movdqa xmm1, [i2468]
pcmpgtd xmm1, xmm0
vpbroadcastd xmm2, xmm2
movaps xmm3, [f5101520]
cmpleps xmm2, xmm3
vptest xmm1, xmm2
jnc skip
sub rsp, 40
call f
add rsp, 40
skip:
ret
section 'data' data readable align 16
i2468: dd 2, 4, 6, 8
f5101520: dd 5.0, 10.0, 15.0, 20.0
D:\gfortran\clf\condition>fasm test.asm
flat assembler version 1.71.49 (1048576 kilobytes memory)
3 passes, 298 bytes.
D:\gfortran\clf\condition>type condition.f90
module stuff
use ISO_C_BINDING
implicit none
interface
subroutine testme(m,n,c) bind(C,name='testme')
import
implicit none
integer(C_INT), value :: m
integer(C_INT), value :: n
real(C_FLOAT), value :: c
end subroutine testme
end interface
contains
subroutine f() bind(C,name='f')
write(*,'(a)') 'Subroutine f was called'
end subroutine f
end module stuff
program condition
use stuff
implicit none
integer, parameter :: marray(0:1) = [16,17]
real, parameter :: carray(0:1) = [10.0,nearest(10.0,1.0)]
real r, x, v1, c
integer i, n, m
integer j
n = 20
r = 1.0
i = 2
x = 1.0
write(*,'(a)') 'Original'
do j = 0, 3
m = marray(mod(j,2))
c = carray(j/2)
write(*,'(*(g0))') 'm = ',m,', n = ',n,', c = ',c
if(r == 0 .OR. i == 1 .OR. x == 0.0) go to 30
v1 = 1
if(m <= (n-2) .AND. c <= 5.0) go to 30
if(m <= (n-4) .AND. c <= 10.0) go to 30
if(m <= (n-6) .AND. c <= 15.0) go to 30
if(m <= (n-7) .AND. c <= 20.0) go to 30
call f
30 continue
end do
write(*,'(a)') 'Converted Fortran'
do j = 0, 3
m = marray(mod(j,2))
c = carray(j/2)
write(*,'(*(g0))') 'm = ',m,', n = ',n,', c = ',c
if(.NOT.(r == 0 .OR. i == 1 .OR. x == 0.0)) then
v1 = 1
if(.NOT.any(m <= n-[2,4,6,8] .AND. c <= [5.0,10.0,15.0,20.0])) call
f
end if
end do
write(*,'(a)') 'Converted FASM'
do j = 0, 3
m = marray(mod(j,2))
c = carray(j/2)
write(*,'(*(g0))') 'm = ',m,', n = ',n,', c = ',c
if(.NOT.(r == 0 .OR. i == 1 .OR. x == 0.0)) then
v1 = 1
call testme(m,n,c)
end if
end do
end program condition
D:\gfortran\clf\condition>gfortran condition.f90 test.obj -ocondition
D:\gfortran\clf\condition>condition
Original
m = 16, n = 20, c = 10.0000000
m = 17, n = 20, c = 10.0000000
Subroutine f was called
m = 16, n = 20, c = 10.0000010
Subroutine f was called
m = 17, n = 20, c = 10.0000010
Subroutine f was called
Converted Fortran
m = 16, n = 20, c = 10.0000000
m = 17, n = 20, c = 10.0000000
Subroutine f was called
m = 16, n = 20, c = 10.0000010
Subroutine f was called
m = 17, n = 20, c = 10.0000010
Subroutine f was called
Converted FASM
m = 16, n = 20, c = 10.0000000
m = 17, n = 20, c = 10.0000000
Subroutine f was called
m = 16, n = 20, c = 10.0000010
Subroutine f was called
m = 17, n = 20, c = 10.0000010
Subroutine f was called
D:\gfortran\clf\condition>