1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 ; REQUIRES: x86-registered-target
5 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
6 target triple = "x86_64-unknown-linux-gnu"
8 ; The returned value should be equal to
11 define noundef i64 @test() {
12 ; CHECK-LABEL: define noundef i64 @test() {
14 ; CHECK-NEXT: br label [[BB3:%.*]]
16 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi i32 [ [[LSR_IV_NEXT:%.*]], [[BB10:%.*]] ], [ -1, [[BB2:%.*]] ]
17 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LSR_IV]], 65536
18 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[TMP0]], 65535
19 ; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[AND]] to i64
20 ; CHECK-NEXT: [[ADD4:%.*]] = add nsw i64 [[ZEXT]], -128
21 ; CHECK-NEXT: [[ICMP5:%.*]] = icmp ult i64 [[ADD4]], -256
22 ; CHECK-NEXT: [[ICMP6:%.*]] = icmp ult i32 [[AND]], 128
23 ; CHECK-NEXT: [[OR:%.*]] = or i1 [[ICMP5]], [[ICMP6]]
24 ; CHECK-NEXT: br i1 [[OR]], label [[BB10]], label [[BB7:%.*]]
26 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[LSR_IV]], 1
27 ; CHECK-NEXT: call void @foo(i32 [[TMP1]])
28 ; CHECK-NEXT: unreachable
30 ; CHECK-NEXT: [[LSR_IV_NEXT]] = add nsw i32 [[LSR_IV]], 1
31 ; CHECK-NEXT: [[ICMP12:%.*]] = icmp ult i32 [[LSR_IV_NEXT]], 1210
32 ; CHECK-NEXT: br i1 [[ICMP12]], label [[BB3]], label [[BB13:%.*]]
34 ; CHECK-NEXT: ret i64 [[ZEXT]]
39 bb3: ; preds = %bb10, %bb2
40 %phi = phi i32 [ 0, %bb2 ], [ %add11, %bb10 ]
41 %add = add nuw nsw i32 %phi, 65535
42 %and = and i32 %add, 65535
43 %zext = zext i32 %and to i64
44 %add4 = add nsw i64 %zext, -128
45 %icmp5 = icmp ult i64 %add4, -256
46 %icmp6 = icmp ult i32 %and, 128
47 %or = or i1 %icmp5, %icmp6
48 br i1 %or, label %bb10, label %bb7
51 call void @foo(i32 %phi)
55 %add11 = add nuw nsw i32 %phi, 1
56 %icmp12 = icmp ult i32 %phi, 1210
57 br i1 %icmp12, label %bb3, label %bb13
62 uselistorder i32 %phi, { 0, 3, 1, 2 }
65 declare void @foo(i32)