[PATCH] D138700: [InstSimplify] Fold !(X || Y) && X --> false

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 07:42:57 PST 2022


spatel added a comment.

There's still a lot of possibilities even with these 2 patterns, so I'd prefer to split it up again. We are missing some necessary tests.



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4560
+    if (match(Cond, m_LogicalOr(m_Value(X), m_Value(Y)))) {
+      // !(X || Y) && X --> false (commuted 2 ways)
+      if (match(TrueVal, m_ZeroInt()) && (X == FalseVal || Y == FalseVal))
----------------
This comment is not the same as the pattern that is matched.


================
Comment at: llvm/test/Transforms/InstSimplify/select-logical.ll:141
 
 define i1 @logical_not_or_and_case1(i1 %x, i1 %y) {
 ; CHECK-LABEL: @logical_not_or_and_case1(
----------------
Shouldn't there be a test like this (or the first test) with a bitwise 'or'?

https://alive2.llvm.org/ce/z/yzcA-z


================
Comment at: llvm/test/Transforms/InstSimplify/select-logical.ll:153
 
 define <3 x i1> @logical_not_or_and_vector1(<3 x i1> %x, <3 x i1> %y) {
 ; CHECK-LABEL: @logical_not_or_and_vector1(
----------------
We need a test similar to this, but with poison elements.


================
Comment at: llvm/test/Transforms/InstSimplify/select-logical.ll:229
 ; CHECK-LABEL: @logical_not_or_and_vector2_poison(
-; CHECK-NEXT:    [[OR:%.*]] = or <2 x i1> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[R:%.*]] = select <2 x i1> [[OR]], <2 x i1> <i1 poison, i1 false>, <2 x i1> [[X]]
-; CHECK-NEXT:    ret <2 x i1> [[R]]
+; CHECK-NEXT:    ret <2 x i1> <i1 poison, i1 false>
 ;
----------------
This is a miscompile:
https://alive2.llvm.org/ce/z/tAeZY9


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

https://reviews.llvm.org/D138700



More information about the llvm-commits mailing list