Merging r258690:
authorJames Molloy <james.molloy@arm.com>
Tue, 26 Jan 2016 13:30:49 +0000 (13:30 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 26 Jan 2016 13:30:49 +0000 (13:30 +0000)
------------------------------------------------------------------------
r258690 | jamesm | 2016-01-25 14:49:36 +0000 (Mon, 25 Jan 2016) | 7 lines

[DemandedBits] Fix computation of demanded bits for ICmps

The computation of ICmp demanded bits is independent of the individual operand being evaluated. We simply return a mask consisting of the minimum leading zeroes of both operands.

We were incorrectly passing "I" to ComputeKnownBits - this should be "UserI->getOperand(0)". In cases where we were evaluating the 1th operand, we were taking the minimum leading zeroes of it and itself.

This should fix PR26266.
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@258805 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DemandedBits.cpp
test/Analysis/DemandedBits/basic.ll
utils/release/merge.sh

index 912c5ceb754dd0d78e9f8655e2b17d69e620aa07..143d0b79f188e5f59372ddd1a2231acf1cfa0747 100644 (file)
@@ -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);
index 487e522e9dbc6ea48c375358a291f7c2ecc063ec..9973edf79c176491d8e72308763c563e280e41b7 100644 (file)
@@ -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
+}
index 93e08c7ce135735064cf68697676bccf5025beb1..6ef7d26d5a714d5f87604b3d8809705feeaa3528 100755 (executable)
@@ -72,7 +72,7 @@ else
 fi
 svn log -c $rev http://llvm.org/svn/llvm-project/$proj/trunk >> $tempfile 2>&1
 
-cd $proj.src
+#cd $proj.src
 echo "# Updating tree"
 svn up
 
@@ -81,7 +81,7 @@ if [ $revert = "yes" ]; then
     svn merge -c -$rev . || exit 1
 else
     echo "# Merging r$rev into $proj locally"
-    svn merge -c $rev https://llvm.org/svn/llvm-project/$proj/trunk . || exit 1
+    svn merge -c $rev https://jamesm@llvm.org/svn/llvm-project/$proj/trunk . || exit 1
 fi
 
 echo