[llvm-commits] [llvm] r154141 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Jim Grosbach grosbach at apple.com
Thu Apr 5 16:51:24 PDT 2012


Author: grosbach
Date: Thu Apr  5 18:51:24 2012
New Revision: 154141

URL: http://llvm.org/viewvc/llvm-project?rev=154141&view=rev
Log:
ARM: Don't form a t2LDRi8 or t2STRi8 with an offset of zero.

The load/store optimizer splits LDRD/STRD into two instructions when the
register pairing doesn't work out. For negative offsets in Thumb2, it uses
t2STRi8 to do that. That's fine, except for the case when the offset is in
the range [-4,-1]. In that case, we'll also form a second t2STRi8 with
the original offset plus 4, resulting in a t2STRi8 with a non-negative
offset, which ends up as if it were an STRT, which is completely bogus.
Similarly for loads.

No testcase, unfortunately, as any I've been able to construct is both large
and extremely fragile.

rdar://11193937

Modified:
    llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=154141&r1=154140&r2=154141&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Thu Apr  5 18:51:24 2012
@@ -1172,6 +1172,10 @@
                       BaseReg, false, BaseUndef, false, OffUndef,
                       Pred, PredReg, TII, isT2);
         NewBBI = llvm::prior(MBBI);
+        // Be extra careful for thumb2. t2LDRi8 can't reference a zero offset,
+        // so adjust and use t2LDRi12 here for that.
+        if (isT2 && NewOpc == ARM::t2LDRi8 && OffImm+4 >= 0)
+          NewOpc = ARM::t2LDRi12;
         InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc,
                       EvenReg, EvenDeadKill, false,
                       BaseReg, BaseKill, BaseUndef, OffKill, OffUndef,
@@ -1193,6 +1197,10 @@
                       BaseReg, false, BaseUndef, false, OffUndef,
                       Pred, PredReg, TII, isT2);
         NewBBI = llvm::prior(MBBI);
+        // Be extra careful for thumb2. t2STRi8 can't reference a zero offset,
+        // so adjust and use t2STRi12 here for that.
+        if (isT2 && NewOpc == ARM::t2STRi8 && OffImm+4 >= 0)
+          NewOpc = ARM::t2STRi12;
         InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc,
                       OddReg, OddDeadKill, OddUndef,
                       BaseReg, BaseKill, BaseUndef, OffKill, OffUndef,





More information about the llvm-commits mailing list