Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
llvm-epi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roger Ferrer
llvm-epi
Commits
6f922dbb
Unverified
Commit
6f922dbb
authored
5 years ago
by
Roman Lebedev
Browse files
Options
Downloads
Patches
Plain Diff
[NFC][InstCombine] '(Op1 & С) - Op1' pattern tests (PR44427)
parent
9b750cc6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/test/Transforms/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll
+98
-0
98 additions, 0 deletions
...e/hoist-negation-out-of-bias-calculation-with-constant.ll
with
98 additions
and
0 deletions
llvm/test/Transforms/InstCombine/hoist-negation-out-of-bias-calculation-with-constant.ll
0 → 100644
+
98
−
0
View file @
6f922dbb
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S < %s -instcombine | FileCheck %s
; Fold
; (X & C) - X
; to
; - (X & ~C)
;
; This allows us to possibly hoist said negation further out,
; and decreases use count of X.
; https://bugs.llvm.org/show_bug.cgi?id=44427
; Base tests
define
i8
@t0
(
i8
%x
)
{
; CHECK-LABEL: @t0(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and i8 [[X:%.*]], 42
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub i8 [[UNBIASEDX]], [[X]]
; CHECK-NEXT: ret i8 [[NEGBIAS]]
;
%unbiasedx
=
and
i8
%x
,
42
%negbias
=
sub
i8
%unbiasedx
,
%x
ret
i8
%negbias
}
define
<
2
x
i8
>
@t1_vec
(<
2
x
i8
>
%x
)
{
; CHECK-LABEL: @t1_vec(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and <2 x i8> [[X:%.*]], <i8 42, i8 42>
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub <2 x i8> [[UNBIASEDX]], [[X]]
; CHECK-NEXT: ret <2 x i8> [[NEGBIAS]]
;
%unbiasedx
=
and
<
2
x
i8
>
%x
,
<
i8
42
,
i8
42
>
%negbias
=
sub
<
2
x
i8
>
%unbiasedx
,
%x
ret
<
2
x
i8
>
%negbias
}
define
<
2
x
i8
>
@t2_vec_undef
(<
2
x
i8
>
%x
)
{
; CHECK-LABEL: @t2_vec_undef(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and <2 x i8> [[X:%.*]], <i8 42, i8 undef>
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub <2 x i8> [[UNBIASEDX]], [[X]]
; CHECK-NEXT: ret <2 x i8> [[NEGBIAS]]
;
%unbiasedx
=
and
<
2
x
i8
>
%x
,
<
i8
42
,
i8
undef
>
%negbias
=
sub
<
2
x
i8
>
%unbiasedx
,
%x
ret
<
2
x
i8
>
%negbias
}
define
<
2
x
i8
>
@t3_vec_nonsplat
(<
2
x
i8
>
%x
)
{
; CHECK-LABEL: @t3_vec_nonsplat(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and <2 x i8> [[X:%.*]], <i8 42, i8 44>
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub <2 x i8> [[UNBIASEDX]], [[X]]
; CHECK-NEXT: ret <2 x i8> [[NEGBIAS]]
;
%unbiasedx
=
and
<
2
x
i8
>
%x
,
<
i8
42
,
i8
44
>
%negbias
=
sub
<
2
x
i8
>
%unbiasedx
,
%x
ret
<
2
x
i8
>
%negbias
}
; Extra uses always prevent fold
declare
void
@use8
(
i8
)
define
i8
@n4_extrause
(
i8
%x
)
{
; CHECK-LABEL: @n4_extrause(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and i8 [[X:%.*]], 42
; CHECK-NEXT: call void @use8(i8 [[UNBIASEDX]])
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub i8 [[UNBIASEDX]], [[X]]
; CHECK-NEXT: ret i8 [[NEGBIAS]]
;
%unbiasedx
=
and
i8
%x
,
42
call
void
@use8
(
i8
%unbiasedx
)
%negbias
=
sub
i8
%unbiasedx
,
%x
ret
i8
%negbias
}
; Negative tests
define
i8
@n5
(
i8
%x
)
{
; CHECK-LABEL: @n5(
; CHECK-NEXT: [[NEGBIAS:%.*]] = and i8 [[X:%.*]], -43
; CHECK-NEXT: ret i8 [[NEGBIAS]]
;
%unbiasedx
=
and
i8
%x
,
42
%negbias
=
sub
i8
%x
,
%unbiasedx
; wrong order
ret
i8
%negbias
}
define
i8
@n6
(
i8
%x0
,
i8
%x1
)
{
; CHECK-LABEL: @n6(
; CHECK-NEXT: [[UNBIASEDX:%.*]] = and i8 [[X1:%.*]], 42
; CHECK-NEXT: [[NEGBIAS:%.*]] = sub i8 [[UNBIASEDX]], [[X0:%.*]]
; CHECK-NEXT: ret i8 [[NEGBIAS]]
;
%unbiasedx
=
and
i8
%x1
,
42
; not %x0
%negbias
=
sub
i8
%unbiasedx
,
%x0
; not %x1
ret
i8
%negbias
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment