xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-fold-lsl.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=arm64 -aarch64-neon-syntax=apple | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; <rdar://problem/14486451>
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker%struct.a = type [256 x i16]
6*9880d681SAndroid Build Coastguard Worker%struct.b = type [256 x i32]
7*9880d681SAndroid Build Coastguard Worker%struct.c = type [256 x i64]
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine i16 @load_halfword(%struct.a* %ctx, i32 %xor72) nounwind {
10*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: load_halfword:
11*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
12*9880d681SAndroid Build Coastguard Worker; CHECK: ldrh w0, [x0, [[REG]], lsl #1]
13*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
14*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
15*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
16*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.a, %struct.a* %ctx, i64 0, i64 %idxprom83
17*9880d681SAndroid Build Coastguard Worker  %result = load i16, i16* %arrayidx86, align 2
18*9880d681SAndroid Build Coastguard Worker  ret i16 %result
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerdefine i32 @load_word(%struct.b* %ctx, i32 %xor72) nounwind {
22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: load_word:
23*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
24*9880d681SAndroid Build Coastguard Worker; CHECK: ldr w0, [x0, [[REG]], lsl #2]
25*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
26*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
27*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
28*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.b, %struct.b* %ctx, i64 0, i64 %idxprom83
29*9880d681SAndroid Build Coastguard Worker  %result = load i32, i32* %arrayidx86, align 4
30*9880d681SAndroid Build Coastguard Worker  ret i32 %result
31*9880d681SAndroid Build Coastguard Worker}
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workerdefine i64 @load_doubleword(%struct.c* %ctx, i32 %xor72) nounwind {
34*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: load_doubleword:
35*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
36*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x0, [x0, [[REG]], lsl #3]
37*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
38*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
39*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
40*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.c, %struct.c* %ctx, i64 0, i64 %idxprom83
41*9880d681SAndroid Build Coastguard Worker  %result = load i64, i64* %arrayidx86, align 8
42*9880d681SAndroid Build Coastguard Worker  ret i64 %result
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerdefine void @store_halfword(%struct.a* %ctx, i32 %xor72, i16 %val) nounwind {
46*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: store_halfword:
47*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
48*9880d681SAndroid Build Coastguard Worker; CHECK: strh w2, [x0, [[REG]], lsl #1]
49*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
50*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
51*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
52*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.a, %struct.a* %ctx, i64 0, i64 %idxprom83
53*9880d681SAndroid Build Coastguard Worker  store i16 %val, i16* %arrayidx86, align 8
54*9880d681SAndroid Build Coastguard Worker  ret void
55*9880d681SAndroid Build Coastguard Worker}
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Workerdefine void @store_word(%struct.b* %ctx, i32 %xor72, i32 %val) nounwind {
58*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: store_word:
59*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
60*9880d681SAndroid Build Coastguard Worker; CHECK: str w2, [x0, [[REG]], lsl #2]
61*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
62*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
63*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
64*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.b, %struct.b* %ctx, i64 0, i64 %idxprom83
65*9880d681SAndroid Build Coastguard Worker  store i32 %val, i32* %arrayidx86, align 8
66*9880d681SAndroid Build Coastguard Worker  ret void
67*9880d681SAndroid Build Coastguard Worker}
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerdefine void @store_doubleword(%struct.c* %ctx, i32 %xor72, i64 %val) nounwind {
70*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: store_doubleword:
71*9880d681SAndroid Build Coastguard Worker; CHECK: ubfx [[REG:x[0-9]+]], x1, #9, #8
72*9880d681SAndroid Build Coastguard Worker; CHECK: str x2, [x0, [[REG]], lsl #3]
73*9880d681SAndroid Build Coastguard Worker  %shr81 = lshr i32 %xor72, 9
74*9880d681SAndroid Build Coastguard Worker  %conv82 = zext i32 %shr81 to i64
75*9880d681SAndroid Build Coastguard Worker  %idxprom83 = and i64 %conv82, 255
76*9880d681SAndroid Build Coastguard Worker  %arrayidx86 = getelementptr inbounds %struct.c, %struct.c* %ctx, i64 0, i64 %idxprom83
77*9880d681SAndroid Build Coastguard Worker  store i64 %val, i64* %arrayidx86, align 8
78*9880d681SAndroid Build Coastguard Worker  ret void
79*9880d681SAndroid Build Coastguard Worker}
80