[llvm] r273562 - [LoopUnrollAnalyzer] Fix a bug in UnrolledInstAnalyzer::visitLoad.

Michael Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 07:31:31 PDT 2016


Author: mzolotukhin
Date: Thu Jun 23 09:31:31 2016
New Revision: 273562

URL: http://llvm.org/viewvc/llvm-project?rev=273562&view=rev
Log:
[LoopUnrollAnalyzer] Fix a bug in UnrolledInstAnalyzer::visitLoad.

When simplifying a load we need to make sure that the type of the
simplified value matches the type of the instruction we're processing.
In theory, we can handle casts here as we deal with constant data, but
since it's not implemented at the moment, we at least need to bail out.

This fixes PR28262.

Modified:
    llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp
    llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll

Modified: llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp?rev=273562&r1=273561&r2=273562&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopUnrollAnalyzer.cpp Thu Jun 23 09:31:31 2016
@@ -115,7 +115,7 @@ bool UnrolledInstAnalyzer::visitLoad(Loa
   // We might have a vector load from an array. FIXME: for now we just bail
   // out in this case, but we should be able to resolve and simplify such
   // loads.
-  if(!CDS->isElementTypeCompatible(I.getType()))
+  if(CDS->getElementType() != I.getType())
     return false;
 
   int ElemSize = CDS->getElementType()->getPrimitiveSizeInBits() / 8U;

Modified: llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll?rev=273562&r1=273561&r2=273562&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/full-unroll-crashers.ll Thu Jun 23 09:31:31 2016
@@ -204,3 +204,21 @@ for.body:
 for.end:
   ret void
 }
+
+define void @load_type_mismatch() {
+entry:
+  br label %for.body
+
+for.body:
+  %iv.0 = phi i64 [ 0, %entry ], [ %iv.1, %for.body ]
+  %arrayidx1 = getelementptr inbounds [10 x i32], [10 x i32]* @known_constant, i64 0, i64 %iv.0
+  %bc = bitcast i32* %arrayidx1 to i64*
+  %x1 = load i64, i64* %bc, align 4
+  %x2 = add i64 10, %x1
+  %iv.1 = add nuw nsw i64 %iv.0, 1
+  %exitcond = icmp eq i64 %iv.1, 10
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+  ret void
+}




More information about the llvm-commits mailing list