llvm.org GIT mirror llvm / c94b63b
Merging r276181: ------------------------------------------------------------------------ r276181 | majnemer | 2016-07-20 14:05:01 -0700 (Wed, 20 Jul 2016) | 6 lines [GVNHoist] Don't hoist PHI nodes We hoisted PHIs without respecting their special insertion point in the block, leading to verfier errors. This fixes PR28626. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@276418 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
2 changed file(s) with 50 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
588588
589589 bool makeOperandsAvailable(Instruction *Repl, BasicBlock *HoistPt) const {
590590 // Check whether the GEP of a ld/st can be synthesized at HoistPt.
591 Instruction *Gep = nullptr;
591 GetElementPtrInst *Gep = nullptr;
592592 Instruction *Val = nullptr;
593593 if (auto *Ld = dyn_cast(Repl))
594 Gep = dyn_cast<Instruction>(Ld->getPointerOperand());
594 Gep = dyn_cast<GetElementPtrInst>(Ld->getPointerOperand());
595595 if (auto *St = dyn_cast(Repl)) {
596 Gep = dyn_cast<Instruction>(St->getPointerOperand());
596 Gep = dyn_cast<GetElementPtrInst>(St->getPointerOperand());
597597 Val = dyn_cast(St->getValueOperand());
598598 }
599599
600 if (!Gep || !isa(Gep))
600 if (!Gep)
601 return false;
602
603 // PHIs may only be inserted at the start of a block.
604 if (Val && isa(Val))
601605 return false;
602606
603607 // Check whether we can compute the Gep at HoistPt.
0 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s
1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2 target triple = "x86_64-unknown-linux-gnu"
3
4 define void @test1(i1 %a, i1** %d) {
5 entry:
6 %0 = load i1*, i1** %d, align 8
7 br i1 %a, label %if.then, label %if.else
8
9 if.then: ; preds = %entry
10 br label %if.end
11
12 if.else: ; preds = %entry
13 br label %if.end
14
15 if.end: ; preds = %if.else, %if.then
16 %c.0 = phi i1 [ 1, %if.then ], [ 0, %if.else ]
17 br i1 %c.0, label %if.then2, label %if.else3
18
19 if.then2: ; preds = %if.end
20 %rc = getelementptr inbounds i1, i1* %0, i64 0
21 store i1 %c.0, i1* %rc, align 4
22 br label %if.end6
23
24 if.else3: ; preds = %if.end
25 %rc5 = getelementptr inbounds i1, i1* %0, i64 0
26 store i1 %c.0, i1* %rc5, align 4
27 br label %if.end6
28
29 if.end6: ; preds = %if.else3, %if.then2
30 ret void
31 }
32
33 ; CHECK-LABEL: define void @test1(
34 ; CHECK: %[[load:.*]] = load i1*, i1** %d, align 8
35 ; CHECK: %[[phi:.*]] = phi i1 [ true, {{.*}} ], [ false, {{.*}} ]
36
37 ; CHECK: %[[gep0:.*]] = getelementptr inbounds i1, i1* %[[load]], i64 0
38 ; CHECK: store i1 %[[phi]], i1* %[[gep0]], align 4
39
40 ; CHECK: %[[gep1:.*]] = getelementptr inbounds i1, i1* %[[load]], i64 0
41 ; CHECK: store i1 %[[phi]], i1* %[[gep1]], align 4