[llvm] r278740 - Revert "[ValueTracking] Improve ValueTracking on left shift with nsw flag"
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 15 14:01:31 PDT 2016
Author: sanjoy
Date: Mon Aug 15 16:01:31 2016
New Revision: 278740
URL: http://llvm.org/viewvc/llvm-project?rev=278740&view=rev
Log:
Revert "[ValueTracking] Improve ValueTracking on left shift with nsw flag"
This reverts commit r278172. It causes PR28946.
Removed:
llvm/trunk/test/Analysis/ValueTracking/known-signbit-shift.ll
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=278740&r1=278739&r2=278740&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Aug 15 16:01:31 2016
@@ -1064,22 +1064,13 @@ static void computeKnownBitsFromOperator
}
case Instruction::Shl: {
// (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0
- bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
- auto KZF = [BitWidth, NSW](const APInt &KnownZero, unsigned ShiftAmt) {
- APInt KZResult = (KnownZero << ShiftAmt) |
+ auto KZF = [BitWidth](const APInt &KnownZero, unsigned ShiftAmt) {
+ return (KnownZero << ShiftAmt) |
APInt::getLowBitsSet(BitWidth, ShiftAmt); // Low bits known 0.
- // If this shift has "nsw" keyword, then the result is either a poison
- // value or has the same sign bit as the first operand.
- if (NSW && KnownZero.isNegative())
- KZResult.setBit(BitWidth - 1);
- return KZResult;
};
- auto KOF = [BitWidth, NSW](const APInt &KnownOne, unsigned ShiftAmt) {
- APInt KOResult = KnownOne << ShiftAmt;
- if (NSW && KnownOne.isNegative())
- KOResult.setBit(BitWidth - 1);
- return KOResult;
+ auto KOF = [BitWidth](const APInt &KnownOne, unsigned ShiftAmt) {
+ return KnownOne << ShiftAmt;
};
computeKnownBitsFromShiftOperator(I, KnownZero, KnownOne,
Removed: llvm/trunk/test/Analysis/ValueTracking/known-signbit-shift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ValueTracking/known-signbit-shift.ll?rev=278739&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/ValueTracking/known-signbit-shift.ll (original)
+++ llvm/trunk/test/Analysis/ValueTracking/known-signbit-shift.ll (removed)
@@ -1,24 +0,0 @@
-; RUN: opt < %s -instcombine -S | FileCheck %s
-
-; Result of left shifting a non-negative integer
-; with nsw flag should also be non-negative
-define i1 @test_shift_nonnegative(i32 %a) {
-; CHECK-LABEL: @test_shift_nonnegative(
-; CHECK: ret i1 true
- %b = lshr i32 %a, 2
- %shift = shl nsw i32 %b, 3
- %cmp = icmp sge i32 %shift, 0
- ret i1 %cmp
-}
-
-; Result of left shifting a negative integer with
-; nsw flag should also be negative
-define i1 @test_shift_negative(i32 %a, i32 %b) {
-; CHECK-LABEL: @test_shift_negative(
-; CHECK: ret i1 true
- %c = or i32 %a, -2147483648
- %d = and i32 %b, 7
- %shift = shl nsw i32 %c, %d
- %cmp = icmp slt i32 %shift, 0
- ret i1 %cmp
-}
More information about the llvm-commits
mailing list