Answers to the Exercises

1.  A traditional compiler would segment the code as such:
 
        IF:                addi i, j, #1
                            p1, p2 compare i, inputval
                            jump if p2

        THEN:         sqrt i, i
          (p1)            jump to next block

        ELSE:           addi i, i, #1
          (p2)

        NEXT:         add j, inputval, i
 

A compiler for the IA-64 would organize the code like this:

                                addi i, j,#1
                                p1, p2 compare i, inputval
            p1    sqrt i, i                            p2    addi i, i,#1
                                add j, inputval, i
 

2.  Here's what a traditional compiler might do:

                                p1, compare datavalue, defaultvalue
                                jump p1

                                store b[i], a[datavalue + i]
                                subi a[i], a[i], #1

The IA-64 compiler would do this:

                                ld.s R4 = a[datavalue + i]
                                p1 compare datavalue, defaultvalue
                                jump p1

                                check.s R4
                                store b[i], R8
                                subi a[i], a[i], #1
 

  Back to the previous page.