1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt %s -S -passes='simplifycfg<switch-to-lookup>' -simplifycfg-require-and-preserve-domtree=1 -switch-range-to-icmp | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 define i64 @test_1(i64 %0) {
7 ; CHECK-LABEL: define i64 @test_1(
8 ; CHECK-SAME: i64 [[TMP0:%.*]]) {
9 ; CHECK-NEXT: switch.lookup:
10 ; CHECK-NEXT: [[TMP1:%.*]] = urem i64 [[TMP0]], 4
11 ; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [4 x i64], ptr @switch.table.test_1, i32 0, i64 [[TMP1]]
12 ; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]], align 8
13 ; CHECK-NEXT: ret i64 [[SWITCH_LOAD]]
16 switch i64 %2, label %5 [
29 %.0 = phi i64 [ 2, %4 ], [ 1, %3 ], [ 0, %1 ]
34 define i64 @test_2(i64 %0) {
35 ; CHECK-LABEL: define i64 @test_2(
36 ; CHECK-SAME: i64 [[TMP0:%.*]]) {
37 ; CHECK-NEXT: switch.lookup:
38 ; CHECK-NEXT: [[TMP1:%.*]] = urem i64 [[TMP0]], 4
39 ; CHECK-NEXT: ret i64 [[TMP1]]
42 switch i64 %2, label %6 [
58 %.0 = phi i64 [ 0, %1 ], [ 1, %3 ], [ 2, %4 ], [ 3, %5 ]