xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/unaligned-spill-folding.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -relocation-model=pic < %s | FileCheck %s -check-prefix=UNALIGNED
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=16 -relocation-model=pic < %s | FileCheck %s -check-prefix=ALIGNED
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=i386-unknown-freebsd -mcpu=core2 -stack-alignment=4 -stackrealign -relocation-model=pic < %s | FileCheck %s -check-prefix=FORCEALIGNED
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker@arr = internal unnamed_addr global [32 x i32] zeroinitializer, align 16
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; PR12250
8*9880d681SAndroid Build Coastguard Workerdefine i32 @test1() {
9*9880d681SAndroid Build Coastguard Workervector.ph:
10*9880d681SAndroid Build Coastguard Worker  br label %vector.body
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workervector.body:
13*9880d681SAndroid Build Coastguard Worker  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
14*9880d681SAndroid Build Coastguard Worker  %0 = getelementptr inbounds [32 x i32], [32 x i32]* @arr, i32 0, i32 %index
15*9880d681SAndroid Build Coastguard Worker  %1 = bitcast i32* %0 to <4 x i32>*
16*9880d681SAndroid Build Coastguard Worker  %wide.load = load <4 x i32>, <4 x i32>* %1, align 16
17*9880d681SAndroid Build Coastguard Worker  %2 = add nsw <4 x i32> %wide.load, <i32 10, i32 10, i32 10, i32 10>
18*9880d681SAndroid Build Coastguard Worker  %3 = xor <4 x i32> %2, <i32 123345, i32 123345, i32 123345, i32 123345>
19*9880d681SAndroid Build Coastguard Worker  %4 = add nsw <4 x i32> %3, <i32 112, i32 112, i32 112, i32 112>
20*9880d681SAndroid Build Coastguard Worker  %5 = xor <4 x i32> %4, <i32 543345, i32 543345, i32 543345, i32 543345>
21*9880d681SAndroid Build Coastguard Worker  %6 = add nsw <4 x i32> %5, <i32 73, i32 73, i32 73, i32 73>
22*9880d681SAndroid Build Coastguard Worker  %7 = xor <4 x i32> %6, <i32 345987, i32 345987, i32 345987, i32 345987>
23*9880d681SAndroid Build Coastguard Worker  %8 = add nsw <4 x i32> %7, <i32 48, i32 48, i32 48, i32 48>
24*9880d681SAndroid Build Coastguard Worker  %9 = xor <4 x i32> %8, <i32 123987, i32 123987, i32 123987, i32 123987>
25*9880d681SAndroid Build Coastguard Worker  store <4 x i32> %9, <4 x i32>* %1, align 16
26*9880d681SAndroid Build Coastguard Worker  %index.next = add i32 %index, 4
27*9880d681SAndroid Build Coastguard Worker  %10 = icmp eq i32 %index.next, 32
28*9880d681SAndroid Build Coastguard Worker  br i1 %10, label %middle.block, label %vector.body
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workermiddle.block:
31*9880d681SAndroid Build Coastguard Worker  ret i32 0
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker; We can't fold the spill into a padd unless the stack is aligned. Just spilling
34*9880d681SAndroid Build Coastguard Worker; doesn't force stack realignment though
35*9880d681SAndroid Build Coastguard Worker; UNALIGNED-LABEL: @test1
36*9880d681SAndroid Build Coastguard Worker; UNALIGNED-NOT: andl $-{{..}}, %esp
37*9880d681SAndroid Build Coastguard Worker; UNALIGNED: movdqu {{.*}} # 16-byte Folded Spill
38*9880d681SAndroid Build Coastguard Worker; UNALIGNED-NOT: paddd {{.*}} # 16-byte Folded Reload
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker; ALIGNED-LABEL: @test1
41*9880d681SAndroid Build Coastguard Worker; ALIGNED-NOT: andl $-{{..}}, %esp
42*9880d681SAndroid Build Coastguard Worker; ALIGNED: movdqa {{.*}} # 16-byte Spill
43*9880d681SAndroid Build Coastguard Worker; ALIGNED: paddd {{.*}} # 16-byte Folded Reload
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; FORCEALIGNED-LABEL: @test1
46*9880d681SAndroid Build Coastguard Worker; FORCEALIGNED: andl $-{{..}}, %esp
47*9880d681SAndroid Build Coastguard Worker; FORCEALIGNED: movdqa {{.*}} # 16-byte Spill
48*9880d681SAndroid Build Coastguard Worker; FORCEALIGNED: paddd {{.*}} # 16-byte Folded Reload
49*9880d681SAndroid Build Coastguard Worker}
50