[llvm-commits] [llvm] r139006 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/LoopUnroll/pr10813.ll
Jakub Staszak
jstaszak at apple.com
Fri Sep 2 08:43:43 PDT 2011
Author: kuba
Date: Fri Sep 2 10:43:43 2011
New Revision: 139006
URL: http://llvm.org/viewvc/llvm-project?rev=139006&view=rev
Log:
ConstantVector returns arbitrary value for the wrong index.
This fixes PR10813.
Added:
llvm/trunk/test/Transforms/LoopUnroll/pr10813.ll
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=139006&r1=139005&r2=139006&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Fri Sep 2 10:43:43 2011
@@ -761,6 +761,10 @@
if (ConstantVector *CVal = dyn_cast<ConstantVector>(Val)) {
if (ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx)) {
+ uint64_t Index = CIdx->getZExtValue();
+ if (Index >= CVal->getNumOperands())
+ // ee({w,x,y,z}, wrong_value) -> w (an arbitrary value).
+ return CVal->getOperand(0);
return CVal->getOperand(CIdx->getZExtValue());
} else if (isa<UndefValue>(Idx)) {
// ee({w,x,y,z}, undef) -> w (an arbitrary value).
Added: llvm/trunk/test/Transforms/LoopUnroll/pr10813.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/pr10813.ll?rev=139006&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/pr10813.ll (added)
+++ llvm/trunk/test/Transforms/LoopUnroll/pr10813.ll Fri Sep 2 10:43:43 2011
@@ -0,0 +1,29 @@
+; RUN: opt < %s -loop-unroll -disable-output
+
+define void @"f_fu___REFUf[]REFUf[]Uf"() nounwind {
+allocas:
+ br i1 undef, label %cif_mask_all, label %cif_mixed_test_all
+
+cif_mask_all: ; preds = %allocas
+ unreachable
+
+cif_mixed_test_all: ; preds = %allocas
+ br label %pl_loop.i964
+
+pl_loop.i964: ; preds = %pl_loopend.i973, %cif_mixed_test_all
+ %0 = phi i32 [ %pl_nextlane.i971, %pl_loopend.i973 ], [ 0, %cif_mixed_test_all ]
+ br i1 undef, label %pl_dolane.i970, label %pl_loopend.i973
+
+pl_dolane.i970: ; preds = %pl_loop.i964
+ %storeval.i.i969 = extractelement <4 x i8> <i8 0, i8 1, i8 2, i8 3>, i32 %0
+ store i8 %storeval.i.i969, i8* undef, align 1
+ br label %pl_loopend.i973
+
+pl_loopend.i973: ; preds = %pl_dolane.i970, %pl_loop.i964
+ %pl_nextlane.i971 = add i32 %0, 1
+ %exitcond5 = icmp ne i32 %pl_nextlane.i971, 5
+ br i1 %exitcond5, label %pl_loop.i964, label %__scatter_base_offsets_i8.exit974
+
+__scatter_base_offsets_i8.exit974: ; preds = %pl_loopend.i973
+ unreachable
+}
More information about the llvm-commits
mailing list