llvm.org GIT mirror llvm / 11745d4
indvars -disable-iv-rewrite: just because SCEV ignores casts doesn't mean they can be removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134054 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 8 years ago
2 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
10061006
10071007 // Eliminate any operation that SCEV can prove is an identity function.
10081008 if (!SE->isSCEVable(UseInst->getType()) ||
1009 (UseInst->getType() != IVOperand->getType()) ||
10091010 (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
10101011 return false;
10111012
2222 ; sext should be eliminated while preserving gep inboundsness.
2323 ; CHECK-NOT: sext
2424 ; CHECK: getelementptr inbounds
25 ; CHECK: exit
2526 loop:
2627 %i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
2728 %s.01 = phi i32 [ 0, %ph ], [ %sinc, %loop ]
6263 ; CHECK: getelementptr inbounds
6364 ; %vall sext should obviously not be eliminated
6465 ; CHECK: sext
66 ; CHECK: exit
6567 loop:
6668 %i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
6769 %s.01 = phi i64 [ 0, %ph ], [ %sinc, %loop ]
105107 ; Preserve gep inboundsness, and don't factor it.
106108 ; CHECK: getelementptr inbounds i32* %ptriv, i32 1
107109 ; CHECK-NOT: add
110 ; CHECK: exit
108111 loop:
109112 %ptriv = phi i32* [ %first, %ph ], [ %ptrpost, %loop ]
110113 %ofs = sext i32 %idx to i64
120123 return:
121124 ret void
122125 }
126
127 %struct = type { i32 }
128
129 define void @bitcastiv(i32 %start, i32 %limit, i32 %step, %struct* %base)
130 nounwind
131 {
132 entry:
133 br label %loop
134
135 ; CHECK: loop:
136 ;
137 ; Preserve casts
138 ; CHECK: phi i32
139 ; CHECK: bitcast
140 ; CHECK: getelementptr
141 ; CHECK: exit
142 loop:
143 %iv = phi i32 [%start, %entry], [%next, %loop]
144 %p = phi %struct* [%base, %entry], [%pinc, %loop]
145 %adr = getelementptr %struct* %p, i32 0, i32 0
146 store i32 3, i32* %adr
147 %pp = bitcast %struct* %p to i32*
148 store i32 4, i32* %pp
149 %pinc = getelementptr %struct* %p, i32 1
150 %next = add i32 %iv, 1
151 %cond = icmp ne i32 %next, %limit
152 br i1 %cond, label %loop, label %exit
153
154 exit:
155 br label %return
156
157 return:
158 ret void
159 }