llvm.org GIT mirror llvm / 0c77db3
Switch invars away from using isTrapping when it really shouldn't be using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75852 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 10 years ago
2 changed file(s) with 26 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
543543 // New instructions were inserted at the end of the preheader.
544544 if (isa(I))
545545 break;
546 if (I->isTrapping())
546 // Don't move instructions which might have side effects, since the side
547 // effects need to complete before instructions inside the loop. Also
548 // don't move instructions which might read memory, since the loop may
549 // modify memory. Note that it's okay if the instruction might have
550 // undefined behavior: LoopSimplify guarantees that the preheader
551 // dominates the exit block.
552 if (I->mayHaveSideEffects() || I->mayReadFromMemory())
547553 continue;
548554 // Determine if there is a use in or before the loop (direct or
549555 // otherwise).
0 ; RUN: llvm-as < %s | opt -indvars | llvm-dis | FileCheck %s --check-prefix=CHECK
1
2 declare i1 @b()
3
4 define i32 @a(i32 %x) nounwind {
5 for.body.preheader:
6 %y = sdiv i32 10, %x
7 br label %for.body
8
9 for.body:
10 %cmp = call i1 @b()
11 br i1 %cmp, label %for.body, label %for.end.loopexit
12
13 for.end.loopexit:
14 ret i32 %y
15 }
16 ; CHECK: for.end.loopexit:
17 ; CHECK: sdiv
18 ; CHECK: ret