1 ; RUN: llc -mtriple=thumbv7em -arm-disable-cgp=false %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=thumbv8m.main -mattr=+dsp -arm-disable-cgp=false %s -o - | FileCheck %s
3 ; RUN: llc -mtriple=thumbv7 %s -arm-disable-cgp=false -o - | FileCheck %s
4 ; RUN: llc -mtriple=armv8 %s -arm-disable-cgp=false -o - | FileCheck %s
6 ; Test to check that ARMCodeGenPrepare doesn't optimised away sign extends.
7 ; CHECK-LABEL: test_signed_load:
9 define i16 @test_signed_load(i16* %ptr) {
10 %load = load i16, i16* %ptr
11 %conv0 = zext i16 %load to i32
12 %conv1 = sext i16 %load to i32
13 %cmp = icmp eq i32 %conv0, %conv1
14 %conv2 = zext i1 %cmp to i16
18 ; Don't allow sign bit generating opcodes.
19 ; CHECK-LABEL: test_ashr:
21 define i16 @test_ashr(i16 zeroext %arg) {
22 %ashr = ashr i16 %arg, 1
23 %cmp = icmp eq i16 %ashr, 0
24 %conv = zext i1 %cmp to i16
28 ; CHECK-LABEL: test_sdiv:
30 define i16 @test_sdiv(i16 zeroext %arg) {
31 %sdiv = sdiv i16 %arg, 2
32 %cmp = icmp ne i16 %sdiv, 0
33 %conv = zext i1 %cmp to i16
37 ; CHECK-LABEL: test_srem
39 define i16 @test_srem(i16 zeroext %arg) {
40 %srem = srem i16 %arg, 4
41 %cmp = icmp ne i16 %srem, 0
42 %conv = zext i1 %cmp to i16
46 ; CHECK-LABEL: test_signext_b
47 ; CHECK: ldrb [[LDR:r[0-9]+]], [r0]
48 ; CHECK: uxtab [[UXT:r[0-9]+]], [[LDR]], r1
49 ; CHECK: cm{{.*}} [[UXT]], #128
50 define i32 @test_signext_b(i8* %ptr, i8 signext %arg) {
52 %0 = load i8, i8* %ptr, align 1
53 %1 = add nuw nsw i8 %0, %arg
54 %cmp = icmp ult i8 %1, 128
55 %res = select i1 %cmp, i32 42, i32 20894
59 ; CHECK-LABEL: test_signext_b_ult_slt
60 ; CHECK: ldrb [[LDR:r[0-9]+]], [r0]
61 ; CHECK: uxtab [[ADD:r[0-9]+]], [[LDR]], r1
62 ; CHECK: uxtb [[UXT:r[0-9]+]], r1
63 ; CHECK: cmp [[ADD]], [[UXT]]
64 ; CHECK: uxtb [[TRUNC:r[0-9]+]], [[ADD]]
65 ; CHECK: cmp [[TRUNC]], #127
66 define i32 @test_signext_b_ult_slt(i8* %ptr, i8 signext %arg) {
68 %0 = load i8, i8* %ptr, align 1
69 %1 = add nuw nsw i8 %0, %arg
70 %cmp = icmp sle i8 %1, 126
71 %cmp.1 = icmp ule i8 %1, %arg
72 %or = and i1 %cmp, %cmp.1
73 %res = select i1 %or, i32 42, i32 57
77 ; CHECK-LABEL: test_signext_h
78 ; CHECK: ldrh [[LDR:r[0-9]+]], [r0]
79 ; CHECK: uxtah [[ADD:r[0-9]+]], [[LDR]], r1
80 ; CHECK: cm{{.*}} [[ADD]],
81 define i32 @test_signext_h(i16* %ptr, i16 signext %arg) {
83 %0 = load i16, i16* %ptr, align 1
84 %1 = add nuw nsw i16 %0, %arg
85 %cmp = icmp ult i16 %1, 32768
86 %res = select i1 %cmp, i32 42, i32 20894