Comment 5 for bug 682536

Revision history for this message
Matt Giuca (mgiuca) wrote :

Note that if you generate some more temporaries before the switch, the unpack temporaries do not start from 0; they start from the index which the switch started at:

    i = add(1, 2)
    switch Pair(1, 2):
        case Pair(x, y):
            pass

becomes:

    Block 0:
        # Preds: []
        $T:0 = 1
        $T:0:1 = 2
        i:0 = @add($T:0, $T:0:1)
        $T:0:3 = Pair
        $T:0:4 = 1
        $T:0:5 = 2
        $T:0:2 = $T:0:3($T:0:4, $T:0:5)
        $T:0:2 = $T:0:2.[Pair: 0]
        $T:0:3 = $T:0:2.[Pair: 1]

Note that temporaries 0 and 1 are used to compute i. Temporaries 2, 3, 4 and 5 are used to compute the switch value, and then temporaries 2 and 3 hold the unpack values. So it is using the subscript map from the beginning of the switch rather than the one after the switch value is generated.