<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Rafael,<div>This commit is causing an execution-time failure for the <span style="font-family: Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); ">MultiSource/Benchmarks/FreeBench/distray/distray benchmark on all of our ARM nightly testers. Would you mind investigating?</span></div><div><span style="font-family: Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); "><br></span></div><div><span style="font-family: Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); "> Regards,</span></div><div><span style="font-family: Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); "> Chad</span></div><div><font face="Helvetica, sans-serif"><br></font><div><div>On Mar 25, 2012, at 6:44 PM, Rafael Espindola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: rafael<br>Date: Sun Mar 25 20:44:11 2012<br>New Revision: 153423<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=153423&view=rev">http://llvm.org/viewvc/llvm-project?rev=153423&view=rev</a><br>Log:<br>Use the new range metadata in computeMaskedBits and add a new optimization to<br>instruction simplify that lets us remove an and when loding a boolean value.<br><br>Added:<br> llvm/trunk/test/Transforms/InstSimplify/pr12251.ll<br>Modified:<br> llvm/trunk/lib/Analysis/InstructionSimplify.cpp<br> llvm/trunk/lib/Analysis/ValueTracking.cpp<br><br>Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=153423&r1=153422&r2=153423&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=153423&r1=153422&r2=153423&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)<br>+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Sun Mar 25 20:44:11 2012<br>@@ -1370,6 +1370,21 @@<br> return Op1;<br> }<br><br>+ unsigned Bitwidth = Op1->getType()->getScalarSizeInBits();<br>+ APInt DemandedMask = APInt::getAllOnesValue(Bitwidth);<br>+ APInt KnownZero0 = APInt::getNullValue(Bitwidth);<br>+ APInt KnownOne0 = APInt::getNullValue(Bitwidth);<br>+ ComputeMaskedBits(Op0, DemandedMask, KnownZero0, KnownOne0);<br>+ APInt KnownZero1 = APInt::getNullValue(Bitwidth);<br>+ APInt KnownOne1 = APInt::getNullValue(Bitwidth);<br>+ ComputeMaskedBits(Op1, DemandedMask, KnownZero1, KnownOne1);<br>+<br>+ if ((KnownZero0 | KnownOne1).isAllOnesValue())<br>+ return Op0;<br>+<br>+ if ((KnownZero1 | KnownOne0).isAllOnesValue())<br>+ return Op1;<br>+<br> // Try some generic simplifications for associative operations.<br> if (Value *V = SimplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q,<br> MaxRecurse))<br><br>Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=153423&r1=153422&r2=153423&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=153423&r1=153422&r2=153423&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)<br>+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Sun Mar 25 20:44:11 2012<br>@@ -20,8 +20,10 @@<br> #include "llvm/GlobalAlias.h"<br> #include "llvm/IntrinsicInst.h"<br> #include "llvm/LLVMContext.h"<br>+#include "llvm/Metadata.h"<br> #include "llvm/Operator.h"<br> #include "llvm/Target/TargetData.h"<br>+#include "llvm/Support/ConstantRange.h"<br> #include "llvm/Support/GetElementPtrTypeIterator.h"<br> #include "llvm/Support/MathExtras.h"<br> #include "llvm/Support/PatternMatch.h"<br>@@ -195,6 +197,26 @@<br> KnownOne.setBit(BitWidth - 1);<br> }<br><br>+static void computeMaskedBitsLoad(const MDNode &Ranges, const APInt &Mask,<br>+ APInt &KnownZero) {<br>+ unsigned BitWidth = Mask.getBitWidth();<br>+ unsigned NumRanges = Ranges.getNumOperands() / 2;<br>+ assert(NumRanges >= 1);<br>+<br>+ // Use the high end of the ranges to find leading zeros.<br>+ unsigned MinLeadingZeros = BitWidth;<br>+ for (unsigned i = 0; i < NumRanges; ++i) {<br>+ ConstantInt *Lower = cast<ConstantInt>(Ranges.getOperand(2*i + 0));<br>+ ConstantInt *Upper = cast<ConstantInt>(Ranges.getOperand(2*i + 1));<br>+ ConstantRange Range(Lower->getValue(), Upper->getValue());<br>+ if (Range.isWrappedSet())<br>+ MinLeadingZeros = 0; // -1 has no zeros<br>+ unsigned LeadingZeros = (Upper->getValue() - 1).countLeadingZeros();<br>+ MinLeadingZeros = std::min(LeadingZeros, MinLeadingZeros);<br>+ }<br>+<br>+ KnownZero = Mask & APInt::getHighBitsSet(BitWidth, MinLeadingZeros);<br>+}<br> /// ComputeMaskedBits - Determine which of the bits specified in Mask are<br> /// known to be either zero or one and return them in the KnownZero/KnownOne<br> /// bit sets. This code only analyzes bits in Mask, in order to short-circuit<br>@@ -315,6 +337,10 @@<br> APInt KnownZero2(KnownZero), KnownOne2(KnownOne);<br> switch (I->getOpcode()) {<br> default: break;<br>+ case Instruction::Load:<br>+ if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))<br>+ computeMaskedBitsLoad(*MD, Mask, KnownZero);<br>+ return;<br> case Instruction::And: {<br> // If either the LHS or the RHS are Zero, the result is zero.<br> ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, TD, Depth+1);<br><br>Added: llvm/trunk/test/Transforms/InstSimplify/pr12251.ll<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/pr12251.ll?rev=153423&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/pr12251.ll?rev=153423&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/InstSimplify/pr12251.ll (added)<br>+++ llvm/trunk/test/Transforms/InstSimplify/pr12251.ll Sun Mar 25 20:44:11 2012<br>@@ -0,0 +1,15 @@<br>+; RUN: opt < %s -instsimplify -S | FileCheck %s<br>+<br>+define zeroext i1 @_Z3fooPb(i8* nocapture %x) {<br>+entry:<br>+ %a = load i8* %x, align 1, !range !0<br>+ %b = and i8 %a, 1<br>+ %tobool = icmp ne i8 %b, 0<br>+ ret i1 %tobool<br>+}<br>+<br>+; CHECK: %a = load i8* %x, align 1, !range !0<br>+; CHECK-NEXT: %tobool = icmp ne i8 %a, 0<br>+; CHECK-NEXT: ret i1 %tobool<br>+<br>+!0 = metadata !{i8 0, i8 2}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></div></blockquote></div><br></div></body></html>