-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-re-land: Teach CorrelatedValuePropagation to reduce the width of u…
…div/urem instructions. Summary: If the operands of a udiv/urem can be proved to fit within a smaller power-of-two-sized type, reduce the width of the udiv/urem. Backed out for causing performance regressions. Re-landing because we've determined that these regressions were noise. Original Differential Revision: https://reviews.llvm.org/D44102 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328096 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Justin Lebar
committed
Mar 21, 2018
1 parent
2f0ad89
commit 0be6cf5
Showing
3 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
; RUN: opt < %s -correlated-propagation -S | FileCheck %s | ||
|
||
; CHECK-LABEL: @test_nop | ||
define void @test_nop(i32 %n) { | ||
; CHECK udiv i32 %n, 100 | ||
%div = udiv i32 %n, 100 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test1( | ||
define void @test1(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 65535 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: udiv i16 | ||
%div = udiv i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test2( | ||
define void @test2(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 65536 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: udiv i32 %n, 100 | ||
%div = udiv i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test3( | ||
define void @test3(i32 %m, i32 %n) { | ||
entry: | ||
%cmp1 = icmp ult i32 %m, 65535 | ||
%cmp2 = icmp ult i32 %n, 65535 | ||
%cmp = and i1 %cmp1, %cmp2 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: udiv i16 | ||
%div = udiv i32 %m, %n | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test4( | ||
define void @test4(i32 %m, i32 %n) { | ||
entry: | ||
%cmp1 = icmp ult i32 %m, 65535 | ||
%cmp2 = icmp ule i32 %n, 65536 | ||
%cmp = and i1 %cmp1, %cmp2 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: udiv i32 %m, %n | ||
%div = udiv i32 %m, %n | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test5 | ||
define void @test5(i32 %n) { | ||
%trunc = and i32 %n, 65535 | ||
; CHECK: udiv i16 | ||
%div = udiv i32 %trunc, 42 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test6 | ||
define void @test6(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 255 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: udiv i8 | ||
%div = sdiv i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
; RUN: opt < %s -correlated-propagation -S | FileCheck %s | ||
|
||
; CHECK-LABEL: @test_nop | ||
define void @test_nop(i32 %n) { | ||
; CHECK udiv i32 %n, 100 | ||
%div = udiv i32 %n, 100 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test1( | ||
define void @test1(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 65535 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: urem i16 | ||
%div = urem i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test2( | ||
define void @test2(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 65536 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: urem i32 %n, 100 | ||
%div = urem i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test3( | ||
define void @test3(i32 %m, i32 %n) { | ||
entry: | ||
%cmp1 = icmp ult i32 %m, 65535 | ||
%cmp2 = icmp ult i32 %n, 65535 | ||
%cmp = and i1 %cmp1, %cmp2 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: urem i16 | ||
%div = urem i32 %m, %n | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test4( | ||
define void @test4(i32 %m, i32 %n) { | ||
entry: | ||
%cmp1 = icmp ult i32 %m, 65535 | ||
%cmp2 = icmp ule i32 %n, 65536 | ||
%cmp = and i1 %cmp1, %cmp2 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: urem i32 %m, %n | ||
%div = urem i32 %m, %n | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test5 | ||
define void @test5(i32 %n) { | ||
%trunc = and i32 %n, 63 | ||
; CHECK: urem i8 | ||
%div = urem i32 %trunc, 42 | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @test6 | ||
define void @test6(i32 %n) { | ||
entry: | ||
%cmp = icmp ule i32 %n, 255 | ||
br i1 %cmp, label %bb, label %exit | ||
|
||
bb: | ||
; CHECK: urem i8 | ||
%div = srem i32 %n, 100 | ||
br label %exit | ||
|
||
exit: | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @non_power_of_2 | ||
define void @non_power_of_2(i24 %n) { | ||
%div = urem i24 %n, 42 | ||
ret void | ||
} |