1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=indvars < %s | FileCheck %s
5 ; CHECK-LABEL: define i32 @test() {
6 ; CHECK-NEXT: [[ENTRY:.*:]]
7 ; CHECK-NEXT: [[XOR:%.*]] = xor i32 0, 3
8 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[XOR]], 329
9 ; CHECK-NEXT: [[CONV:%.*]] = trunc i32 [[MUL]] to i16
10 ; CHECK-NEXT: [[SEXT:%.*]] = shl i16 [[CONV]], 8
11 ; CHECK-NEXT: [[CONV1:%.*]] = ashr i16 [[SEXT]], 8
12 ; CHECK-NEXT: br label %[[LOOP_BODY:.*]]
13 ; CHECK: [[LOOP_BODY]]:
14 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[LOOP_BODY]]
16 ; CHECK-NEXT: [[CONV3:%.*]] = zext i16 [[CONV1]] to i32
17 ; CHECK-NEXT: ret i32 [[CONV3]]
21 %mul = mul i32 %xor, 329
22 %conv = trunc i32 %mul to i16
23 %sext = shl i16 %conv, 8
24 %conv1 = ashr i16 %sext, 8
25 %conv3 = zext i16 %conv1 to i32
29 %indvar = phi i32 [ %indvar.inc, %loop.body ], [ 1, %entry ]
30 %indvar.inc = add nuw i32 %indvar, 1
31 %exitcond = icmp eq i32 %indvar, %conv3
32 br i1 %exitcond, label %exit, label %loop.body