<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 27 June 2014 05:31, suyog <span dir="ltr"><<a href="mailto:suyog.sarda@samsung.com" target="_blank">suyog.sarda@samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Nick,<br>
<br>
I modified the test case to use FileCheck.<br>
<br>
I also believe the test case is in accordance to what we taught instsimplify as mentioned by Rahul above.<br>
Also, this test case was the original one for instcombine, the code for which we moved to instsimplify.<br>
<br>
Can you point out what's specific wrong in the test case? Your inputs are most welcomed :)<br>
<div class=""><br>
<a href="http://reviews.llvm.org/D4102" target="_blank">http://reviews.llvm.org/D4102</a><br>
<br>
Files:<br>
lib/Analysis/InstructionSimplify.cpp<br>
lib/Transforms/InstCombine/InstCombineShifts.cpp<br>
</div> test/Transforms/InstSimplify/ashr-nop.ll<br>
<div class=""><br>
Index: lib/Analysis/InstructionSimplify.cpp<br>
===================================================================<br>
--- lib/Analysis/InstructionSimplify.cpp<br>
+++ lib/Analysis/InstructionSimplify.cpp<br>
</div>@@ -1346,6 +1346,11 @@<br>
<div class=""> cast<OverflowingBinaryOperator>(Op0)->hasNoSignedWrap())<br>
return X;<br>
<br>
+ // Arithmetic shifting an all-sign-bit value is a no-op.<br>
+ unsigned NumSignBits = ComputeNumSignBits(Op0);<br>
+ if (NumSignBits == Op0->getType()->getScalarSizeInBits())<br>
+ return Op0;<br>
+<br>
return nullptr;<br>
}<br>
<br>
Index: lib/Transforms/InstCombine/InstCombineShifts.cpp<br>
===================================================================<br>
--- lib/Transforms/InstCombine/InstCombineShifts.cpp<br>
+++ lib/Transforms/InstCombine/InstCombineShifts.cpp<br>
</div>@@ -815,10 +815,5 @@<br>
<div class=""> APInt::getSignBit(I.getType()->getScalarSizeInBits())))<br>
return BinaryOperator::CreateLShr(Op0, Op1);<br>
<br>
- // Arithmetic shifting an all-sign-bit value is a no-op.<br>
- unsigned NumSignBits = ComputeNumSignBits(Op0);<br>
- if (NumSignBits == Op0->getType()->getScalarSizeInBits())<br>
- return ReplaceInstUsesWith(I, Op0);<br>
-<br>
return nullptr;<br>
}<br>
</div><div class="">Index: test/Transforms/InstSimplify/ashr-nop.ll<br>
===================================================================<br>
--- test/Transforms/InstSimplify/ashr-nop.ll<br>
+++ test/Transforms/InstSimplify/ashr-nop.ll<br>
</div>@@ -0,0 +1,10 @@<br>
+; RUN: opt < %s -instcombine -S | FileCheck %s<br></blockquote><div><br></div><div>Did you mean -instsimplify?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+; CHECK-LABEL: @foo<br>
+; CHECK-NOT: ashr<br>
<div class="HOEnZb"><div class="h5">+define i32 @foo(i32 %x) {<br>
+ %o = and i32 %x, 1<br>
+ %n = add i32 %o, -1<br>
+ %t = ashr i32 %n, 17<br>
+ ret i32 %t<br>
+}<br>
</div></div></blockquote></div><br></div></div>