1 ; RUN: llc -mtriple=thumbv7m -arm-disable-cgp=false %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=thumbv8m.main -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: sxtb [[SXT:r[0-9]+]], [[LDR]]
49 ; CHECK: cm{{.*}} [[SXT]]
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_h
60 ; CHECK: ldrh [[LDR:r[0-9]+]], [r0]
61 ; CHECK: sxth [[SXT:r[0-9]+]], [[LDR]]
62 ; CHECK: cm{{.*}} [[SXT]]
63 define i32 @test_signext_h(i16* %ptr, i16 signext %arg) {
65 %0 = load i16, i16* %ptr, align 1
66 %1 = add nuw nsw i16 %0, %arg
67 %cmp = icmp ult i16 %1, 32768
68 %res = select i1 %cmp, i32 42, i32 20894