@@ -160,7 +160,6 @@ class GenXLowering : public FunctionPass {
160
160
virtual StringRef getPassName () const { return " GenX lowering" ; }
161
161
void getAnalysisUsage (AnalysisUsage &AU) const ;
162
162
bool runOnFunction (Function &F);
163
- static bool splitStructPhi (PHINode *Phi);
164
163
165
164
private:
166
165
bool splitGatherScatter (CallInst *CI, unsigned IID);
@@ -2196,81 +2195,6 @@ Instruction *llvm::genx::convertShlShr(Instruction *Inst) {
2196
2195
return Ext;
2197
2196
}
2198
2197
2199
- /* **********************************************************************
2200
- * splitStructPhis : find struct phi nodes and split them
2201
- *
2202
- * Return: whether code modified
2203
- *
2204
- * Each struct phi node is split into a separate phi node for each struct
2205
- * element. This is needed because the GenX backend's liveness and coalescing
2206
- * code cannot cope with a struct phi.
2207
- *
2208
- * This is run in two places: firstly in GenXLowering, so that pass can then
2209
- * simplify any InsertElement and ExtractElement instructions added by the
2210
- * struct phi splitting. But then it needs to be run again in GenXLiveness,
2211
- * because other passes can re-insert a struct phi. The case I saw in
2212
- * hevc_speed was something commoning up the struct return from two calls in an
2213
- * if..else..endif.
2214
- */
2215
- bool genx::splitStructPhis (Function *F) {
2216
- bool Modified = false ;
2217
- for (Function::iterator fi = F->begin (), fe = F->end (); fi != fe; ++fi) {
2218
- BasicBlock *BB = &*fi;
2219
- for (BasicBlock::iterator bi = BB->begin ();;) {
2220
- PHINode *Phi = dyn_cast<PHINode>(&*bi);
2221
- if (!Phi)
2222
- break ;
2223
- ++bi; // increment here as splitStructPhi removes old phi node
2224
- if (isa<StructType>(Phi->getType ()))
2225
- Modified |= GenXLowering::splitStructPhi (Phi);
2226
- }
2227
- }
2228
- return Modified;
2229
- }
2230
-
2231
- /* **********************************************************************
2232
- * splitStructPhi : split a phi node with struct type by splitting into
2233
- * struct elements
2234
- */
2235
- bool GenXLowering::splitStructPhi (PHINode *Phi) {
2236
- StructType *Ty = cast<StructType>(Phi->getType ());
2237
- // Find where we need to insert the combine instructions.
2238
- Instruction *CombineInsertBefore = Phi->getParent ()->getFirstNonPHI ();
2239
- // Now split the phi.
2240
- Value *Combined = UndefValue::get (Ty);
2241
- // For each struct element...
2242
- for (unsigned Idx = 0 , e = Ty->getNumElements (); Idx != e; ++Idx) {
2243
- Type *ElTy = Ty->getTypeAtIndex (Idx);
2244
- // Create the new phi node.
2245
- PHINode *NewPhi =
2246
- PHINode::Create (ElTy, Phi->getNumIncomingValues (),
2247
- Phi->getName () + " .element" + Twine (Idx), Phi);
2248
- NewPhi->setDebugLoc (Phi->getDebugLoc ());
2249
- // Combine the new phi.
2250
- Instruction *Combine = InsertValueInst::Create (
2251
- Combined, NewPhi, Idx, NewPhi->getName (), CombineInsertBefore);
2252
- Combine->setDebugLoc (Phi->getDebugLoc ());
2253
- Combined = Combine;
2254
- // For each incoming...
2255
- for (unsigned In = 0 , InEnd = Phi->getNumIncomingValues (); In != InEnd;
2256
- ++In) {
2257
- // Create an extractelement to get the individual element value.
2258
- // This needs to go before the terminator of the incoming block.
2259
- BasicBlock *IncomingBB = Phi->getIncomingBlock (In);
2260
- Value *Incoming = Phi->getIncomingValue (In);
2261
- Instruction *Extract = ExtractValueInst::Create (
2262
- Incoming, Idx, Phi->getName () + " .element" + Twine (Idx),
2263
- IncomingBB->getTerminator ());
2264
- Extract->setDebugLoc (Phi->getDebugLoc ());
2265
- // Add as an incoming of the new phi node.
2266
- NewPhi->addIncoming (Extract, IncomingBB);
2267
- }
2268
- }
2269
- Phi->replaceAllUsesWith (Combined);
2270
- Phi->eraseFromParent ();
2271
- return true ;
2272
- }
2273
-
2274
2198
/* **********************************************************************
2275
2199
* lowerExtractValue : remove extractvalue if possible
2276
2200
*
0 commit comments