; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=typepromotion -mtriple=aarch64 %s -o - | FileCheck %s
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
define dso_local noundef i1 @_Z10find_shortPssj(ptr nocapture noundef readonly %0, i16 noundef %1, i32 noundef %2) {
; CHECK-LABEL: @_Z10find_shortPssj(
; CHECK-NEXT: [[TMP4:%.*]] = zext i16 [[TMP1:%.*]] to i32
; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[TMP2:%.*]], 0
; CHECK-NEXT: br i1 [[TMP5]], label [[TMP22:%.*]], label [[TMP6:%.*]]
; CHECK: 6:
; CHECK-NEXT: [[TMP7:%.*]] = zext i32 [[TMP2]] to i64
; CHECK-NEXT: [[TMP8:%.*]] = load i16, ptr [[TMP0:%.*]], align 2
; CHECK-NEXT: [[TMP9:%.*]] = zext i16 [[TMP8]] to i32
; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i32 [[TMP9]], [[TMP4]]
; CHECK-NEXT: br i1 [[TMP10]], label [[TMP22]], label [[TMP11:%.*]]
; CHECK: 11:
; CHECK-NEXT: [[TMP12:%.*]] = phi i64 [ [[TMP13:%.*]], [[TMP15:%.*]] ], [ 0, [[TMP6]] ]
; CHECK-NEXT: [[TMP13]] = add nuw nsw i64 [[TMP12]], 1
; CHECK-NEXT: [[TMP14:%.*]] = icmp eq i64 [[TMP13]], [[TMP7]]
; CHECK-NEXT: br i1 [[TMP14]], label [[TMP20:%.*]], label [[TMP15]]
; CHECK: 15:
; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds i16, ptr [[TMP0]], i64 [[TMP13]]
; CHECK-NEXT: [[TMP17:%.*]] = load i16, ptr [[TMP16]], align 2
; CHECK-NEXT: [[TMP18:%.*]] = zext i16 [[TMP17]] to i32
; CHECK-NEXT: [[TMP19:%.*]] = icmp eq i32 [[TMP18]], [[TMP4]]
; CHECK-NEXT: br i1 [[TMP19]], label [[TMP20]], label [[TMP11]]
; CHECK: 20:
; CHECK-NEXT: [[TMP21:%.*]] = icmp ult i64 [[TMP13]], [[TMP7]]
; CHECK-NEXT: br label [[TMP22]]
; CHECK: 22:
; CHECK-NEXT: [[TMP23:%.*]] = phi i1 [ false, [[TMP3:%.*]] ], [ true, [[TMP6]] ], [ [[TMP21]], [[TMP20]] ]
; CHECK-NEXT: ret i1 [[TMP23]]
;
%4 = icmp eq i32 %2, 0
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = load i16, ptr %0, align 2
%8 = icmp eq i16 %7, %1
br i1 %8, label %19, label %9
9: ; preds = %5, %13
%10 = phi i64 [ %11, %13 ], [ 0, %5 ]
%11 = add nuw nsw i64 %10, 1
%12 = icmp eq i64 %11, %6
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = getelementptr inbounds i16, ptr %0, i64 %11
%15 = load i16, ptr %14, align 2
%16 = icmp eq i16 %15, %1
br i1 %16, label %17, label %9
17: ; preds = %9, %13
%18 = icmp ult i64 %11, %6
br label %19
19: ; preds = %17, %5, %3
%20 = phi i1 [ false, %3 ], [ true, %5 ], [ %18, %17 ]
ret i1 %20
}
define dso_local noundef i1 @_Z9find_charPccj(ptr nocapture noundef readonly %0, i8 noundef %1, i32 noundef %2) {
; CHECK-LABEL: @_Z9find_charPccj(
; CHECK-NEXT: [[TMP4:%.*]] = zext i8 [[TMP1:%.*]] to i32
; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[TMP2:%.*]], 0
; CHECK-NEXT: br i1 [[TMP5]], label [[TMP22:%.*]], label [[TMP6:%.*]]
; CHECK: 6:
; CHECK-NEXT: [[TMP7:%.*]] = zext i32 [[TMP2]] to i64
; CHECK-NEXT: [[TMP8:%.*]] = load i8, ptr [[TMP0:%.*]], align 1
; CHECK-NEXT: [[TMP9:%.*]] = zext i8 [[TMP8]] to i32
; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i32 [[TMP9]], [[TMP4]]
; CHECK-NEXT: br i1 [[TMP10]], label [[TMP22]], label [[TMP11:%.*]]
; CHECK: 11:
; CHECK-NEXT: [[TMP12:%.*]] = phi i64 [ [[TMP13:%.*]], [[TMP15:%.*]] ], [ 0, [[TMP6]] ]
; CHECK-NEXT: [[TMP13]] = add nuw nsw i64 [[TMP12]], 1
; CHECK-NEXT: [[TMP14:%.*]] = icmp eq i64 [[TMP13]], [[TMP7]]
; CHECK-NEXT: br i1 [[TMP14]], label [[TMP20:%.*]], label [[TMP15]]
; CHECK: 15:
; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i64 [[TMP13]]
; CHECK-NEXT: [[TMP17:%.*]] = load i8, ptr [[TMP16]], align 1
; CHECK-NEXT: [[TMP18:%.*]] = zext i8 [[TMP17]] to i32
; CHECK-NEXT: [[TMP19:%.*]] = icmp eq i32 [[TMP18]], [[TMP4]]
; CHECK-NEXT: br i1 [[TMP19]], label [[TMP20]], label [[TMP11]]
; CHECK: 20:
; CHECK-NEXT: [[TMP21:%.*]] = icmp ult i64 [[TMP13]], [[TMP7]]
; CHECK-NEXT: br label [[TMP22]]
; CHECK: 22:
; CHECK-NEXT: [[TMP23:%.*]] = phi i1 [ false, [[TMP3:%.*]] ], [ true, [[TMP6]] ], [ [[TMP21]], [[TMP20]] ]
; CHECK-NEXT: ret i1 [[TMP23]]
;
%4 = icmp eq i32 %2, 0
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = load i8, ptr %0, align 1
%8 = icmp eq i8 %7, %1
br i1 %8, label %19, label %9
9: ; preds = %5, %13
%10 = phi i64 [ %11, %13 ], [ 0, %5 ]
%11 = add nuw nsw i64 %10, 1
%12 = icmp eq i64 %11, %6
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, ptr %0, i64 %11
%15 = load i8, ptr %14, align 1
%16 = icmp eq i8 %15, %1
br i1 %16, label %17, label %9
17: ; preds = %9, %13
%18 = icmp ult i64 %11, %6
br label %19
19: ; preds = %17, %5, %3
%20 = phi i1 [ false, %3 ], [ true, %5 ], [ %18, %17 ]
ret i1 %20
}