llvm.org GIT mirror llvm / 1df0680
Merging r182485: ------------------------------------------------------------------------ r182485 | arnolds | 2013-05-22 09:54:56 -0700 (Wed, 22 May 2013) | 7 lines LoopVectorize: Make Value pointers that could be RAUW'ed a VH The Value pointers we store in the induction variable list can be RAUW'ed by a call to SCEVExpander::expandCodeFor, use a TrackingVH instead. Do the same thing in some other places where we store pointers that could potentially be RAUW'ed. Fixes PR16073. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@182492 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
2 changed file(s) with 54 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7979 #include "llvm/Support/Debug.h"
8080 #include "llvm/Support/PatternMatch.h"
8181 #include "llvm/Support/raw_ostream.h"
82 #include "llvm/Support/ValueHandle.h"
8283 #include "llvm/Target/TargetLibraryInfo.h"
8384 #include "llvm/Transforms/Scalar.h"
8485 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
381382
382383 // The starting value of the reduction.
383384 // It does not have to be zero!
384 Value *StartValue;
385 TrackingVH StartValue;
385386 // The instruction who's value is used outside the loop.
386387 Instruction *LoopExitInstr;
387388 // The kind of the reduction.
426427 /// This flag indicates if we need to add the runtime check.
427428 bool Need;
428429 /// Holds the pointers that we need to check.
429 SmallVector<Value*, 2> Pointers;
430 SmallVector<TrackingVH, 2> Pointers;
430431 /// Holds the pointer value at the beginning of the loop.
431432 SmallVector Starts;
432433 /// Holds the pointer value at the end of the loop.
440441 InductionInfo(Value *Start, InductionKind K) : StartValue(Start), IK(K) {}
441442 InductionInfo() : StartValue(0), IK(IK_NoInduction) {}
442443 /// Start value.
443 Value *StartValue;
444 TrackingVH StartValue;
444445 /// Induction kind.
445446 InductionKind IK;
446447 };
0 ; RUN: opt -S -loop-vectorize -force-vector-width=4 -force-vector-unroll=1 -dce -instcombine < %s | FileCheck %s
1
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3
4 ; PR16073
5
6 ; Because we were caching value pointers accross a function call that could RAUW
7 ; we would generate an undefined value store below:
8 ; SCEVExpander::expandCodeFor would change a value (the start value of an
9 ; induction) that we cached in the induction variable list.
10
11 ; CHECK: test_vh
12 ; CHECK-NOT: store <4 x i8> undef
13
14 define void @test_vh(i32* %ptr265, i32* %ptr266, i32 %sub267) {
15 entry:
16 br label %loop
17
18 loop:
19 %inc = phi i32 [ %sub267, %entry ], [ %add, %loop]
20 %ext.inc = sext i32 %inc to i64
21 %add.ptr265 = getelementptr inbounds i32* %ptr265, i64 %ext.inc
22 %add.ptr266 = getelementptr inbounds i32* %ptr266, i64 %ext.inc
23 %add = add i32 %inc, 9
24 %cmp = icmp slt i32 %add, 140
25 br i1 %cmp, label %block1, label %loop
26
27 block1:
28 %sub267.lcssa = phi i32 [ %add, %loop ]
29 %add.ptr266.lcssa = phi i32* [ %add.ptr266, %loop ]
30 %add.ptr265.lcssa = phi i32* [ %add.ptr265, %loop ]
31 %tmp29 = bitcast i32* %add.ptr265.lcssa to i8*
32 %tmp30 = bitcast i32* %add.ptr266.lcssa to i8*
33 br label %do.body272
34
35 do.body272:
36 %row_width.5 = phi i32 [ %sub267.lcssa, %block1 ], [ %dec, %do.body272 ]
37 %sp.4 = phi i8* [ %tmp30, %block1 ], [ %incdec.ptr273, %do.body272 ]
38 %dp.addr.4 = phi i8* [ %tmp29, %block1 ], [ %incdec.ptr274, %do.body272 ]
39 %incdec.ptr273 = getelementptr inbounds i8* %sp.4, i64 1
40 %tmp31 = load i8* %sp.4, align 1
41 %incdec.ptr274 = getelementptr inbounds i8* %dp.addr.4, i64 1
42 store i8 %tmp31, i8* %dp.addr.4, align 1
43 %dec = add i32 %row_width.5, -1
44 %cmp276 = icmp eq i32 %dec, 0
45 br i1 %cmp276, label %loop.exit, label %do.body272
46
47 loop.exit:
48 ret void
49 }