[llvm] r306690 - [Hexagon] Keep all phi nodes when building DFG in addr-mode-opt
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 08:55:59 PDT 2017
Author: kparzysz
Date: Thu Jun 29 08:55:59 2017
New Revision: 306690
URL: http://llvm.org/viewvc/llvm-project?rev=306690&view=rev
Log:
[Hexagon] Keep all phi nodes when building DFG in addr-mode-opt
The dead phis are needed for finding correct would-be reaching defs
in register propagation.
Added:
llvm/trunk/test/CodeGen/Hexagon/addrmode-keepdeadphis.mir
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonOptAddrMode.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonOptAddrMode.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonOptAddrMode.cpp?rev=306690&r1=306689&r2=306690&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonOptAddrMode.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonOptAddrMode.cpp Thu Jun 29 08:55:59 2017
@@ -535,9 +535,9 @@ bool HexagonOptAddrMode::processBlock(No
!MI->getOperand(1).isGlobal())
continue;
- DEBUG(dbgs() << "[Analyzing A2_tfrsi]: " << *MI << "\n");
- DEBUG(dbgs() << "\t[InstrNode]: " << Print<NodeAddr<InstrNode *>>(IA, *DFG)
- << "\n");
+ DEBUG(dbgs() << "[Analyzing " << HII->getName(MI->getOpcode()) << "]: "
+ << *MI << "\n\t[InstrNode]: "
+ << Print<NodeAddr<InstrNode *>>(IA, *DFG) << '\n');
NodeList UNodeList;
getAllRealUses(SA, UNodeList);
@@ -605,7 +605,9 @@ bool HexagonOptAddrMode::runOnMachineFun
const TargetOperandInfo TOI(*HII);
DataFlowGraph G(MF, *HII, TRI, *MDT, MDF, TOI);
- G.build();
+ // Need to keep dead phis because we can propagate uses of registers into
+ // nodes dominated by those would-be phis.
+ G.build(BuildOptions::KeepDeadPhis);
DFG = &G;
Liveness L(MRI, *DFG);
Added: llvm/trunk/test/CodeGen/Hexagon/addrmode-keepdeadphis.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/addrmode-keepdeadphis.mir?rev=306690&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/addrmode-keepdeadphis.mir (added)
+++ llvm/trunk/test/CodeGen/Hexagon/addrmode-keepdeadphis.mir Thu Jun 29 08:55:59 2017
@@ -0,0 +1,30 @@
+# RUN: llc -march=hexagon -run-pass amode-opt %s -o - | FileCheck %s
+
+# Check that the addasl is not propagated into the addressing mode.
+# CHECK-NOT: L4_loadri_ur
+
+--- |
+ @g = global i32 zeroinitializer
+ define void @fred() { ret void }
+...
+
+---
+name: fred
+tracksRegLiveness: true
+
+body: |
+ bb.0:
+ liveins: %p0
+ %r0 = A2_tfrsi @g
+ %r1 = A2_tfrsi 1
+ %r2 = S2_addasl_rrri %r0, %r1, 1
+ J2_jumpt %p0, %bb.2, implicit-def %pc
+
+ bb.1:
+ liveins: %r0, %r2
+ %r1 = A2_tfrsi 2
+
+ bb.2:
+ liveins: %r0, %r2
+ %r3 = L2_loadri_io %r2, 0
+...
More information about the llvm-commits
mailing list