[PATCH] D19549: Fold compares irrespective of whether allocation can be elided

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 12:35:03 PDT 2016


anna marked 2 inline comments as done.

================
Comment at: lib/Analysis/InstructionSimplify.cpp:2100
@@ +2099,3 @@
+  if (MI && !PointerMayBeCaptured(MI, true, true))
+    return ConstantInt::get(GetCompareTy(LHS), !CmpInst::isTrueWhenEqual(Pred));
+
----------------
sanjoy wrote:
> You can use `CmpInst::isFalseWhenEqual` here, but did you intend to put this under the previous `Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE` check?  Right now you're handling inequalities too, I think.
> 
> Inequalities are tricky, since it is difficult to justify folding `%newPtr ULE -1` to `false`, for instance.
> 
I see your point. Although we can never know the `%newPtr` value when it is dynamically allocated, there *might be* some inequalities which can not automatically be folded to false, such as making sure the value is `ULE` or `UGE`  a 'boundary' value. 


Repository:
  rL LLVM

http://reviews.llvm.org/D19549





More information about the llvm-commits mailing list