llvm.org GIT mirror llvm / 9b61c55
SimplifyCFG: GEPs with constant indices are cheap enough to be executed unconditionally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126445 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 8 years ago
2 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
244244 // load in its basic block, as we are going to hoist the load out to its
245245 // predecessor.
246246 if (PBB->getFirstNonPHIOrDbg() != I)
247 return false;
248 break;
249 case Instruction::GetElementPtr:
250 // GEPs are cheap if all indices are constant.
251 if (!cast(I)->hasAllConstantIndices())
247252 return false;
248253 break;
249254 case Instruction::Add:
0 ; RUN: opt -S -simplifycfg %s | FileCheck %s
1
2 define i8* @test1(i8* %x) nounwind {
3 entry:
4 %tmp1 = load i8* %x, align 1
5 %cmp = icmp eq i8 %tmp1, 47
6 br i1 %cmp, label %if.then, label %if.end
7
8 if.then:
9 %incdec.ptr = getelementptr inbounds i8* %x, i64 1
10 br label %if.end
11
12 if.end:
13 %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %x, %entry ]
14 ret i8* %x.addr
15
16 ; CHECK: @test1
17 ; CHECK: %x.addr = select i1 %cmp, i8* %incdec.ptr, i8* %x
18 ; CHECK: ret i8* %x.addr
19 }