blob: 178d29e257d8649cc354ce9be953f7c69eb1333f [file] [log] [blame]
Chris Lattner210e45a2009-12-04 02:10:16 +00001//===- PHITransAddr.cpp - PHI Translation for Addresses -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the PHITransAddr class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Analysis/PHITransAddr.h"
15#include "llvm/Analysis/Dominators.h"
Chris Lattner9a864122009-12-07 18:36:53 +000016#include "llvm/Analysis/InstructionSimplify.h"
David Greene2a0f3cc2009-12-23 21:06:14 +000017#include "llvm/Support/Debug.h"
Chris Lattner7dedbf42009-12-09 00:01:00 +000018#include "llvm/Support/raw_ostream.h"
Chris Lattner210e45a2009-12-04 02:10:16 +000019using namespace llvm;
20
Chris Lattner6fcca1c2009-12-07 19:04:49 +000021static bool CanPHITrans(Instruction *Inst) {
22 if (isa<PHINode>(Inst) ||
Chris Lattner6fcca1c2009-12-07 19:04:49 +000023 isa<GetElementPtrInst>(Inst))
24 return true;
Dan Gohmance562622010-11-18 17:05:13 +000025
26 if (isa<CastInst>(Inst) &&
27 Inst->isSafeToSpeculativelyExecute())
28 return true;
Chris Lattner6fcca1c2009-12-07 19:04:49 +000029
Chris Lattner34f84902009-12-08 06:06:26 +000030 if (Inst->getOpcode() == Instruction::Add &&
Chris Lattner6fcca1c2009-12-07 19:04:49 +000031 isa<ConstantInt>(Inst->getOperand(1)))
32 return true;
33
34 // cerr << "MEMDEP: Could not PHI translate: " << *Pointer;
35 // if (isa<BitCastInst>(PtrInst) || isa<GetElementPtrInst>(PtrInst))
36 // cerr << "OP:\t\t\t\t" << *PtrInst->getOperand(0);
37 return false;
38}
39
Chris Lattner7dedbf42009-12-09 00:01:00 +000040void PHITransAddr::dump() const {
41 if (Addr == 0) {
David Greene2a0f3cc2009-12-23 21:06:14 +000042 dbgs() << "PHITransAddr: null\n";
Chris Lattner7dedbf42009-12-09 00:01:00 +000043 return;
44 }
David Greene2a0f3cc2009-12-23 21:06:14 +000045 dbgs() << "PHITransAddr: " << *Addr << "\n";
Chris Lattner7dedbf42009-12-09 00:01:00 +000046 for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
David Greene2a0f3cc2009-12-23 21:06:14 +000047 dbgs() << " Input #" << i << " is " << *InstInputs[i] << "\n";
Chris Lattner7dedbf42009-12-09 00:01:00 +000048}
49
50
51static bool VerifySubExpr(Value *Expr,
52 SmallVectorImpl<Instruction*> &InstInputs) {
53 // If this is a non-instruction value, there is nothing to do.
54 Instruction *I = dyn_cast<Instruction>(Expr);
55 if (I == 0) return true;
56
57 // If it's an instruction, it is either in Tmp or its operands recursively
58 // are.
59 SmallVectorImpl<Instruction*>::iterator Entry =
60 std::find(InstInputs.begin(), InstInputs.end(), I);
61 if (Entry != InstInputs.end()) {
62 InstInputs.erase(Entry);
63 return true;
64 }
65
66 // If it isn't in the InstInputs list it is a subexpr incorporated into the
67 // address. Sanity check that it is phi translatable.
68 if (!CanPHITrans(I)) {
David Greenea8e21d42009-12-23 23:27:15 +000069 errs() << "Non phi translatable instruction found in PHITransAddr, either "
Chris Lattner7dedbf42009-12-09 00:01:00 +000070 "something is missing from InstInputs or CanPHITrans is wrong:\n";
David Greenea8e21d42009-12-23 23:27:15 +000071 errs() << *I << '\n';
Chris Lattner7dedbf42009-12-09 00:01:00 +000072 return false;
73 }
74
75 // Validate the operands of the instruction.
76 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
77 if (!VerifySubExpr(I->getOperand(i), InstInputs))
78 return false;
79
80 return true;
81}
82
83/// Verify - Check internal consistency of this data structure. If the
84/// structure is valid, it returns true. If invalid, it prints errors and
85/// returns false.
86bool PHITransAddr::Verify() const {
87 if (Addr == 0) return true;
88
89 SmallVector<Instruction*, 8> Tmp(InstInputs.begin(), InstInputs.end());
90
91 if (!VerifySubExpr(Addr, Tmp))
92 return false;
93
94 if (!Tmp.empty()) {
David Greenea8e21d42009-12-23 23:27:15 +000095 errs() << "PHITransAddr inconsistent, contains extra instructions:\n";
Chris Lattner7dedbf42009-12-09 00:01:00 +000096 for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
David Greenea8e21d42009-12-23 23:27:15 +000097 errs() << " InstInput #" << i << " is " << *InstInputs[i] << "\n";
Chris Lattner7dedbf42009-12-09 00:01:00 +000098 return false;
99 }
100
101 // a-ok.
102 return true;
103}
104
105
Chris Lattner9a864122009-12-07 18:36:53 +0000106/// IsPotentiallyPHITranslatable - If this needs PHI translation, return true
107/// if we have some hope of doing it. This should be used as a filter to
108/// avoid calling PHITranslateValue in hopeless situations.
109bool PHITransAddr::IsPotentiallyPHITranslatable() const {
110 // If the input value is not an instruction, or if it is not defined in CurBB,
111 // then we don't need to phi translate it.
112 Instruction *Inst = dyn_cast<Instruction>(Addr);
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000113 return Inst == 0 || CanPHITrans(Inst);
Chris Lattner210e45a2009-12-04 02:10:16 +0000114}
115
Chris Lattner9a864122009-12-07 18:36:53 +0000116
Chris Lattner6200e532009-12-09 00:56:14 +0000117static void RemoveInstInputs(Value *V,
Chris Lattner43678f42009-12-08 23:42:51 +0000118 SmallVectorImpl<Instruction*> &InstInputs) {
Chris Lattner6200e532009-12-09 00:56:14 +0000119 Instruction *I = dyn_cast<Instruction>(V);
120 if (I == 0) return;
121
Chris Lattner43678f42009-12-08 23:42:51 +0000122 // If the instruction is in the InstInputs list, remove it.
123 SmallVectorImpl<Instruction*>::iterator Entry =
124 std::find(InstInputs.begin(), InstInputs.end(), I);
125 if (Entry != InstInputs.end()) {
126 InstInputs.erase(Entry);
127 return;
128 }
129
Chris Lattner6200e532009-12-09 00:56:14 +0000130 assert(!isa<PHINode>(I) && "Error, removing something that isn't an input");
Chris Lattner43678f42009-12-08 23:42:51 +0000131
Chris Lattner6200e532009-12-09 00:56:14 +0000132 // Otherwise, it must have instruction inputs itself. Zap them recursively.
133 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
134 if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(i)))
135 RemoveInstInputs(Op, InstInputs);
136 }
Chris Lattner43678f42009-12-08 23:42:51 +0000137}
138
Chris Lattner9a864122009-12-07 18:36:53 +0000139Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000140 BasicBlock *PredBB,
141 const DominatorTree *DT) {
Chris Lattner9a864122009-12-07 18:36:53 +0000142 // If this is a non-instruction value, it can't require PHI translation.
143 Instruction *Inst = dyn_cast<Instruction>(V);
144 if (Inst == 0) return V;
145
Chris Lattneraf503152009-12-09 00:10:55 +0000146 // Determine whether 'Inst' is an input to our PHI translatable expression.
147 bool isInput = std::count(InstInputs.begin(), InstInputs.end(), Inst);
148
149 // Handle inputs instructions if needed.
150 if (isInput) {
151 if (Inst->getParent() != CurBB) {
152 // If it is an input defined in a different block, then it remains an
153 // input.
154 return Inst;
155 }
Chris Lattnere09e98c2009-12-09 00:18:13 +0000156
157 // If 'Inst' is defined in this block and is an input that needs to be phi
158 // translated, we need to incorporate the value into the expression or fail.
159
Chris Lattner6200e532009-12-09 00:56:14 +0000160 // In either case, the instruction itself isn't an input any longer.
161 InstInputs.erase(std::find(InstInputs.begin(), InstInputs.end(), Inst));
162
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000163 // If this is a PHI, go ahead and translate it.
164 if (PHINode *PN = dyn_cast<PHINode>(Inst))
Chris Lattner6200e532009-12-09 00:56:14 +0000165 return AddAsInput(PN->getIncomingValueForBlock(PredBB));
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000166
167 // If this is a non-phi value, and it is analyzable, we can incorporate it
168 // into the expression by making all instruction operands be inputs.
169 if (!CanPHITrans(Inst))
170 return 0;
Chris Lattnere09e98c2009-12-09 00:18:13 +0000171
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000172 // All instruction operands are now inputs (and of course, they may also be
173 // defined in this block, so they may need to be phi translated themselves.
174 for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
175 if (Instruction *Op = dyn_cast<Instruction>(Inst->getOperand(i)))
176 InstInputs.push_back(Op);
Chris Lattner9a864122009-12-07 18:36:53 +0000177 }
178
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000179 // Ok, it must be an intermediate result (either because it started that way
180 // or because we just incorporated it into the expression). See if its
181 // operands need to be phi translated, and if so, reconstruct it.
Chris Lattner9a864122009-12-07 18:36:53 +0000182
Dan Gohmance562622010-11-18 17:05:13 +0000183 if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
184 if (!Cast->isSafeToSpeculativelyExecute()) return 0;
185 Value *PHIIn = PHITranslateSubExpr(Cast->getOperand(0), CurBB, PredBB, DT);
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000186 if (PHIIn == 0) return 0;
Dan Gohmance562622010-11-18 17:05:13 +0000187 if (PHIIn == Cast->getOperand(0))
188 return Cast;
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000189
190 // Find an available version of this cast.
191
192 // Constants are trivial to find.
193 if (Constant *C = dyn_cast<Constant>(PHIIn))
Dan Gohmance562622010-11-18 17:05:13 +0000194 return AddAsInput(ConstantExpr::getCast(Cast->getOpcode(),
195 C, Cast->getType()));
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000196
Dan Gohmance562622010-11-18 17:05:13 +0000197 // Otherwise we have to see if a casted version of the incoming pointer
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000198 // is available. If so, we can use it, otherwise we have to fail.
199 for (Value::use_iterator UI = PHIIn->use_begin(), E = PHIIn->use_end();
200 UI != E; ++UI) {
Dan Gohmance562622010-11-18 17:05:13 +0000201 if (CastInst *CastI = dyn_cast<CastInst>(*UI))
202 if (CastI->getOpcode() == Cast->getOpcode() &&
203 CastI->getType() == Cast->getType() &&
204 (!DT || DT->dominates(CastI->getParent(), PredBB)))
205 return CastI;
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000206 }
207 return 0;
208 }
Chris Lattner9a864122009-12-07 18:36:53 +0000209
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000210 // Handle getelementptr with at least one PHI translatable operand.
211 if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
212 SmallVector<Value*, 8> GEPOps;
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000213 bool AnyChanged = false;
214 for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000215 Value *GEPOp = PHITranslateSubExpr(GEP->getOperand(i), CurBB, PredBB, DT);
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000216 if (GEPOp == 0) return 0;
217
Chris Lattner60454172009-12-07 19:52:57 +0000218 AnyChanged |= GEPOp != GEP->getOperand(i);
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000219 GEPOps.push_back(GEPOp);
220 }
221
222 if (!AnyChanged)
223 return GEP;
224
225 // Simplify the GEP to handle 'gep x, 0' -> x etc.
Duncan Sands18450092010-11-16 12:16:38 +0000226 if (Value *V = SimplifyGEPInst(&GEPOps[0], GEPOps.size(), TD, DT)) {
Chris Lattner6200e532009-12-09 00:56:14 +0000227 for (unsigned i = 0, e = GEPOps.size(); i != e; ++i)
228 RemoveInstInputs(GEPOps[i], InstInputs);
229
230 return AddAsInput(V);
231 }
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000232
233 // Scan to see if we have this GEP available.
234 Value *APHIOp = GEPOps[0];
235 for (Value::use_iterator UI = APHIOp->use_begin(), E = APHIOp->use_end();
236 UI != E; ++UI) {
237 if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(*UI))
238 if (GEPI->getType() == GEP->getType() &&
239 GEPI->getNumOperands() == GEPOps.size() &&
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000240 GEPI->getParent()->getParent() == CurBB->getParent() &&
241 (!DT || DT->dominates(GEPI->getParent(), PredBB))) {
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000242 bool Mismatch = false;
243 for (unsigned i = 0, e = GEPOps.size(); i != e; ++i)
244 if (GEPI->getOperand(i) != GEPOps[i]) {
245 Mismatch = true;
246 break;
247 }
248 if (!Mismatch)
249 return GEPI;
250 }
251 }
252 return 0;
253 }
254
255 // Handle add with a constant RHS.
256 if (Inst->getOpcode() == Instruction::Add &&
257 isa<ConstantInt>(Inst->getOperand(1))) {
258 // PHI translate the LHS.
259 Constant *RHS = cast<ConstantInt>(Inst->getOperand(1));
260 bool isNSW = cast<BinaryOperator>(Inst)->hasNoSignedWrap();
261 bool isNUW = cast<BinaryOperator>(Inst)->hasNoUnsignedWrap();
262
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000263 Value *LHS = PHITranslateSubExpr(Inst->getOperand(0), CurBB, PredBB, DT);
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000264 if (LHS == 0) return 0;
265
266 // If the PHI translated LHS is an add of a constant, fold the immediates.
267 if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(LHS))
268 if (BOp->getOpcode() == Instruction::Add)
269 if (ConstantInt *CI = dyn_cast<ConstantInt>(BOp->getOperand(1))) {
270 LHS = BOp->getOperand(0);
271 RHS = ConstantExpr::getAdd(RHS, CI);
272 isNSW = isNUW = false;
Chris Lattner6200e532009-12-09 00:56:14 +0000273
274 // If the old 'LHS' was an input, add the new 'LHS' as an input.
275 if (std::count(InstInputs.begin(), InstInputs.end(), BOp)) {
276 RemoveInstInputs(BOp, InstInputs);
277 AddAsInput(LHS);
278 }
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000279 }
280
281 // See if the add simplifies away.
Duncan Sands18450092010-11-16 12:16:38 +0000282 if (Value *Res = SimplifyAddInst(LHS, RHS, isNSW, isNUW, TD, DT)) {
Chris Lattner6200e532009-12-09 00:56:14 +0000283 // If we simplified the operands, the LHS is no longer an input, but Res
284 // is.
285 RemoveInstInputs(LHS, InstInputs);
286 return AddAsInput(Res);
287 }
Chris Lattner4d3a16f2009-12-09 17:27:45 +0000288
289 // If we didn't modify the add, just return it.
290 if (LHS == Inst->getOperand(0) && RHS == Inst->getOperand(1))
291 return Inst;
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000292
293 // Otherwise, see if we have this add available somewhere.
294 for (Value::use_iterator UI = LHS->use_begin(), E = LHS->use_end();
295 UI != E; ++UI) {
296 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(*UI))
Chris Lattnereddc65a2009-12-09 17:18:49 +0000297 if (BO->getOpcode() == Instruction::Add &&
298 BO->getOperand(0) == LHS && BO->getOperand(1) == RHS &&
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000299 BO->getParent()->getParent() == CurBB->getParent() &&
300 (!DT || DT->dominates(BO->getParent(), PredBB)))
Chris Lattner6fcca1c2009-12-07 19:04:49 +0000301 return BO;
302 }
303
304 return 0;
305 }
306
307 // Otherwise, we failed.
308 return 0;
Chris Lattner210e45a2009-12-04 02:10:16 +0000309}
310
Chris Lattner9a864122009-12-07 18:36:53 +0000311
312/// PHITranslateValue - PHI translate the current address up the CFG from
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000313/// CurBB to Pred, updating our state to reflect any needed changes. If the
314/// dominator tree DT is non-null, the translated value must dominate
315/// PredBB. This returns true on failure and sets Addr to null.
316bool PHITransAddr::PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB,
317 const DominatorTree *DT) {
Chris Lattner7dedbf42009-12-09 00:01:00 +0000318 assert(Verify() && "Invalid PHITransAddr!");
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000319 Addr = PHITranslateSubExpr(Addr, CurBB, PredBB, DT);
Chris Lattner7dedbf42009-12-09 00:01:00 +0000320 assert(Verify() && "Invalid PHITransAddr!");
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000321
322 if (DT) {
323 // Make sure the value is live in the predecessor.
324 if (Instruction *Inst = dyn_cast_or_null<Instruction>(Addr))
325 if (!DT->dominates(Inst->getParent(), PredBB))
326 Addr = 0;
327 }
328
Chris Lattner9a864122009-12-07 18:36:53 +0000329 return Addr == 0;
330}
331
Chris Lattner9a864122009-12-07 18:36:53 +0000332/// PHITranslateWithInsertion - PHI translate this value into the specified
333/// predecessor block, inserting a computation of the value if it is
334/// unavailable.
335///
336/// All newly created instructions are added to the NewInsts list. This
337/// returns null on failure.
338///
339Value *PHITransAddr::
340PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB,
341 const DominatorTree &DT,
342 SmallVectorImpl<Instruction*> &NewInsts) {
343 unsigned NISize = NewInsts.size();
344
345 // Attempt to PHI translate with insertion.
346 Addr = InsertPHITranslatedSubExpr(Addr, CurBB, PredBB, DT, NewInsts);
347
348 // If successful, return the new value.
349 if (Addr) return Addr;
350
351 // If not, destroy any intermediate instructions inserted.
352 while (NewInsts.size() != NISize)
353 NewInsts.pop_back_val()->eraseFromParent();
354 return 0;
355}
356
357
Chris Lattner210e45a2009-12-04 02:10:16 +0000358/// InsertPHITranslatedPointer - Insert a computation of the PHI translated
359/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
360/// block. All newly created instructions are added to the NewInsts list.
361/// This returns null on failure.
362///
363Value *PHITransAddr::
Chris Lattner9a864122009-12-07 18:36:53 +0000364InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
365 BasicBlock *PredBB, const DominatorTree &DT,
366 SmallVectorImpl<Instruction*> &NewInsts) {
Chris Lattner210e45a2009-12-04 02:10:16 +0000367 // See if we have a version of this value already available and dominating
Chris Lattner9a864122009-12-07 18:36:53 +0000368 // PredBB. If so, there is no need to insert a new instance of it.
Daniel Dunbar6d8f2ca2010-02-24 08:48:04 +0000369 PHITransAddr Tmp(InVal, TD);
370 if (!Tmp.PHITranslateValue(CurBB, PredBB, &DT))
371 return Tmp.getAddr();
Chris Lattner210e45a2009-12-04 02:10:16 +0000372
Chris Lattner9a864122009-12-07 18:36:53 +0000373 // If we don't have an available version of this value, it must be an
374 // instruction.
375 Instruction *Inst = cast<Instruction>(InVal);
376
Dan Gohmance562622010-11-18 17:05:13 +0000377 // Handle cast of PHI translatable value.
378 if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
379 if (!Cast->isSafeToSpeculativelyExecute()) return 0;
380 Value *OpVal = InsertPHITranslatedSubExpr(Cast->getOperand(0),
Chris Lattner9a864122009-12-07 18:36:53 +0000381 CurBB, PredBB, DT, NewInsts);
382 if (OpVal == 0) return 0;
383
Dan Gohmance562622010-11-18 17:05:13 +0000384 // Otherwise insert a cast at the end of PredBB.
385 CastInst *New = CastInst::Create(Cast->getOpcode(),
386 OpVal, InVal->getType(),
387 InVal->getName()+".phi.trans.insert",
388 PredBB->getTerminator());
Chris Lattner9a864122009-12-07 18:36:53 +0000389 NewInsts.push_back(New);
390 return New;
391 }
392
393 // Handle getelementptr with at least one PHI operand.
394 if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
395 SmallVector<Value*, 8> GEPOps;
396 BasicBlock *CurBB = GEP->getParent();
397 for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
398 Value *OpVal = InsertPHITranslatedSubExpr(GEP->getOperand(i),
399 CurBB, PredBB, DT, NewInsts);
400 if (OpVal == 0) return 0;
401 GEPOps.push_back(OpVal);
402 }
403
404 GetElementPtrInst *Result =
405 GetElementPtrInst::Create(GEPOps[0], GEPOps.begin()+1, GEPOps.end(),
406 InVal->getName()+".phi.trans.insert",
407 PredBB->getTerminator());
408 Result->setIsInBounds(GEP->isInBounds());
409 NewInsts.push_back(Result);
410 return Result;
411 }
412
413#if 0
414 // FIXME: This code works, but it is unclear that we actually want to insert
415 // a big chain of computation in order to make a value available in a block.
416 // This needs to be evaluated carefully to consider its cost trade offs.
417
418 // Handle add with a constant RHS.
419 if (Inst->getOpcode() == Instruction::Add &&
420 isa<ConstantInt>(Inst->getOperand(1))) {
421 // PHI translate the LHS.
422 Value *OpVal = InsertPHITranslatedSubExpr(Inst->getOperand(0),
423 CurBB, PredBB, DT, NewInsts);
424 if (OpVal == 0) return 0;
425
426 BinaryOperator *Res = BinaryOperator::CreateAdd(OpVal, Inst->getOperand(1),
427 InVal->getName()+".phi.trans.insert",
428 PredBB->getTerminator());
429 Res->setHasNoSignedWrap(cast<BinaryOperator>(Inst)->hasNoSignedWrap());
430 Res->setHasNoUnsignedWrap(cast<BinaryOperator>(Inst)->hasNoUnsignedWrap());
431 NewInsts.push_back(Res);
432 return Res;
433 }
434#endif
435
Chris Lattner210e45a2009-12-04 02:10:16 +0000436 return 0;
437}