@@ -171,7 +171,10 @@ static bool processLoop(Loop &L, OptimizationRemarkEmitter &ORE, ScalarEvolution
171171 BasicBlock *Lh = L.getHeader ();
172172 LLVM_DEBUG (dbgs () << " LSL: loop header: " << *Lh << " \n " );
173173
174- for (unsigned i = 0 , ie = LoopID->getNumOperands (); i < ie; ++i) {
174+ SmallVector<Metadata*, 4 > MDs (1 );
175+ // First Operand is self-reference
176+ // Drop `julia.` prefixes
177+ for (unsigned i = 1 , ie = LoopID->getNumOperands (); i < ie; ++i) {
175178 Metadata *Op = LoopID->getOperand (i);
176179 const MDString *S = dyn_cast<MDString>(Op);
177180 if (S) {
@@ -184,13 +187,18 @@ static bool processLoop(Loop &L, OptimizationRemarkEmitter &ORE, ScalarEvolution
184187 continue ;
185188 }
186189 }
190+ MDs.push_back (Op);
187191 }
188192
189193 LLVM_DEBUG (dbgs () << " LSL: simd: " << simd << " ivdep: " << ivdep << " \n " );
190194 if (!simd && !ivdep)
191195 return false ;
192196
193- // TODO: Can we drop `julia.simdloop` and `julia.ivdep`?
197+ LLVMContext &Context = L.getHeader ()->getContext ();
198+ MDNode *NewLoopID = MDNode::get (Context, MDs);
199+ // Set operand 0 to refer to the loop id itself
200+ NewLoopID->replaceOperandWith (0 , NewLoopID);
201+ L.setLoopID (NewLoopID);
194202
195203 REMARK ([&]() {
196204 return OptimizationRemarkAnalysis (DEBUG_TYPE, " Loop SIMD Flags" , L.getStartLoc (), L.getHeader ())
0 commit comments