-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TRE] Add tests for intrinsic accumulators
- Loading branch information
Showing
1 changed file
with
141 additions
and
0 deletions.
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
llvm/test/Transforms/TailCallElim/tre-minmax-intrinsic.ll
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,141 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 | ||
; RUN: opt < %s -passes=tailcallelim -verify-dom-info -S | FileCheck %s | ||
|
||
%struct.ListNode = type { i32, ptr } | ||
|
||
define noundef i32 @umin(ptr noundef readonly %a) { | ||
; CHECK-LABEL: define noundef i32 @umin | ||
; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null | ||
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] | ||
; CHECK: common.ret6: | ||
; CHECK-NEXT: ret i32 -1 | ||
; CHECK: if.end: | ||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 | ||
; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 | ||
; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @umin(ptr noundef [[TMP1]]) | ||
; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.umin.i32(i32 [[TMP0]], i32 [[CALL]]) | ||
; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] | ||
; | ||
entry: | ||
%tobool.not = icmp eq ptr %a, null | ||
br i1 %tobool.not, label %common.ret6, label %if.end | ||
|
||
common.ret6: ; preds = %entry, %if.end | ||
%common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ -1, %entry ] | ||
ret i32 %common.ret6.op | ||
|
||
if.end: ; preds = %entry | ||
%0 = load i32, ptr %a | ||
%next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 | ||
%1 = load ptr, ptr %next | ||
%call = tail call noundef i32 @umin(ptr noundef %1) | ||
%.sroa.speculated = tail call i32 @llvm.umin.i32(i32 %0, i32 %call) | ||
br label %common.ret6 | ||
} | ||
|
||
define noundef i32 @umax(ptr noundef readonly %a) { | ||
; CHECK-LABEL: define noundef i32 @umax | ||
; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null | ||
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] | ||
; CHECK: common.ret6: | ||
; CHECK-NEXT: ret i32 0 | ||
; CHECK: if.end: | ||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 | ||
; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 | ||
; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @umax(ptr noundef [[TMP1]]) | ||
; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.umax.i32(i32 [[TMP0]], i32 [[CALL]]) | ||
; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] | ||
; | ||
entry: | ||
%tobool.not = icmp eq ptr %a, null | ||
br i1 %tobool.not, label %common.ret6, label %if.end | ||
|
||
common.ret6: ; preds = %entry, %if.end | ||
%common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ 0, %entry ] | ||
ret i32 %common.ret6.op | ||
|
||
if.end: ; preds = %entry | ||
%0 = load i32, ptr %a | ||
%next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 | ||
%1 = load ptr, ptr %next | ||
%call = tail call noundef i32 @umax(ptr noundef %1) | ||
%.sroa.speculated = tail call i32 @llvm.umax.i32(i32 %0, i32 %call) | ||
br label %common.ret6 | ||
} | ||
|
||
define noundef i32 @smin(ptr noundef readonly %a) { | ||
; CHECK-LABEL: define noundef i32 @smin | ||
; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null | ||
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] | ||
; CHECK: common.ret6: | ||
; CHECK-NEXT: ret i32 2147483647 | ||
; CHECK: if.end: | ||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 | ||
; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 | ||
; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @smin(ptr noundef [[TMP1]]) | ||
; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.smin.i32(i32 [[TMP0]], i32 [[CALL]]) | ||
; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] | ||
; | ||
entry: | ||
%tobool.not = icmp eq ptr %a, null | ||
br i1 %tobool.not, label %common.ret6, label %if.end | ||
|
||
common.ret6: ; preds = %entry, %if.end | ||
%common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ 2147483647, %entry ] | ||
ret i32 %common.ret6.op | ||
|
||
if.end: ; preds = %entry | ||
%0 = load i32, ptr %a | ||
%next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 | ||
%1 = load ptr, ptr %next | ||
%call = tail call noundef i32 @smin(ptr noundef %1) | ||
%.sroa.speculated = tail call i32 @llvm.smin.i32(i32 %0, i32 %call) | ||
br label %common.ret6 | ||
} | ||
|
||
define noundef i32 @smax(ptr noundef readonly %a) { | ||
; CHECK-LABEL: define noundef i32 @smax | ||
; CHECK-SAME: (ptr noundef readonly [[A:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq ptr [[A]], null | ||
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[COMMON_RET6:%.*]], label [[IF_END:%.*]] | ||
; CHECK: common.ret6: | ||
; CHECK-NEXT: ret i32 -2147483648 | ||
; CHECK: if.end: | ||
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4 | ||
; CHECK-NEXT: [[NEXT:%.*]] = getelementptr inbounds [[STRUCT_LISTNODE:%.*]], ptr [[A]], i64 0, i32 1 | ||
; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[NEXT]], align 8 | ||
; CHECK-NEXT: [[CALL:%.*]] = tail call noundef i32 @smax(ptr noundef [[TMP1]]) | ||
; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = tail call i32 @llvm.smax.i32(i32 [[TMP0]], i32 [[CALL]]) | ||
; CHECK-NEXT: ret i32 [[DOTSROA_SPECULATED]] | ||
; | ||
entry: | ||
%tobool.not = icmp eq ptr %a, null | ||
br i1 %tobool.not, label %common.ret6, label %if.end | ||
|
||
common.ret6: ; preds = %entry, %if.end | ||
%common.ret6.op = phi i32 [ %.sroa.speculated, %if.end ], [ -2147483648, %entry ] | ||
ret i32 %common.ret6.op | ||
|
||
if.end: ; preds = %entry | ||
%0 = load i32, ptr %a | ||
%next = getelementptr inbounds %struct.ListNode, ptr %a, i64 0, i32 1 | ||
%1 = load ptr, ptr %next | ||
%call = tail call noundef i32 @smax(ptr noundef %1) | ||
%.sroa.speculated = tail call i32 @llvm.smax.i32(i32 %0, i32 %call) | ||
br label %common.ret6 | ||
} | ||
|
||
declare i32 @llvm.umin.i32(i32, i32) | ||
declare i32 @llvm.umax.i32(i32, i32) | ||
declare i32 @llvm.smin.i32(i32, i32) | ||
declare i32 @llvm.smax.i32(i32, i32) |