xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/dagcombine-anyexttozeroext.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple armv7 %s -o - | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f:
4*9880d681SAndroid Build Coastguard Workerdefine float @f(<4 x i16>* nocapture %in) {
5*9880d681SAndroid Build Coastguard Worker  ; CHECK: vld1
6*9880d681SAndroid Build Coastguard Worker  ; CHECK: vmovl.u16
7*9880d681SAndroid Build Coastguard Worker  ; CHECK-NOT: vand
8*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x i16>, <4 x i16>* %in
9*9880d681SAndroid Build Coastguard Worker  ; CHECK: vcvt.f32.u32
10*9880d681SAndroid Build Coastguard Worker  %2 = uitofp <4 x i16> %1 to <4 x float>
11*9880d681SAndroid Build Coastguard Worker  %3 = extractelement <4 x float> %2, i32 0
12*9880d681SAndroid Build Coastguard Worker  %4 = extractelement <4 x float> %2, i32 1
13*9880d681SAndroid Build Coastguard Worker  %5 = extractelement <4 x float> %2, i32 2
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker  ; CHECK: vadd.f32
16*9880d681SAndroid Build Coastguard Worker  %6 = fadd float %3, %4
17*9880d681SAndroid Build Coastguard Worker  %7 = fadd float %6, %5
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker  ret float %7
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: g:
23*9880d681SAndroid Build Coastguard Workerdefine float @g(<4 x i16>* nocapture %in) {
24*9880d681SAndroid Build Coastguard Worker  ; CHECK: vldr
25*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x i16>, <4 x i16>* %in
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker  ; For now we're generating a vmov.16 and a uxth instruction.
28*9880d681SAndroid Build Coastguard Worker  ; The uxth is redundant, and we should be able to extend without
29*9880d681SAndroid Build Coastguard Worker  ; having to generate cross-domain copies. Once we can do this
30*9880d681SAndroid Build Coastguard Worker  ; we should modify the checks below.
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker  ; CHECK: uxth
33*9880d681SAndroid Build Coastguard Worker  %2 = extractelement <4 x i16> %1, i32 0
34*9880d681SAndroid Build Coastguard Worker  ; CHECK: vcvt.f32.u32
35*9880d681SAndroid Build Coastguard Worker  %3 = uitofp i16 %2 to float
36*9880d681SAndroid Build Coastguard Worker  ret float %3
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; The backend generates for the following code an
40*9880d681SAndroid Build Coastguard Worker; (and 0xff (i32 extract_vector_elt (zext load <4 x i8> to 4 x i16)))
41*9880d681SAndroid Build Coastguard Worker;
42*9880d681SAndroid Build Coastguard Worker; The and is not redundant and cannot be removed. Since
43*9880d681SAndroid Build Coastguard Worker; extract_vector_elt is doing an implicit any_ext, the and
44*9880d681SAndroid Build Coastguard Worker; is required to guarantee that the top bits are set to zero.
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; Ideally should be a zext from <4 x i8> to <4 x 32>.
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: h:
49*9880d681SAndroid Build Coastguard Worker; CHECK: vld1.32
50*9880d681SAndroid Build Coastguard Worker; CHECK: uxtb
51*9880d681SAndroid Build Coastguard Workerdefine <4 x i32> @h(<4 x i8> *%in) {
52*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x i8>, <4 x i8>* %in, align 4
53*9880d681SAndroid Build Coastguard Worker  %2 = extractelement <4 x i8> %1, i32 0
54*9880d681SAndroid Build Coastguard Worker  %3 = zext i8 %2 to i32
55*9880d681SAndroid Build Coastguard Worker  %4 = insertelement <4 x i32> undef, i32 %3, i32 0
56*9880d681SAndroid Build Coastguard Worker  %5 = extractelement <4 x i8> %1, i32 1
57*9880d681SAndroid Build Coastguard Worker  %6 = zext i8 %5 to i32
58*9880d681SAndroid Build Coastguard Worker  %7 = insertelement <4 x i32> %4, i32 %6, i32 1
59*9880d681SAndroid Build Coastguard Worker  %8 = extractelement <4 x i8> %1, i32 2
60*9880d681SAndroid Build Coastguard Worker  %9 = zext i8 %8 to i32
61*9880d681SAndroid Build Coastguard Worker  %10 = insertelement <4 x i32> %7, i32 %9, i32 2
62*9880d681SAndroid Build Coastguard Worker  %11 = extractelement <4 x i8> %1, i32 3
63*9880d681SAndroid Build Coastguard Worker  %12 = zext i8 %11 to i32
64*9880d681SAndroid Build Coastguard Worker  %13 = insertelement <4 x i32> %10, i32 %12, i32 3
65*9880d681SAndroid Build Coastguard Worker  ret <4 x i32> %13
66*9880d681SAndroid Build Coastguard Worker}
67