[PATCH] D20663: [ConstantFold] Fix incorrect index rewrites for GEPs

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 00:14:37 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL270826: [ConstantFold] Fix incorrect index rewrites for GEPs (authored by anemet).

Changed prior to commit:
  http://reviews.llvm.org/D20663?vs=58568&id=58575#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20663

Files:
  llvm/trunk/lib/IR/ConstantFold.cpp
  llvm/trunk/test/Transforms/InstCombine/getelementptr-folding.ll

Index: llvm/trunk/test/Transforms/InstCombine/getelementptr-folding.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/getelementptr-folding.ll
+++ llvm/trunk/test/Transforms/InstCombine/getelementptr-folding.ll
@@ -0,0 +1,13 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+%struct.matrix_float3x3 = type { [3 x <3 x float>] }
+
+; We used to fold this by rewriting the indices to 0, 0, 2, 0.  This is
+; invalid because there is a 4-byte padding after each <3 x float> field.
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+ at matrix_identity_float3x3 = external global %struct.matrix_float3x3, align 16
+ at bbb = global float* getelementptr inbounds (%struct.matrix_float3x3, %struct.matrix_float3x3* @matrix_identity_float3x3, i64 0, i32 0, i64 1, i64 3)
+; CHECK: @bbb = global float* getelementptr inbounds (%struct.matrix_float3x3, %struct.matrix_float3x3* @matrix_identity_float3x3, i64 0, i32 0, i64 1, i64 3)
Index: llvm/trunk/lib/IR/ConstantFold.cpp
===================================================================
--- llvm/trunk/lib/IR/ConstantFold.cpp
+++ llvm/trunk/lib/IR/ConstantFold.cpp
@@ -2193,7 +2193,7 @@
   for (unsigned i = 1, e = Idxs.size(); i != e;
        Prev = Ty, Ty = cast<CompositeType>(Ty)->getTypeAtIndex(Idxs[i]), ++i) {
     if (ConstantInt *CI = dyn_cast<ConstantInt>(Idxs[i])) {
-      if (isa<ArrayType>(Ty) || isa<VectorType>(Ty))
+      if (isa<ArrayType>(Ty))
         if (CI->getSExtValue() > 0 &&
             !isIndexInRangeOfSequentialType(cast<SequentialType>(Ty), CI)) {
           if (isa<SequentialType>(Prev)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20663.58575.patch
Type: text/x-patch
Size: 1694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160526/915b3b69/attachment.bin>


More information about the llvm-commits mailing list