Understanding Dead Code Elimination

Let's look at a simple before-and-after example to see what you can expect from Dead Code Elimination.

Before:

WORKING-STORAGE SECTION.

 01 USED-VARS.
  05 USED1 PIC 9.

 01 DEAD-VARS.
  05 DEAD1 PIC 9.
  05 DEAD2 PIC X.

 PROCEDURE DIVISION.

 FIRST-USED-PARA.
  MOVE 1 TO USED1.
  GO TO SECOND-USED-PARA.
  MOVE 2 TO USED1.

 DEAD-PARA1.
  MOVE 0 TO DEAD2.
 
 SECOND-USED PARA.
  MOVE 3 TO USED1.
  STOP RUN.

After:

WORKING-STORAGE SECTION.

 01 USED-VARS.
  05 USED1 PIC 9.

 PROCEDURE DIVISION.

 FIRST-USED-PARA.
  MOVE 1 TO USED1.
  GO TO SECOND-USED-PARA.
  
 SECOND-USED PARA.
  MOVE 3 TO USED1.
  STOP RUN.