[PATCH] D143032: [InstCombine] Allow splats with poison/undef in llvm::decomposeBitTestICmp
John McIver via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 15:10:41 PST 2023
jmciver created this revision.
jmciver added reviewers: RKSimon, fhahn, spatel, yamauchi, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
jmciver retitled this revision from "[InstCombine] Allow splats with undef in llvm::decomposeBitTestICmp" to "[InstCombine] Allow splats with poison/undef in llvm::decomposeBitTestICmp".
jmciver edited the summary of this revision.
jmciver updated this revision to Diff 494029.
jmciver added a comment.
jmciver updated this revision to Diff 494069.
jmciver published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Update patch per changes to test label names in D143031 <https://reviews.llvm.org/D143031>
jmciver added a comment.
Update per change to poison based splat vectors in D143031 <https://reviews.llvm.org/D143031>
This change is made to enable conversion of a masked icmp splat vector
containing poison/undef to an equality expression.
Tests have been verified using Alive2.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143032
Files:
llvm/lib/Analysis/CmpInstAnalysis.cpp
llvm/test/Transforms/InstCombine/icmp-logical.ll
llvm/test/Transforms/InstCombine/signed-truncation-check.ll
Index: llvm/test/Transforms/InstCombine/signed-truncation-check.ll
===================================================================
--- llvm/test/Transforms/InstCombine/signed-truncation-check.ll
+++ llvm/test/Transforms/InstCombine/signed-truncation-check.ll
@@ -200,11 +200,8 @@
define <3 x i1> @positive_vec_undef0(<3 x i32> %arg) {
; CHECK-LABEL: @positive_vec_undef0(
-; CHECK-NEXT: [[T1:%.*]] = icmp sgt <3 x i32> [[ARG:%.*]], <i32 -1, i32 undef, i32 -1>
-; CHECK-NEXT: [[T2:%.*]] = add <3 x i32> [[ARG]], <i32 128, i32 128, i32 128>
-; CHECK-NEXT: [[T3:%.*]] = icmp ult <3 x i32> [[T2]], <i32 256, i32 256, i32 256>
-; CHECK-NEXT: [[T4:%.*]] = and <3 x i1> [[T1]], [[T3]]
-; CHECK-NEXT: ret <3 x i1> [[T4]]
+; CHECK-NEXT: [[T4_SIMPLIFIED:%.*]] = icmp ult <3 x i32> [[ARG:%.*]], <i32 128, i32 128, i32 128>
+; CHECK-NEXT: ret <3 x i1> [[T4_SIMPLIFIED]]
;
%t1 = icmp sgt <3 x i32> %arg, <i32 -1, i32 undef, i32 -1>
%t2 = add <3 x i32> %arg, <i32 128, i32 128, i32 128>
Index: llvm/test/Transforms/InstCombine/icmp-logical.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-logical.ll
+++ llvm/test/Transforms/InstCombine/icmp-logical.ll
@@ -379,10 +379,7 @@
define <2 x i1> @nomask_splat_and_B_allones(<2 x i32> %A) {
; CHECK-LABEL: @nomask_splat_and_B_allones(
-; CHECK-NEXT: [[TST1:%.*]] = icmp slt <2 x i32> [[A:%.*]], <i32 0, i32 poison>
-; CHECK-NEXT: [[MASK2:%.*]] = and <2 x i32> [[A]], <i32 1879048192, i32 1879048192>
-; CHECK-NEXT: [[TST2:%.*]] = icmp eq <2 x i32> [[MASK2]], <i32 1879048192, i32 1879048192>
-; CHECK-NEXT: [[RES:%.*]] = and <2 x i1> [[TST1]], [[TST2]]
+; CHECK-NEXT: [[RES:%.*]] = icmp ugt <2 x i32> [[A:%.*]], <i32 -268435457, i32 -268435457>
; CHECK-NEXT: ret <2 x i1> [[RES]]
;
%tst1 = icmp slt <2 x i32> %A, <i32 0, i32 poison>
@@ -394,10 +391,8 @@
define <2 x i1> @nomask_splat_and_B_mixed(<2 x i32> %A) {
; CHECK-LABEL: @nomask_splat_and_B_mixed(
-; CHECK-NEXT: [[TST1:%.*]] = icmp sgt <2 x i32> [[A:%.*]], <i32 -1, i32 poison>
-; CHECK-NEXT: [[MASK2:%.*]] = and <2 x i32> [[A]], <i32 1879048192, i32 1879048192>
-; CHECK-NEXT: [[TST2:%.*]] = icmp eq <2 x i32> [[MASK2]], <i32 1879048192, i32 1879048192>
-; CHECK-NEXT: [[RES:%.*]] = and <2 x i1> [[TST1]], [[TST2]]
+; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i32> [[A:%.*]], <i32 -268435456, i32 -268435456>
+; CHECK-NEXT: [[RES:%.*]] = icmp eq <2 x i32> [[TMP1]], <i32 1879048192, i32 1879048192>
; CHECK-NEXT: ret <2 x i1> [[RES]]
;
%tst1 = icmp sgt <2 x i32> %A, <i32 -1, i32 poison>
Index: llvm/lib/Analysis/CmpInstAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/CmpInstAnalysis.cpp
+++ llvm/lib/Analysis/CmpInstAnalysis.cpp
@@ -79,7 +79,7 @@
using namespace PatternMatch;
const APInt *C;
- if (!match(RHS, m_APInt(C)))
+ if (!match(RHS, m_APIntAllowUndef(C)))
return false;
switch (Pred) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143032.494069.patch
Type: text/x-patch
Size: 3009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230201/e7910c0e/attachment.bin>
More information about the llvm-commits
mailing list