@@ -2156,24 +2156,21 @@ bool llvm::promoteLoopAccessesToScalars(
2156
2156
2157
2157
// Set up the preheader to have a definition of the value. It is the live-out
2158
2158
// value from the preheader that uses in the loop will use.
2159
- LoadInst *PreheaderLoad = nullptr ;
2160
- if (FoundLoadToPromote) {
2161
- PreheaderLoad =
2162
- new LoadInst (AccessTy, SomePtr, SomePtr->getName () + " .promoted" ,
2163
- Preheader->getTerminator ());
2164
- if (SawUnorderedAtomic)
2165
- PreheaderLoad->setOrdering (AtomicOrdering::Unordered);
2166
- PreheaderLoad->setAlignment (Alignment);
2167
- PreheaderLoad->setDebugLoc (DebugLoc ());
2168
- if (AATags)
2169
- PreheaderLoad->setAAMetadata (AATags);
2170
-
2171
- MemoryAccess *PreheaderLoadMemoryAccess = MSSAU.createMemoryAccessInBB (
2172
- PreheaderLoad, nullptr , PreheaderLoad->getParent (), MemorySSA::End);
2173
- MemoryUse *NewMemUse = cast<MemoryUse>(PreheaderLoadMemoryAccess);
2174
- MSSAU.insertUse (NewMemUse, /* RenameUses=*/ true );
2175
- SSA.AddAvailableValue (Preheader, PreheaderLoad);
2176
- }
2159
+ LoadInst *PreheaderLoad = new LoadInst (
2160
+ AccessTy, SomePtr, SomePtr->getName () + " .promoted" ,
2161
+ Preheader->getTerminator ());
2162
+ if (SawUnorderedAtomic)
2163
+ PreheaderLoad->setOrdering (AtomicOrdering::Unordered);
2164
+ PreheaderLoad->setAlignment (Alignment);
2165
+ PreheaderLoad->setDebugLoc (DebugLoc ());
2166
+ if (AATags)
2167
+ PreheaderLoad->setAAMetadata (AATags);
2168
+ SSA.AddAvailableValue (Preheader, PreheaderLoad);
2169
+
2170
+ MemoryAccess *PreheaderLoadMemoryAccess = MSSAU.createMemoryAccessInBB (
2171
+ PreheaderLoad, nullptr , PreheaderLoad->getParent (), MemorySSA::End);
2172
+ MemoryUse *NewMemUse = cast<MemoryUse>(PreheaderLoadMemoryAccess);
2173
+ MSSAU.insertUse (NewMemUse, /* RenameUses=*/ true );
2177
2174
2178
2175
if (VerifyMemorySSA)
2179
2176
MSSAU.getMemorySSA ()->verifyMemorySSA ();
@@ -2184,7 +2181,7 @@ bool llvm::promoteLoopAccessesToScalars(
2184
2181
if (VerifyMemorySSA)
2185
2182
MSSAU.getMemorySSA ()->verifyMemorySSA ();
2186
2183
// If the SSAUpdater didn't use the load in the preheader, just zap it now.
2187
- if (PreheaderLoad && PreheaderLoad ->use_empty ())
2184
+ if (PreheaderLoad->use_empty ())
2188
2185
eraseInstruction (*PreheaderLoad, *SafetyInfo, MSSAU);
2189
2186
2190
2187
return true ;
0 commit comments