@@ -166,11 +166,14 @@ struct ForwardingAction {
166
166
}
167
167
168
168
// / Named ctor: The value can just be used without any preparation.
169
- static ForwardingAction triviallyForwardable (bool IsProfitable) {
169
+ static ForwardingAction triviallyForwardable (bool IsProfitable, Value *Val ) {
170
170
ForwardingAction Result;
171
171
Result.Decision =
172
172
IsProfitable ? FD_CanForwardProfitably : FD_CanForwardLeaf;
173
- Result.Execute = []() { return true ; };
173
+ Result.Execute = [=]() {
174
+ LLVM_DEBUG (dbgs () << " trivially forwarded: " << *Val << " \n " );
175
+ return true ;
176
+ };
174
177
return Result;
175
178
}
176
179
@@ -637,6 +640,8 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
637
640
Access = TargetStmt->ensureValueRead (Inst);
638
641
Access->setNewAccessRelation (SameVal);
639
642
643
+ LLVM_DEBUG (dbgs () << " forwarded known content of " << *Inst
644
+ << " which is " << SameVal << " \n " );
640
645
TotalReloads++;
641
646
NumReloads++;
642
647
return false ;
@@ -703,6 +708,9 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
703
708
// operands. This ensures that its operands are inserted before the
704
709
// instruction using them.
705
710
TargetStmt->prependInstruction (UseInst);
711
+
712
+ LLVM_DEBUG (dbgs () << " forwarded speculable instruction: " << *UseInst
713
+ << " \n " );
706
714
NumInstructionsCopied++;
707
715
TotalInstructionsCopied++;
708
716
return true ;
@@ -736,7 +744,7 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
736
744
case VirtualUse::Block:
737
745
case VirtualUse::Hoisted:
738
746
// These can be used anywhere without special considerations.
739
- return ForwardingAction::triviallyForwardable (false );
747
+ return ForwardingAction::triviallyForwardable (false , UseVal );
740
748
741
749
case VirtualUse::Synthesizable: {
742
750
// Check if the value is synthesizable at the new location as well. This
@@ -752,7 +760,7 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
752
760
VirtualUse TargetUse = VirtualUse::create (
753
761
S, TargetStmt, TargetStmt->getSurroundingLoop (), UseVal, true );
754
762
if (TargetUse.getKind () == VirtualUse::Synthesizable)
755
- return ForwardingAction::triviallyForwardable (false );
763
+ return ForwardingAction::triviallyForwardable (false , UseVal );
756
764
757
765
LLVM_DEBUG (
758
766
dbgs () << " Synthesizable would not be synthesizable anymore: "
@@ -761,11 +769,15 @@ class ForwardOpTreeImpl : ZoneAlgorithm {
761
769
}
762
770
763
771
case VirtualUse::ReadOnly: {
772
+ if (!ModelReadOnlyScalars)
773
+ return ForwardingAction::triviallyForwardable (false , UseVal);
774
+
764
775
// If we model read-only scalars, we need to create a MemoryAccess for it.
765
776
auto ExecAction = [this , TargetStmt, UseVal]() {
766
- if (ModelReadOnlyScalars)
767
- TargetStmt->ensureValueRead (UseVal);
777
+ TargetStmt->ensureValueRead (UseVal);
768
778
779
+ LLVM_DEBUG (dbgs () << " forwarded read-only value " << *UseVal
780
+ << " \n " );
769
781
NumReadOnlyCopied++;
770
782
TotalReadOnlyCopied++;
771
783
0 commit comments