[PATCH] Handle big index in getelementptr instruction for AArch64FastISel

Paweł Bylica chfast at gmail.com
Tue Apr 21 01:30:50 PDT 2015


Hi t.p.northover,

This is a fix http://reviews.llvm.org/D8219 applied also to AArch64FastISel, as it has a copy of the code fixed previously.

http://reviews.llvm.org/D9140

Files:
  lib/Target/AArch64/AArch64FastISel.cpp
  test/CodeGen/X86/getelementptr.ll

Index: lib/Target/AArch64/AArch64FastISel.cpp
===================================================================
--- lib/Target/AArch64/AArch64FastISel.cpp
+++ lib/Target/AArch64/AArch64FastISel.cpp
@@ -4832,7 +4832,7 @@
   for (auto OI = std::next(I->op_begin()), E = I->op_end(); OI != E; ++OI) {
     const Value *Idx = *OI;
     if (auto *StTy = dyn_cast<StructType>(Ty)) {
-      unsigned Field = cast<ConstantInt>(Idx)->getZExtValue();
+      uint64_t Field = cast<ConstantInt>(Idx)->getZExtValue();
       // N = N + Offset
       if (Field)
         TotalOffs += DL.getStructLayout(StTy)->getElementOffset(Field);
@@ -4844,8 +4844,8 @@
         if (CI->isZero())
           continue;
         // N = N + Offset
-        TotalOffs +=
-            DL.getTypeAllocSize(Ty) * cast<ConstantInt>(CI)->getSExtValue();
+        uint64_t IdxN = CI->getValue().sextOrTrunc(64).getSExtValue();
+        TotalOffs += DL.getTypeAllocSize(Ty) * IdxN;
         continue;
       }
       if (TotalOffs) {
Index: test/CodeGen/X86/getelementptr.ll
===================================================================
--- test/CodeGen/X86/getelementptr.ll
+++ test/CodeGen/X86/getelementptr.ll
@@ -1,7 +1,19 @@
 ; RUN: llc < %s -O0 -march=x86
 ; RUN: llc < %s -O0 -march=x86-64
+; RUN: llc < %s -O0 -march=arm64
+; RUN: llc < %s -O0 -march=mips64
+; RUN: llc < %s -O0 -march=ppc64
+; RUN: llc < %s -O0 -march=hexagon
+; RUN: llc < %s -O0 -march=sparc
+; RUN: llc < %s -O0 -march=systemz
 ; RUN: llc < %s -O2 -march=x86
 ; RUN: llc < %s -O2 -march=x86-64
+; RUN: llc < %s -O2 -march=arm64
+; RUN: llc < %s -O2 -march=mips64
+; RUN: llc < %s -O2 -march=ppc64
+; RUN: llc < %s -O2 -march=hexagon
+; RUN: llc < %s -O2 -march=sparc
+; RUN: llc < %s -O2 -march=systemz
 
 
 ; Test big index trunc to pointer size:

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9140.24100.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150421/7a9095b3/attachment.bin>


More information about the llvm-commits mailing list