Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCEV] Add transform zext((A * B * ...)<nuw>) --> (zext(A) * zext(B) …
…* ...)<nuw>. Reviewers: sanjoy Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D48041 llvm-svn: 334429
- Loading branch information
Justin Lebar
committed
Jun 11, 2018
1 parent
aa4fec9
commit 4da41c1
Showing
2 changed files
with
43 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,31 @@ | ||
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s | ||
|
||
; Check that we convert | ||
; zext((a * b)<nuw>) | ||
; to | ||
; (zext(a) * zext(b))<nuw> | ||
|
||
declare i32 @get_int(); | ||
|
||
; Transform doesn't apply here, because %a lacks range metadata. | ||
; CHECK-LABEL: @no_range | ||
define void @no_range() { | ||
%a = call i32 @get_int() | ||
%b = mul i32 %a, 4 | ||
%c = zext i32 %b to i64 | ||
; CHECK: %c | ||
; CHECK-NEXT: --> (zext i32 (4 * %a) to i64) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @range | ||
define void @range() { | ||
%a = call i32 @get_int(), !range !0 | ||
%b = mul i32 %a, 4 | ||
%c = zext i32 %b to i64 | ||
; CHECK: %c | ||
; CHECK-NEXT: --> (4 * (zext i32 %a to i64))<nuw> | ||
ret void | ||
} | ||
|
||
!0 = !{i32 0, i32 100} |