[llvm] r307400 - [ValueTracking] Fix the identity case (LHS => RHS) when the LHS is false.
Chad Rosier via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 06:55:55 PDT 2017
Author: mcrosier
Date: Fri Jul 7 06:55:55 2017
New Revision: 307400
URL: http://llvm.org/viewvc/llvm-project?rev=307400&view=rev
Log:
[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.).
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstCombine/select-implied.ll
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=307400&r1=307399&r2=307400&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Jul 7 06:55:55 2017
@@ -4405,8 +4405,8 @@ Optional<bool> llvm::isImpliedCondition(
assert(OpTy->getScalarType()->isIntegerTy(1));
// LHS ==> RHS by definition
- if (!LHSIsFalse && LHS == RHS)
- return true;
+ if (LHS == RHS)
+ return !LHSIsFalse;
if (OpTy->isVectorTy())
// TODO: extending the code below to handle vectors
Modified: llvm/trunk/test/Transforms/InstCombine/select-implied.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select-implied.ll?rev=307400&r1=307399&r2=307400&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select-implied.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select-implied.ll Fri Jul 7 06:55:55 2017
@@ -162,3 +162,39 @@ fpath:
end:
ret i32 0
}
+
+; LHS ==> RHS by definition (true -> true)
+; CHECK-LABEL: @test6
+; CHECK: taken:
+; CHECK-NOT: select
+; CHECK: call void @foo(i32 10)
+define void @test6(i32 %a, i32 %b) {
+ %cmp1 = icmp eq i32 %a, %b
+ br i1 %cmp1, label %taken, label %end
+
+taken:
+ %c = select i1 %cmp1, i32 10, i32 0
+ call void @foo(i32 %c)
+ br label %end
+
+end:
+ ret void
+}
+
+; LHS ==> RHS by definition (false -> false)
+; CHECK-LABEL: @test7
+; CHECK: taken:
+; CHECK-NOT: select
+; CHECK: call void @foo(i32 11)
+define void @test7(i32 %a, i32 %b) {
+ %cmp1 = icmp eq i32 %a, %b
+ br i1 %cmp1, label %end, label %taken
+
+taken:
+ %c = select i1 %cmp1, i32 0, i32 11
+ call void @foo(i32 %c)
+ br label %end
+
+end:
+ ret void
+}
More information about the llvm-commits
mailing list