Browse Prior Art Database

Method and Apparatus for Switch Statement in Single-Instruction-Multiple-Data Computing Systems

IP.com Disclosure Number: IPCOM000190119D
Original Publication Date: 2009-Nov-18
Included in the Prior Art Database: 2009-Nov-18
Document File: 3 page(s) / 24K

Publishing Venue

IBM

Abstract

The present article provides an improved method and apparatus for switch statement in modern computing systems which feature SIMD capacity. The core idea proposes a SIMDized branch instruction to speedup the processing of switch statement. It is a more generic method compared with the branch table and the indexed function pointers approaches.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 57% of the total text.

Page 1 of 3

Method and Apparatus for Switch Statement in Single-Instruction-Multiple-Data Computing Systems

In computer programming, a switch statement is a type of control statement that exists in most modern imperative programming languages (e.g., C, C++, C#, and Java). Its purpose is to allow the value of a variable or expression to control the flow of program execution. In some other programming languages, a statement that is syntactically different but conceptually the same as the switch statement is known as a case statement or a select statement.

If the range of input values is identifiably 'small' and has only a few gaps, some compilers that incorporate an optimizer, may actually implement the switch statement as a branch table or an array of indexed function pointers (a lookup table) instead of a lengthy series of conditional instructions - which can be very much faster.

Normally, the only method of finding out if this optimization has happened is by actually looking at the resultant

assembler or machine code output that has been generated by the compiler. The first 'C' example below would be eligible for this kind of optimization if the compiler supported it.

switch(n) {

case 0:

printf("You typed zero.\n");

break;

case 1:

case 9:

printf("n is a perfect square\n");

break;

case 3:

case 5:

case 7:

printf("n is a prime number\n");

break;

case 2:

printf("n is a prime number\n");

case 4:

case 6:

case 8:

printf("n is an even number\n");

break;

default:

printf("Only single-digit numbers are allowed\n");

break; }

1

Page 2 of 3

Fig 1 Single Instruction, Multiple Data

In computing, SIMD (Single Instruction, Multiple Data) is a technique employed to achieve data level parallelism, as in a vector processor. First made pop...