[llvm] r298488 - [ValueTracking] Make sure we keep range metadata information when calculating known bits for calls to bitreverse intrinsic.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 00:22:50 PDT 2017
Author: ctopper
Date: Wed Mar 22 02:22:49 2017
New Revision: 298488
URL: http://llvm.org/viewvc/llvm-project?rev=298488&view=rev
Log:
[ValueTracking] Make sure we keep range metadata information when calculating known bits for calls to bitreverse intrinsic.
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstCombine/bitreverse-known-bits.ll
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=298488&r1=298487&r2=298488&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Mar 22 02:22:49 2017
@@ -1414,8 +1414,8 @@ static void computeKnownBitsFromOperator
default: break;
case Intrinsic::bitreverse:
computeKnownBits(I->getOperand(0), KnownZero2, KnownOne2, Depth + 1, Q);
- KnownZero = KnownZero2.reverseBits();
- KnownOne = KnownOne2.reverseBits();
+ KnownZero |= KnownZero2.reverseBits();
+ KnownOne |= KnownOne2.reverseBits();
break;
case Intrinsic::bswap:
computeKnownBits(I->getOperand(0), KnownZero2, KnownOne2, Depth + 1, Q);
Modified: llvm/trunk/test/Transforms/InstCombine/bitreverse-known-bits.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitreverse-known-bits.ll?rev=298488&r1=298487&r2=298488&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitreverse-known-bits.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitreverse-known-bits.ll Wed Mar 22 02:22:49 2017
@@ -1,5 +1,6 @@
; RUN: opt < %s -S -instcombine | FileCheck %s
+declare i8 @llvm.bitreverse.i8(i8)
declare i32 @llvm.bitreverse.i32(i32)
; CHECK-LABEL: @test1
@@ -32,3 +33,19 @@ define i1 @test3(i32 %arg) {
%res = icmp eq i32 %and, 0
ret i1 %res
}
+
+; CHECK-LABEL: @add_bitreverse
+; Make sure we process range metadata on bitreverse
+define i8 @add_bitreverse(i8 %a) {
+ %b = and i8 %a, 252
+ ; known bits for the bitreverse will say the result is in the range [0, 64)
+ ; but the metadata says [0, 16). So make sure the range metadata wins.
+ ; add %reverse, 1111 0000
+ ; should become
+ ; or %reverse, 1111 0000
+ %reverse = call i8 @llvm.bitreverse.i8(i8 %b), !range !1
+ %c = add i8 %reverse, -16
+; CHECK: or i8 %reverse, -16
+ ret i8 %c
+}
+!1 = !{i8 0, i8 16}
More information about the llvm-commits
mailing list