[llvm-commits] [llvm] r153452 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp lib/Analysis/ValueTracking.cpp test/Transforms/InstSimplify/pr12251.ll
Chad Rosier
mcrosier at apple.com
Mon Mar 26 11:07:14 PDT 2012
Author: mcrosier
Date: Mon Mar 26 13:07:14 2012
New Revision: 153452
URL: http://llvm.org/viewvc/llvm-project?rev=153452&view=rev
Log:
Revert r153423 as this is causing failures on our internal nightly testers.
Original commit message:
Use the new range metadata in computeMaskedBits and add a new optimization to
instruction simplify that lets us remove an and when loading a boolean value.
Removed:
llvm/trunk/test/Transforms/InstSimplify/pr12251.ll
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/ValueTracking.cpp
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=153452&r1=153451&r2=153452&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Mon Mar 26 13:07:14 2012
@@ -1370,21 +1370,6 @@
return Op1;
}
- unsigned Bitwidth = Op1->getType()->getScalarSizeInBits();
- APInt DemandedMask = APInt::getAllOnesValue(Bitwidth);
- APInt KnownZero0 = APInt::getNullValue(Bitwidth);
- APInt KnownOne0 = APInt::getNullValue(Bitwidth);
- ComputeMaskedBits(Op0, DemandedMask, KnownZero0, KnownOne0);
- APInt KnownZero1 = APInt::getNullValue(Bitwidth);
- APInt KnownOne1 = APInt::getNullValue(Bitwidth);
- ComputeMaskedBits(Op1, DemandedMask, KnownZero1, KnownOne1);
-
- if ((KnownZero0 | KnownOne1).isAllOnesValue())
- return Op0;
-
- if ((KnownZero1 | KnownOne0).isAllOnesValue())
- return Op1;
-
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q,
MaxRecurse))
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=153452&r1=153451&r2=153452&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Mar 26 13:07:14 2012
@@ -20,10 +20,8 @@
#include "llvm/GlobalAlias.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
#include "llvm/Operator.h"
#include "llvm/Target/TargetData.h"
-#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/PatternMatch.h"
@@ -197,26 +195,6 @@
KnownOne.setBit(BitWidth - 1);
}
-static void computeMaskedBitsLoad(const MDNode &Ranges, const APInt &Mask,
- APInt &KnownZero) {
- unsigned BitWidth = Mask.getBitWidth();
- unsigned NumRanges = Ranges.getNumOperands() / 2;
- assert(NumRanges >= 1);
-
- // Use the high end of the ranges to find leading zeros.
- unsigned MinLeadingZeros = BitWidth;
- for (unsigned i = 0; i < NumRanges; ++i) {
- ConstantInt *Lower = cast<ConstantInt>(Ranges.getOperand(2*i + 0));
- ConstantInt *Upper = cast<ConstantInt>(Ranges.getOperand(2*i + 1));
- ConstantRange Range(Lower->getValue(), Upper->getValue());
- if (Range.isWrappedSet())
- MinLeadingZeros = 0; // -1 has no zeros
- unsigned LeadingZeros = (Upper->getValue() - 1).countLeadingZeros();
- MinLeadingZeros = std::min(LeadingZeros, MinLeadingZeros);
- }
-
- KnownZero = Mask & APInt::getHighBitsSet(BitWidth, MinLeadingZeros);
-}
/// ComputeMaskedBits - Determine which of the bits specified in Mask are
/// known to be either zero or one and return them in the KnownZero/KnownOne
/// bit sets. This code only analyzes bits in Mask, in order to short-circuit
@@ -337,10 +315,6 @@
APInt KnownZero2(KnownZero), KnownOne2(KnownOne);
switch (I->getOpcode()) {
default: break;
- case Instruction::Load:
- if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))
- computeMaskedBitsLoad(*MD, Mask, KnownZero);
- return;
case Instruction::And: {
// If either the LHS or the RHS are Zero, the result is zero.
ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, TD, Depth+1);
Removed: llvm/trunk/test/Transforms/InstSimplify/pr12251.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/pr12251.ll?rev=153451&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/pr12251.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/pr12251.ll (removed)
@@ -1,15 +0,0 @@
-; RUN: opt < %s -instsimplify -S | FileCheck %s
-
-define zeroext i1 @_Z3fooPb(i8* nocapture %x) {
-entry:
- %a = load i8* %x, align 1, !range !0
- %b = and i8 %a, 1
- %tobool = icmp ne i8 %b, 0
- ret i1 %tobool
-}
-
-; CHECK: %a = load i8* %x, align 1, !range !0
-; CHECK-NEXT: %tobool = icmp ne i8 %a, 0
-; CHECK-NEXT: ret i1 %tobool
-
-!0 = metadata !{i8 0, i8 2}
More information about the llvm-commits
mailing list