A computer-implemented method of predicting semantics of a program using a deep learning model comprising a first recurrent neural network, a bi-directional recurrent neural network, and a second recurrent neural network, the method comprising: receiving a plurality of execution traces of a program, each execution trace comprising a plurality of variable values; encoding, by the first recurrent neural network, the plurality of variable values to generate a plurality of program states for each execution trace; determining, by the bi-directional recurrent neural network, a reduced set of program states for each execution trace from the plurality of program states; encoding, by the second recurrent neural network, the reduced set of program states to generate a plurality of execution embeddings for the program; pooling the plurality of execution embeddings to generate a program embedding; and predicting the semantics of the program using the program embedding; and using the predicted semantics of the program to perform a compiler optimization task, wherein determining the reduced set of program states comprises: computing a forward sequence from the plurality of program states; computing a backward sequence from the plurality of program states; and for each program state in the plurality of program states: determining a forward context vector from the forward sequence; determining a backward context vector from the backward sequence; and determining, by a multi-layer perceptron, based on at least the forward context vector and backward context vector used as inputs to the multi-layer perceptron, to include the program state in the reduced set of program states, wherein the method is optimized to minimize a cross-entropy loss and minimize the number of program states in the reduced set of program states. receiving a plurality of execution traces of a program, each execution trace comprising a plurality of variable values; encoding, by the first recurrent neural network, the plurality of variable values to generate a plurality of program states for each execution trace; determining, by the bi-directional recurrent neural network, a reduced set of program states for each execution trace from the plurality of program states; encoding, by the second recurrent neural network, the reduced set of program states to generate a plurality of execution embeddings for the program; pooling the plurality of execution embeddings to generate a program embedding; and predicting the semantics of the program using the program embedding; and using the predicted semantics of the program to perform a compiler optimization task, computing a forward sequence from the plurality of program states; computing a backward sequence from the plurality of program states; and for each program state in the plurality of program states: determining a forward context vector from the forward sequence; determining a backward context vector from the backward sequence; and determining, by a multi-layer perceptron, based on at least the forward context vector and backward context vector used as inputs to the multi-layer perceptron, to include the program state in the reduced set of program states, wherein the method is optimized to minimize a cross-entropy loss and minimize the number of program states in the reduced set of program states. determining a forward context vector from the forward sequence; determining a backward context vector from the backward sequence; and determining, by a multi-layer perceptron, based on at least the forward context vector and backward context vector used as inputs to the multi-layer perceptron, to include the program state in the reduced set of program states, wherein the method is optimized to minimize a cross-entropy loss and minimize the number of program states in the reduced set of program states.