1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - -verify-machineinstrs | FileCheck %s
4 # This test checks the optimization to remove the G_TRUNC if we can determine it's redundant.
6 name: icmp_trunc_sextload
7 tracksRegLiveness: true
12 ; CHECK-LABEL: name: icmp_trunc_sextload
14 ; CHECK: %v:_(p0) = COPY $x0
15 ; CHECK: %load:_(s64) = G_SEXTLOAD %v(p0) :: (load (s32))
16 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
17 ; CHECK: %cmp:_(s1) = G_ICMP intpred(ne), %load(s64), [[C]]
18 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT %cmp(s1)
19 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
20 ; CHECK: RET_ReallyLR implicit $w0
22 %load:_(s64) = G_SEXTLOAD %v:_(p0) :: (load (s32))
23 %trunc:_(s32) = G_TRUNC %load(s64)
24 %zero:_(s32) = G_CONSTANT i32 0
25 %cmp:_(s1) = G_ICMP intpred(ne), %trunc(s32), %zero
26 %5:_(s32) = G_ANYEXT %cmp
28 RET_ReallyLR implicit $w0
31 name: icmp_trunc_sextload_eq
32 tracksRegLiveness: true
37 ; CHECK-LABEL: name: icmp_trunc_sextload_eq
39 ; CHECK: %v:_(p0) = COPY $x0
40 ; CHECK: %load:_(s64) = G_SEXTLOAD %v(p0) :: (load (s32))
41 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
42 ; CHECK: %cmp:_(s1) = G_ICMP intpred(eq), %load(s64), [[C]]
43 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT %cmp(s1)
44 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
45 ; CHECK: RET_ReallyLR implicit $w0
47 %load:_(s64) = G_SEXTLOAD %v:_(p0) :: (load (s32))
48 %trunc:_(s32) = G_TRUNC %load(s64)
49 %zero:_(s32) = G_CONSTANT i32 0
50 %cmp:_(s1) = G_ICMP intpred(eq), %trunc(s32), %zero
51 %5:_(s32) = G_ANYEXT %cmp
53 RET_ReallyLR implicit $w0
56 name: icmp_trunc_sextload_wrongpred
57 tracksRegLiveness: true
62 ; CHECK-LABEL: name: icmp_trunc_sextload_wrongpred
64 ; CHECK: %v:_(p0) = COPY $x0
65 ; CHECK: %load:_(s64) = G_SEXTLOAD %v(p0) :: (load (s32))
66 ; CHECK: %trunc:_(s32) = G_TRUNC %load(s64)
67 ; CHECK: %zero:_(s32) = G_CONSTANT i32 0
68 ; CHECK: %cmp:_(s1) = G_ICMP intpred(slt), %trunc(s32), %zero
69 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT %cmp(s1)
70 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
71 ; CHECK: RET_ReallyLR implicit $w0
73 %load:_(s64) = G_SEXTLOAD %v:_(p0) :: (load (s32))
74 %trunc:_(s32) = G_TRUNC %load(s64)
75 %zero:_(s32) = G_CONSTANT i32 0
76 %cmp:_(s1) = G_ICMP intpred(slt), %trunc(s32), %zero
77 %5:_(s32) = G_ANYEXT %cmp
79 RET_ReallyLR implicit $w0
82 name: icmp_trunc_sextload_extend_mismatch
83 tracksRegLiveness: true
88 ; CHECK-LABEL: name: icmp_trunc_sextload_extend_mismatch
90 ; CHECK: %v:_(p0) = COPY $x0
91 ; CHECK: %load:_(s64) = G_SEXTLOAD %v(p0) :: (load (s32))
92 ; CHECK: %trunc:_(s16) = G_TRUNC %load(s64)
93 ; CHECK: %zero:_(s16) = G_CONSTANT i16 0
94 ; CHECK: %cmp:_(s1) = G_ICMP intpred(ne), %trunc(s16), %zero
95 ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT %cmp(s1)
96 ; CHECK: $w0 = COPY [[ANYEXT]](s32)
97 ; CHECK: RET_ReallyLR implicit $w0
99 %load:_(s64) = G_SEXTLOAD %v:_(p0) :: (load (s32))
100 %trunc:_(s16) = G_TRUNC %load(s64)
101 %zero:_(s16) = G_CONSTANT i16 0
102 %cmp:_(s1) = G_ICMP intpred(ne), %trunc(s16), %zero
103 %5:_(s32) = G_ANYEXT %cmp
105 RET_ReallyLR implicit $w0