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
8913882f
Commit
8913882f
authored
5 years ago
by
Sanjay Patel
Browse files
Options
Downloads
Patches
Plain Diff
[InstCombine] add tests for negate disguised as mul; NFC
llvm-svn: 373222
parent
565b1d3d
No related branches found
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/mul.ll
+74
-0
74 additions, 0 deletions
llvm/test/Transforms/InstCombine/mul.ll
with
74 additions
and
0 deletions
llvm/test/Transforms/InstCombine/mul.ll
+
74
−
0
View file @
8913882f
...
...
@@ -517,3 +517,77 @@ define i64 @test_mul_canonicalize_neg_is_not_undone(i64 %L1) {
%B4
=
mul
i64
%B8
,
%L1
ret
i64
%B4
}
define
i32
@negate_if_true
(
i32
%x
,
i1
%cond
)
{
; CHECK-LABEL: @negate_if_true(
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i32 -1, i32 1
; CHECK-NEXT: [[R:%.*]] = mul i32 [[SEL]], [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%sel
=
select
i1
%cond
,
i32
-1
,
i32
1
%r
=
mul
i32
%sel
,
%x
ret
i32
%r
}
define
i32
@negate_if_false
(
i32
%x
,
i1
%cond
)
{
; CHECK-LABEL: @negate_if_false(
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i32 1, i32 -1
; CHECK-NEXT: [[R:%.*]] = mul i32 [[SEL]], [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%sel
=
select
i1
%cond
,
i32
1
,
i32
-1
%r
=
mul
i32
%sel
,
%x
ret
i32
%r
}
define
<
2
x
i8
>
@negate_if_true_commute
(<
2
x
i8
>
%px
,
i1
%cond
)
{
; CHECK-LABEL: @negate_if_true_commute(
; CHECK-NEXT: [[X:%.*]] = sdiv <2 x i8> <i8 42, i8 42>, [[PX:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], <2 x i8> <i8 -1, i8 -1>, <2 x i8> <i8 1, i8 1>
; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[X]], [[SEL]]
; CHECK-NEXT: ret <2 x i8> [[R]]
;
%x
=
sdiv
<
2
x
i8
>
<
i8
42
,
i8
42
>,
%px
; thwart complexity-based canonicalization
%sel
=
select
i1
%cond
,
<
2
x
i8
>
<
i8
-1
,
i8
-1
>,
<
2
x
i8
>
<
i8
1
,
i8
1
>
%r
=
mul
<
2
x
i8
>
%x
,
%sel
ret
<
2
x
i8
>
%r
}
define
<
2
x
i8
>
@negate_if_false_commute
(<
2
x
i8
>
%px
,
<
2
x
i1
>
%cond
)
{
; CHECK-LABEL: @negate_if_false_commute(
; CHECK-NEXT: [[X:%.*]] = sdiv <2 x i8> <i8 42, i8 5>, [[PX:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[COND:%.*]], <2 x i8> <i8 1, i8 undef>, <2 x i8> <i8 -1, i8 -1>
; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[X]], [[SEL]]
; CHECK-NEXT: ret <2 x i8> [[R]]
;
%x
=
sdiv
<
2
x
i8
>
<
i8
42
,
i8
5
>,
%px
; thwart complexity-based canonicalization
%sel
=
select
<
2
x
i1
>
%cond
,
<
2
x
i8
>
<
i8
1
,
i8
undef
>,
<
2
x
i8
>
<
i8
-1
,
i8
-1
>
%r
=
mul
<
2
x
i8
>
%x
,
%sel
ret
<
2
x
i8
>
%r
}
define
i32
@negate_if_true_extra_use
(
i32
%x
,
i1
%cond
)
{
; CHECK-LABEL: @negate_if_true_extra_use(
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i32 -1, i32 1
; CHECK-NEXT: call void @use32(i32 [[SEL]])
; CHECK-NEXT: [[R:%.*]] = mul i32 [[SEL]], [[X:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%sel
=
select
i1
%cond
,
i32
-1
,
i32
1
call
void
@use32
(
i32
%sel
)
%r
=
mul
i32
%sel
,
%x
ret
i32
%r
}
define
<
2
x
i8
>
@negate_if_true_wrong_constant
(<
2
x
i8
>
%px
,
i1
%cond
)
{
; CHECK-LABEL: @negate_if_true_wrong_constant(
; CHECK-NEXT: [[X:%.*]] = sdiv <2 x i8> <i8 42, i8 42>, [[PX:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], <2 x i8> <i8 -1, i8 0>, <2 x i8> <i8 1, i8 1>
; CHECK-NEXT: [[R:%.*]] = mul <2 x i8> [[X]], [[SEL]]
; CHECK-NEXT: ret <2 x i8> [[R]]
;
%x
=
sdiv
<
2
x
i8
>
<
i8
42
,
i8
42
>,
%px
; thwart complexity-based canonicalization
%sel
=
select
i1
%cond
,
<
2
x
i8
>
<
i8
-1
,
i8
0
>,
<
2
x
i8
>
<
i8
1
,
i8
1
>
%r
=
mul
<
2
x
i8
>
%x
,
%sel
ret
<
2
x
i8
>
%r
}
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