@@ -103,9 +103,6 @@ let function = builder.addFunction(
103103let entryBB = function.appendBasicBlock (named : " entry" )
104104builder.positionAtEnd (of : entryBB)
105105
106- // allocate space for a local value
107- let local = builder.buildAlloca (type : FloatType.double , name : " local" )
108-
109106// Compare to the condition
110107let test = builder.buildICmp (function.parameters [0 ], IntType.int1 .zero (), .notEqual )
111108
@@ -120,15 +117,13 @@ builder.buildCondBr(condition: test, then: thenBB, else: elseBB)
120117builder.positionAtEnd (of : thenBB)
121118// local = 1/89, the fibonacci series (sort of)
122119let thenVal = FloatType.double .constant (1 / 89 )
123- builder.buildStore (thenVal, to : local)
124120// Branch to the merge block
125121builder.buildBr (mergeBB)
126122
127123// MARK: Else Block
128124builder.positionAtEnd (of : elseBB)
129125// local = 1/109, the fibonacci series (sort of) backwards
130126let elseVal = FloatType.double .constant (1 / 109 )
131- builder.buildStore (elseVal, to : local)
132127// Branch to the merge block
133128builder.buildBr (mergeBB)
134129
@@ -147,16 +142,13 @@ This program generates the following IR:
147142``` llvm
148143define double @calculateFibs(i1) {
149144entry:
150- %local = alloca double
151145 %1 = icmp ne i1 %0, false
152146 br i1 %1, label %then, label %else
153147
154148then: ; preds = %entry
155- store double 0x3F8702E05C0B8170, double* %local
156149 br label %merge
157150
158151else: ; preds = %entry
159- store double 0x3F82C9FB4D812CA0, double* %local
160152 br label %merge
161153
162154merge: ; preds = %else, %then
0 commit comments