[PATCH] D132989: [InstSimplify] Odd - X ==/!= X -> false/true

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 4 07:32:59 PDT 2022


spatel added a comment.

1. Did you determine that the transform is valid without nsw/nuw?

2. My request for a vector test with poison element was not handled. Please mark inline questions as completed when they are answered.

3. The tests should be in the tests/Transforms/InstSimplify directory, and the RUN line should only use -instsimplify.



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:3297-3298
+  // (sub C, X) != X, C is odd  --> true
+  if (LBO && LBO->getOperand(1) == RHS &&
+      match(LHS, m_Sub(m_APInt(C), m_Value()))) {
+    if ((*C & 1) == 1) {
----------------
Reduce to match() with m_Specific()?


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:3299
+      match(LHS, m_Sub(m_APInt(C), m_Value()))) {
+    if ((*C & 1) == 1) {
+      if (Pred == CmpInst::ICMP_EQ)
----------------
RKSimon wrote:
> Can we use knownbits here instead to support non-uniform constant vectors?
> 
> I'm never very clear on when we're allowed to use value tracking in instsimplify as its more expensive....
Yes, I mentioned that in an earlier comment. 

I think we could handle the non-uniform constant pattern even without knownbits - check the compare of a constant expression? But I'd say let's do that as a follow-up to keep this patch simpler.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132989/new/

https://reviews.llvm.org/D132989



More information about the llvm-commits mailing list