@@ -103,9 +103,6 @@ let function = builder.addFunction(
103
103
let entryBB = function.appendBasicBlock (named : " entry" )
104
104
builder.positionAtEnd (of : entryBB)
105
105
106
- // allocate space for a local value
107
- let local = builder.buildAlloca (type : FloatType.double , name : " local" )
108
-
109
106
// Compare to the condition
110
107
let test = builder.buildICmp (function.parameters [0 ], IntType.int1 .zero (), .notEqual )
111
108
@@ -120,15 +117,13 @@ builder.buildCondBr(condition: test, then: thenBB, else: elseBB)
120
117
builder.positionAtEnd (of : thenBB)
121
118
// local = 1/89, the fibonacci series (sort of)
122
119
let thenVal = FloatType.double .constant (1 / 89 )
123
- builder.buildStore (thenVal, to : local)
124
120
// Branch to the merge block
125
121
builder.buildBr (mergeBB)
126
122
127
123
// MARK: Else Block
128
124
builder.positionAtEnd (of : elseBB)
129
125
// local = 1/109, the fibonacci series (sort of) backwards
130
126
let elseVal = FloatType.double .constant (1 / 109 )
131
- builder.buildStore (elseVal, to : local)
132
127
// Branch to the merge block
133
128
builder.buildBr (mergeBB)
134
129
@@ -147,16 +142,13 @@ This program generates the following IR:
147
142
``` llvm
148
143
define double @calculateFibs(i1) {
149
144
entry:
150
- %local = alloca double
151
145
%1 = icmp ne i1 %0, false
152
146
br i1 %1, label %then, label %else
153
147
154
148
then: ; preds = %entry
155
- store double 0x3F8702E05C0B8170, double* %local
156
149
br label %merge
157
150
158
151
else: ; preds = %entry
159
- store double 0x3F82C9FB4D812CA0, double* %local
160
152
br label %merge
161
153
162
154
merge: ; preds = %else, %then
0 commit comments