[llvm-commits] [llvm] r123060 - in /llvm/trunk: lib/Transforms/Scalar/LoopRotation.cpp test/Transforms/LoopRotate/phi-duplicate.ll
Duncan Sands
baldrick at free.fr
Sat Jan 8 05:36:39 PST 2011
Hi Chris,
> Have loop-rotate simplify instructions (yay instsimplify!) as it clones
> them into the loop preheader, eliminating silly instructions like
> "icmp i32 0, 100" in fixed tripcount loops. This also better exposes the
> bigger problem with loop rotate that I'd like to fix: once this has been
> folded, the duplicated conditional branch *often* turns into an uncond branch.
...
> @@ -205,9 +206,24 @@
> // Otherwise, create a duplicate of the instruction.
> Instruction *C = Inst->clone();
>
> - C->setName(Inst->getName());
> - C->insertBefore(LoopEntryBranch);
> - ValueMap[Inst] = C;
> + // Eagerly remap the operands of the instruction.
> + RemapInstruction(C, ValueMap,
> + RF_NoModuleLevelChanges|RF_IgnoreMissingEntries);
> +
> + // With the operands remapped, see if the instruction constant folds or is
> + // otherwise simplifyable. This commonly occurs because the entry from PHI
> + // nodes allows icmps and other instructions to fold.
> + if (Value *V = SimplifyInstruction(C)) {
> + // If so, then delete the temporary instruction and stick the folded value
> + // in the map.
> + delete C;
> + ValueMap[Inst] = V;
> + } else {
since instsimplify can look through phi nodes, it doesn't automatically preserve
LCSSA form. Passes like loop-rotate that need to preserve LCSSA form should do
something like this:
if (Value *V = SimplifyInstruction(C))
if (LI->replacementPreservesLCSSAForm(C, V)) {
.. use the simplification ...
}
Ciao, Duncan.
More information about the llvm-commits
mailing list