forked from llvm-mirror/llvm
-
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.
[InstCombine] Allow common type conversions to i8/i16/i32
This, in instcombine, allows conversions to i8/i16/i32 (very common cases) even if the resulting type is not legal according to the data layout. This can often open up extra combine opportunities. Differential Revision: https://reviews.llvm.org/D42424 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323951 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
217ad73
commit ab1bf91
Showing
5 changed files
with
142 additions
and
117 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
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
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,57 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -instcombine -S | FileCheck %s | ||
target datalayout = "n64" | ||
|
||
; Tests for removing zext/trunc from/to i8, i16 and i32, even if it is | ||
; not a legal type. | ||
|
||
define i8 @test1(i8 %x, i8 %y) { | ||
; CHECK-LABEL: @test1( | ||
; CHECK-NEXT: [[C:%.*]] = add i8 [[X:%.*]], [[Y:%.*]] | ||
; CHECK-NEXT: ret i8 [[C]] | ||
; | ||
%xz = zext i8 %x to i64 | ||
%yz = zext i8 %y to i64 | ||
%c = add i64 %xz, %yz | ||
%d = trunc i64 %c to i8 | ||
ret i8 %d | ||
} | ||
|
||
define i16 @test2(i16 %x, i16 %y) { | ||
; CHECK-LABEL: @test2( | ||
; CHECK-NEXT: [[C:%.*]] = add i16 [[X:%.*]], [[Y:%.*]] | ||
; CHECK-NEXT: ret i16 [[C]] | ||
; | ||
%xz = zext i16 %x to i64 | ||
%yz = zext i16 %y to i64 | ||
%c = add i64 %xz, %yz | ||
%d = trunc i64 %c to i16 | ||
ret i16 %d | ||
} | ||
|
||
define i32 @test3(i32 %x, i32 %y) { | ||
; CHECK-LABEL: @test3( | ||
; CHECK-NEXT: [[C:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] | ||
; CHECK-NEXT: ret i32 [[C]] | ||
; | ||
%xz = zext i32 %x to i64 | ||
%yz = zext i32 %y to i64 | ||
%c = add i64 %xz, %yz | ||
%d = trunc i64 %c to i32 | ||
ret i32 %d | ||
} | ||
|
||
define i9 @test4(i9 %x, i9 %y) { | ||
; CHECK-LABEL: @test4( | ||
; CHECK-NEXT: [[XZ:%.*]] = zext i9 [[X:%.*]] to i64 | ||
; CHECK-NEXT: [[YZ:%.*]] = zext i9 [[Y:%.*]] to i64 | ||
; CHECK-NEXT: [[C:%.*]] = add nuw nsw i64 [[XZ]], [[YZ]] | ||
; CHECK-NEXT: [[D:%.*]] = trunc i64 [[C]] to i9 | ||
; CHECK-NEXT: ret i9 [[D]] | ||
; | ||
%xz = zext i9 %x to i64 | ||
%yz = zext i9 %y to i64 | ||
%c = add i64 %xz, %yz | ||
%d = trunc i64 %c to i9 | ||
ret i9 %d | ||
} |