QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: NOVARSEG on March 05, 2021, 10:56:50 pm

Title: Is the compiler influenced by GOTO?
Post by: NOVARSEG on March 05, 2021, 10:56:50 pm
So I am messing with EXE files with DAV hex editor and found that

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

In the EXE file there is no trace of the compiled instruction  for  A = 1094795585
is that normal?

When the GOTO is commented out, then both instructions for A = 1094795585 and B = 1094795585 show up in the EXE

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
'GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585


What about this case. What will the compiler do now?

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
DIM r AS SINGLE
r = RND

IF r > .5 AND r < .6 THEN GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

Title: Re: Is the compiler influenced by GOTO?
Post by: luke on March 05, 2021, 11:26:48 pm
https://en.m.wikipedia.org/wiki/Dead_code_elimination
Title: Re: Is the compiler influenced by GOTO?
Post by: NOVARSEG on March 06, 2021, 01:07:15 am
For that last code example



Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
DIM r AS SINGLE
r = RND

IF r > .5 AND r < .6 THEN GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

The compiler will not skip the instruction because the GOTO is conditional