[PATCH] D114666: [InstSimplify] Simplify bool icmp with not in LHS

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 9 06:13:20 PST 2021


spatel added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2707-2708
   // A boolean compared to true/false can be simplified in 14 out of the 20
   // (10 predicates * 2 constants) possible combinations. Cases not handled here
   // require a 'not' of the LHS, so those must be transformed in InstCombine.
+
----------------
Given the new version of the patch, we should update this comment. :)
Something like this might explain better:
  // A boolean compared to true/false can be reduced in 14 out of the 20
  // (10 predicates * 2 constants) possible combinations directly. The other
  // 6 cases require a 'not' of the LHS.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2712
+    Value *X;
+    if (match(V, m_Xor(m_Value(X), m_One())))
+      return X;
----------------
Is there a reason to use m_Xor() rather than m_Not()?
Is the transform safe with vector types that might have undef elements?
For example:

```
define <2 x i1> @ult_t_not(<2 x i1> %a) {
  %not = xor <2 x i1> %a, <i1 undef, i1 true>
  %r = icmp ult <2 x i1> %not, <i1 true, i1 true>
  ret <2 x i1> %r
}

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114666



More information about the llvm-commits mailing list