llvm.org GIT mirror llvm / 86dfedd
[ValueTracking] Fix the identity case (LHS => RHS) when the LHS is false. Prior to this commit both of the added test cases were passing. However, in the latter case (test7) we were doing a lot more work to arrive at the same answer (i.e., we were using isImpliedCondMatchingOperands() to determine the implication.). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307400 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 3 years ago
2 changed file(s) with 38 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
44044404 assert(OpTy->getScalarType()->isIntegerTy(1));
44054405
44064406 // LHS ==> RHS by definition
4407 if (!LHSIsFalse && LHS == RHS)
4408 return true;
4407 if (LHS == RHS)
4408 return !LHSIsFalse;
44094409
44104410 if (OpTy->isVectorTy())
44114411 // TODO: extending the code below to handle vectors
161161 end:
162162 ret i32 0
163163 }
164
165 ; LHS ==> RHS by definition (true -> true)
166 ; CHECK-LABEL: @test6
167 ; CHECK: taken:
168 ; CHECK-NOT: select
169 ; CHECK: call void @foo(i32 10)
170 define void @test6(i32 %a, i32 %b) {
171 %cmp1 = icmp eq i32 %a, %b
172 br i1 %cmp1, label %taken, label %end
173
174 taken:
175 %c = select i1 %cmp1, i32 10, i32 0
176 call void @foo(i32 %c)
177 br label %end
178
179 end:
180 ret void
181 }
182
183 ; LHS ==> RHS by definition (false -> false)
184 ; CHECK-LABEL: @test7
185 ; CHECK: taken:
186 ; CHECK-NOT: select
187 ; CHECK: call void @foo(i32 11)
188 define void @test7(i32 %a, i32 %b) {
189 %cmp1 = icmp eq i32 %a, %b
190 br i1 %cmp1, label %end, label %taken
191
192 taken:
193 %c = select i1 %cmp1, i32 0, i32 11
194 call void @foo(i32 %c)
195 br label %end
196
197 end:
198 ret void
199 }