[llvm-commits] [polly] r153952 - in /polly/trunk: lib/CodeGen/CodeGeneration.cpp test/CodeGen/20120403-RHS-type-mismatch.ll test/CodeGen/MemAccess/codegen_simple_md.ll

Tobias Grosser grosser at fim.uni-passau.de
Tue Apr 3 05:24:32 PDT 2012


Author: grosser
Date: Tue Apr  3 07:24:32 2012
New Revision: 153952

URL: http://llvm.org/viewvc/llvm-project?rev=153952&view=rev
Log:
CodeGen: Recreate old ivs with the original type

To avoid overflows we still use a larger type (i64) while calculating the value
of the old ivs.  However, we truncate the result to the type of the old iv when
providing it to the new code.

A corresponding test case is added to the polly test suite. Also, a failing test
case is fixed.

This fixes PR12311.

Contributed by: Tsingray Liu  <tsingrayliu at gmail.com>

Added:
    polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll   (with props)
Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/test/CodeGen/MemAccess/codegen_simple_md.ll

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=153952&r1=153951&r2=153952&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Tue Apr  3 07:24:32 2012
@@ -1088,8 +1088,9 @@
 
   assert(!A->LHS && "Statement assignments do not have left hand side");
 
-  RHS = ExpGen.codegen(A->RHS, getIntPtrTy());
   PN = Stmt->getInductionVariableForDimension(Dim);
+  RHS = ExpGen.codegen(A->RHS, Builder.getInt64Ty());
+  RHS = Builder.CreateTruncOrBitCast(RHS, PN->getType());
 
   if (VectorVMap)
     (*VectorVMap)[VectorDim][PN] = RHS;

Added: polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll?rev=153952&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll (added)
+++ polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll Tue Apr  3 07:24:32 2012
@@ -0,0 +1,27 @@
+; RUN: opt %loadPolly -polly-codegen %s
+
+; We just check that this compilation does not crash.
+
+target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32f64:64:64-f32:32:32-a0:0-n32"
+target triple = "hexagon-unknown-linux-gnu"
+
+define void @init() nounwind {
+entry:
+  %hi.129.reg2mem = alloca i64
+  br label %for.body
+
+for.cond5.preheader:                              ; preds = %for.body
+  br label %for.body7
+
+for.body:                                         ; preds = %for.body, %entry
+  br i1 undef, label %for.body, label %for.cond5.preheader
+
+for.body7:                                        ; preds = %for.body7, %for.cond5.preheader
+  %i.128 = phi i64 [ 0, %for.cond5.preheader ], [ %inc17, %for.body7 ]
+  %inc17 = add nsw i64 %i.128, 1
+  store i64 undef, i64* %hi.129.reg2mem
+  br i1 false, label %for.body7, label %for.end18
+
+for.end18:                                        ; preds = %for.body7
+  unreachable
+}

Propchange: polly/trunk/test/CodeGen/20120403-RHS-type-mismatch.ll
------------------------------------------------------------------------------
    svn:executable = *

Modified: polly/trunk/test/CodeGen/MemAccess/codegen_simple_md.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/MemAccess/codegen_simple_md.ll?rev=153952&r1=153951&r2=153952&view=diff
==============================================================================
--- polly/trunk/test/CodeGen/MemAccess/codegen_simple_md.ll (original)
+++ polly/trunk/test/CodeGen/MemAccess/codegen_simple_md.ll Tue Apr  3 07:24:32 2012
@@ -45,20 +45,20 @@
   ret i32 0
 }
 
-; WITHCONST:  %4 = sext i32 %2 to i64
-; WITHCONST:  %p_mul_coeff = mul i64 16, %4
+; WITHCONST:  [[REG1:%[0-9]+]] = sext i32 %{{[0-9]+}} to i64
+; WITHCONST:  %p_mul_coeff = mul i64 16, [[REG1]]
 ; WITHCONST:  %p_sum_coeff = add i64 5, %p_mul_coeff
-; WITHCONST:  %5 = sext i32 %3 to i64
-; WITHCONST:  %p_mul_coeff6 = mul i64 2, %5
+; WITHCONST:  [[REG2:%[0-9]+]] = sext i32 %{{[0-9]+}} to i64
+; WITHCONST:  %p_mul_coeff6 = mul i64 2, [[REG2]]
 ; WITHCONST:  %p_sum_coeff7 = add i64 %p_sum_coeff, %p_mul_coeff6
 ; WITHCONST:  %p_newarrayidx_ = getelementptr [1040 x i32]* @A, i64 0, i64 %p_sum_coeff7
 ; WITHCONST:  store i32 100, i32* %p_newarrayidx_
 
-; WITHOUTCONST:  %4 = sext i32 %2 to i64
-; WITHOUTCONST:  %p_mul_coeff = mul i64 16, %4
+; WITHOUTCONST:  [[REG1:%[0-9]+]] = sext i32 %{{[0-9]+}} to i64
+; WITHOUTCONST:  %p_mul_coeff = mul i64 16, [[REG1]]
 ; WITHOUTCONST:  %p_sum_coeff = add i64 0, %p_mul_coeff
-; WITHOUTCONST:  %5 = sext i32 %3 to i64
-; WITHOUTCONST:  %p_mul_coeff6 = mul i64 2, %5
+; WITHOUTCONST:  [[REG2:%[0-9]+]] = sext i32 %{{[0-9]+}} to i64
+; WITHOUTCONST:  %p_mul_coeff6 = mul i64 2, [[REG2]]
 ; WITHOUTCONST:  %p_sum_coeff7 = add i64 %p_sum_coeff, %p_mul_coeff6
 ; WITHOUTCONST:  %p_newarrayidx_ = getelementptr [1040 x i32]* @A, i64 0, i64 %p_sum_coeff7
 ; WITHOUTCONST:  store i32 100, i32* %p_newarrayidx_





More information about the llvm-commits mailing list