[PATCH] D18448: Fix Sub-register Rewriting in Aggressive Anti-Dependence Breaker

Thomas Jablin via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 17:13:09 PDT 2016


tjablin updated this revision to Diff 52312.
tjablin added a comment.

Add comments per Hal's suggestion.


http://reviews.llvm.org/D18448

Files:
  lib/CodeGen/AggressiveAntiDepBreaker.cpp
  test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll

Index: test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll
===================================================================
--- test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll
+++ test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll
@@ -0,0 +1,24 @@
+; RUN: llc %s -mtriple=powerpc64-unknown-linux-gnu -O2 -o - -optimize-regalloc=false -regalloc=fast | FileCheck %s
+
+declare void @func(i8*, i64, i64)
+
+define void @test(i8* %context, i32** %elementArrayPtr, i32 %value) {
+entry:
+  %cmp = icmp eq i32 %value, 0
+  br i1 %cmp, label %lreturn, label %lnext
+
+lnext:
+  %elementArray = load i32*, i32** %elementArrayPtr, align 8
+; CHECK: lwz [[LDREG:[0-9]+]], 124(1)                   # 4-byte Folded Reload
+; CHECK: # implicit-def: %X[[TEMPREG:[0-9]+]]
+  %element = load i32, i32* %elementArray, align 4
+; CHECK: mr [[TEMPREG]], [[LDREG]]
+; CHECK: clrldi   4, [[TEMPREG]], 32
+  %element.ext = zext i32 %element to i64
+  %value.ext = zext i32 %value to i64
+  call void @func(i8* %context, i64 %value.ext, i64 %element.ext)
+  br label %lreturn
+
+lreturn:
+  ret void
+}
Index: lib/CodeGen/AggressiveAntiDepBreaker.cpp
===================================================================
--- lib/CodeGen/AggressiveAntiDepBreaker.cpp
+++ lib/CodeGen/AggressiveAntiDepBreaker.cpp
@@ -312,19 +312,22 @@
     DEBUG(if (header) {
         dbgs() << header << TRI->getName(Reg); header = nullptr; });
     DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << tag);
-  }
-  // Repeat for subregisters.
-  for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
-    unsigned SubregReg = *SubRegs;
-    if (!State->IsLive(SubregReg)) {
-      KillIndices[SubregReg] = KillIdx;
-      DefIndices[SubregReg] = ~0u;
-      RegRefs.erase(SubregReg);
-      State->LeaveGroup(SubregReg);
-      DEBUG(if (header) {
-          dbgs() << header << TRI->getName(Reg); header = nullptr; });
-      DEBUG(dbgs() << " " << TRI->getName(SubregReg) << "->g" <<
-            State->GetGroup(SubregReg) << tag);
+    // Repeat for subregisters. Note that we only do this if the superregister
+    // was not live because otherwise, regardless whether we have an explicit
+    // use of the subregister, the subregister's contents are needed for the
+    // uses of the superregister.
+    for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
+      unsigned SubregReg = *SubRegs;
+      if (!State->IsLive(SubregReg)) {
+        KillIndices[SubregReg] = KillIdx;
+        DefIndices[SubregReg] = ~0u;
+        RegRefs.erase(SubregReg);
+        State->LeaveGroup(SubregReg);
+        DEBUG(if (header) {
+            dbgs() << header << TRI->getName(Reg); header = nullptr; });
+        DEBUG(dbgs() << " " << TRI->getName(SubregReg) << "->g" <<
+              State->GetGroup(SubregReg) << tag);
+      }
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18448.52312.patch
Type: text/x-patch
Size: 2867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160401/0bf847b1/attachment.bin>


More information about the llvm-commits mailing list