-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] add tests for icmp with trunc op; NFC
- Loading branch information
1 parent
1e6ef0c
commit e8fdd03
Showing
1 changed file
with
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -instcombine -S | FileCheck %s | ||
|
||
declare void @use(i8) | ||
|
||
define i1 @ult_2(i32 %x) { | ||
; CHECK-LABEL: @ult_2( | ||
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8 | ||
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 2 | ||
; CHECK-NEXT: ret i1 [[R]] | ||
; | ||
%t = trunc i32 %x to i8 | ||
%r = icmp ult i8 %t, 2 | ||
ret i1 %r | ||
} | ||
|
||
define <2 x i1> @ult_16_splat(<2 x i16> %x) { | ||
; CHECK-LABEL: @ult_16_splat( | ||
; CHECK-NEXT: [[T:%.*]] = trunc <2 x i16> [[X:%.*]] to <2 x i11> | ||
; CHECK-NEXT: [[R:%.*]] = icmp ult <2 x i11> [[T]], <i11 16, i11 16> | ||
; CHECK-NEXT: ret <2 x i1> [[R]] | ||
; | ||
%t = trunc <2 x i16> %x to <2 x i11> | ||
%r = icmp ult <2 x i11> %t, <i11 16, i11 16> | ||
ret <2 x i1> %r | ||
} | ||
|
||
define i1 @ult_3(i32 %x) { | ||
; CHECK-LABEL: @ult_3( | ||
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8 | ||
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 3 | ||
; CHECK-NEXT: ret i1 [[R]] | ||
; | ||
%t = trunc i32 %x to i8 | ||
%r = icmp ult i8 %t, 3 | ||
ret i1 %r | ||
} | ||
|
||
define i1 @ult_2_use(i32 %x) { | ||
; CHECK-LABEL: @ult_2_use( | ||
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8 | ||
; CHECK-NEXT: call void @use(i8 [[T]]) | ||
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 2 | ||
; CHECK-NEXT: ret i1 [[R]] | ||
; | ||
%t = trunc i32 %x to i8 | ||
call void @use(i8 %t) | ||
%r = icmp ult i8 %t, 2 | ||
ret i1 %r | ||
} | ||
|
||
@a = internal unnamed_addr constant [3 x i32] [i32 0, i32 0, i32 1], align 4 | ||
|
||
define i1 @PR52260(i32 %x) { | ||
; CHECK-LABEL: @PR52260( | ||
; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[X:%.*]] to i64 | ||
; CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 [[IDXPROM]] | ||
; CHECK-NEXT: [[T1:%.*]] = load i32, i32* [[IDX]], align 4 | ||
; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[T1]] to i8 | ||
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ult i8 [[TMP1]], 2 | ||
; CHECK-NEXT: ret i1 [[TOBOOL]] | ||
; | ||
%idxprom = sext i32 %x to i64 | ||
%idx = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 %idxprom | ||
%t1 = load i32, i32* %idx, align 4 | ||
%conv1 = lshr i32 %t1, 1 | ||
%t2 = trunc i32 %conv1 to i8 | ||
%conv2 = and i8 %t2, 127 | ||
%tobool = icmp eq i8 %conv2, 0 | ||
ret i1 %tobool | ||
} | ||
|