summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp2
-rw-r--r--llvm/test/Analysis/DemandedBits/basic.ll13
2 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index 912c5ceb754..143d0b79f18 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -244,7 +244,7 @@ void DemandedBits::determineLiveOperandBits(
break;
case Instruction::ICmp:
// Count the number of leading zeroes in each operand.
- ComputeKnownBits(BitWidth, I, UserI->getOperand(1));
+ ComputeKnownBits(BitWidth, UserI->getOperand(0), UserI->getOperand(1));
auto NumLeadingZeroes = std::min(KnownZero.countLeadingOnes(),
KnownZero2.countLeadingOnes());
AB = ~APInt::getHighBitsSet(BitWidth, NumLeadingZeroes);
diff --git a/llvm/test/Analysis/DemandedBits/basic.ll b/llvm/test/Analysis/DemandedBits/basic.ll
index 487e522e9db..9973edf79c1 100644
--- a/llvm/test/Analysis/DemandedBits/basic.ll
+++ b/llvm/test/Analysis/DemandedBits/basic.ll
@@ -24,11 +24,20 @@ define i1 @test_icmp1(i32 %a, i32 %b) {
; CHECK-LABEL: 'test_icmp2'
; CHECK-DAG: DemandedBits: 0x1 for %3 = icmp eq i32 %1, %2
-; CHECK-DAG: DemandedBits: 0xFF for %1 = and i32 %a, 255
-; CHECK-DAG: DemandedBits: 0xF for %2 = ashr i32 %1, 4
+; CHECK-DAG: DemandedBits: 0xFFF for %1 = and i32 %a, 255
+; CHECK-DAG: DemandedBits: 0xFF for %2 = ashr i32 %1, 4
define i1 @test_icmp2(i32 %a, i32 %b) {
%1 = and i32 %a, 255
%2 = ashr i32 %1, 4
%3 = icmp eq i32 %1, %2
ret i1 %3
}
+
+; CHECK-LABEL: 'test_icmp3'
+; CHECK-DAG: DemandedBits: 0xFFFFFFFF for %1 = and i32 %a, 255
+; CHECK-DAG: DemandedBits: 0x1 for %2 = icmp eq i32 -1, %1
+define i1 @test_icmp3(i32 %a) {
+ %1 = and i32 %a, 255
+ %2 = icmp eq i32 -1, %1
+ ret i1 %2
+}
OpenPOWER on IntegriCloud