8.5.7 Benefits of DAGs (2024)

When a DAG is created, common subexpressions are detected. Also,creating a DAG makes it easy to see variables and expressionswhich are used or defined within a block.

DAGs also produce good code at code generation time. In Module11, we will see a code generation algorithm which produces good(but not optimal!) code from a DAG.

Example 6 shows a bubble sort procedure and a set of quadruplesto which it might be translated. Quadruples are an intermediaterepresentation consisting of a single operation, up to two operandsand a result. They are easier for humans to read than an abstractsyntax tree. The quadruples shown here are in "assignment statement" form.

EXAMPLE 6 IR for a bubble sort procedureFOR I := 1 TO n - 1 DO FOR J := 1 TO I DOIF A[J] > A[J+1] THEN BEGINTemp := A[J]A[J] := A[ J + 1 ]A[ J + 1 ] := Temp END8.5.7 Benefits of DAGs (1)I := 1GOTO ITestILoop:J := 1GOTO JTestJLoop:T1 := 4 * JT2 := A [T1] ; A[J]T3 := J + 1T4 := 4 * T3T5 := A[T4] ; A[ J + 1 ]IF T2 <= T5 GOTO JPlusT6 := 4 * JTemp := A[T6] ; Temp := A[J]T7 := J + 1T8 := 4 * T7T9 := A[T8] ; A { J + 1 ]T10 := 4 * JA[T10] := T9 ; A[J] := A[ J + 1 ]T11 := J + 1T12 := 4 * T11A[T12] := Temp; A [ J + 1 ] := TempJPlus:J := J + 1JTest:IF J &lt = I GOTO JLoopIPlus:I := I + 1ITest:IF I &lt= n - 1 GOTO ILoop
    The intermediate code shown in Example 6 is rather high-level. For machines which have no indexing modes, the references to A[...] will have to be computed by the compiler. Also, the IF statements really involve several quadruples (see Module 6). The multiplication by "4" could, alternatively, be done at code generation time. We do it here because it will give us more opportunities for optimization of our example.

    Using "( )" to mean "contents of " and "addr" to mean "address of", the low-level quadruples for "Temp := List[i]" might be:

T1 := addr(List)T2 := T1 + Itemp := (T2)
    Similarly, if the array reference is on the left-hand side of an assignment statement as in "List[i] := temp", low-level quadruples would be:
T1 := addr (List)T2 := T1 + I(T2) := Temp
    Even if a machine has an indexing addressing mode, translating array references into their low-level format may allow optimizations (for example, if the subscript reference were a common subexpression).

    Nevertheless, there will be numerous opportunities to improve the code sequence in Example 6.

Example 7 shows the basic blocks and the control flow graph for the procedure in Example 6.
8.5.7 Benefits of DAGs (2)
    Example 8 shows a DAG for block 3 of Example 8.
    8.5.7 Benefits of DAGs (3)
      The program of Example 7 contains cycles which may be loops. Determining loops is a major activity of control flow analysis. Creating basic blocks and a control flow graph are two steps toward this process. In the next section, we will formalize the process of determining a loop in a control flow graph.

    8.5.7 Benefits of DAGs (4)

    Send questions and comments to: Karen Lemone
    8.5.7 Benefits of DAGs (2024)
    Top Articles
    Kakao Talk Revenue and Growth Statistics (2024) - SignHouse
    Log4j Zero-Day Vulnerability: Everything You Need To Know - Spiceworks
    Mickey Moniak Walk Up Song
    Spectrum Gdvr-2007
    Skylar Vox Bra Size
    Skamania Lodge Groupon
    Best Team In 2K23 Myteam
    Maria Dolores Franziska Kolowrat Krakowská
    Missing 2023 Showtimes Near Cinemark West Springfield 15 And Xd
    Wells Fargo Careers Log In
    Ati Capstone Orientation Video Quiz
    Corpse Bride Soap2Day
    Nj Scratch Off Remaining Prizes
    Hair Love Salon Bradley Beach
    Burn Ban Map Oklahoma
    Apne Tv Co Com
    Imagetrend Inc, 20855 Kensington Blvd, Lakeville, MN 55044, US - MapQuest
    Tygodnik Polityka - Polityka.pl
    Air Force Chief Results
    Wausau Marketplace
    Earl David Worden Military Service
    Big Lots Weekly Advertisem*nt
    Never Give Up Quotes to Keep You Going
    Best Nail Salons Open Near Me
    Mandy Rose - WWE News, Rumors, & Updates
    Mjc Financial Aid Phone Number
    Turns As A Jetliner Crossword Clue
    Uncovering the Enigmatic Trish Stratus: From Net Worth to Personal Life
    Stubhub Elton John Dodger Stadium
    Franklin Villafuerte Osorio
    Mkvcinemas Movies Free Download
    Gina's Pizza Port Charlotte Fl
    Craigslist Albany Ny Garage Sales
    Today's Final Jeopardy Clue
    Bitchinbubba Face
    Page 5662 – Christianity Today
    Mytime Maple Grove Hospital
    5A Division 1 Playoff Bracket
    Despacito Justin Bieber Lyrics
    Arnesons Webcam
    [Teen Titans] Starfire In Heat - Chapter 1 - Umbrelloid - Teen Titans
    Yale College Confidential 2027
    The Great Brian Last
    Alba Baptista Bikini, Ethnicity, Marriage, Wedding, Father, Shower, Nazi
    Human Resources / Payroll Information
    Minterns German Shepherds
    French Linen krijtverf van Annie Sloan
    Makes A Successful Catch Maybe Crossword Clue
    Image Mate Orange County
    Grandma's Portuguese Sweet Bread Recipe Made from Scratch
    Renfield Showtimes Near Regal The Loop & Rpx
    Latest Posts
    Article information

    Author: Lilliana Bartoletti

    Last Updated:

    Views: 5636

    Rating: 4.2 / 5 (53 voted)

    Reviews: 84% of readers found this page helpful

    Author information

    Name: Lilliana Bartoletti

    Birthday: 1999-11-18

    Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

    Phone: +50616620367928

    Job: Real-Estate Liaison

    Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

    Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.