1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 -ppc-convert-rr-to-ri=false -ppc-asm-full-reg-names < %s | FileCheck %s
4 ; ISEL matches address mode xaddr.
5 define i8 @test_xaddr(i8* %p) {
6 ; CHECK-LABEL: test_xaddr:
7 ; CHECK: # %bb.0: # %entry
9 ; CHECK-NEXT: ori r4, r4, 40000
10 ; CHECK-NEXT: std r3, -8(r1)
11 ; CHECK-NEXT: lbzx r3, r3, r4
14 %p.addr = alloca i8*, align 8
15 store i8* %p, i8** %p.addr, align 8
16 %0 = load i8*, i8** %p.addr, align 8
17 %add.ptr = getelementptr inbounds i8, i8* %0, i64 40000
18 %1 = load i8, i8* %add.ptr, align 1
22 ; ISEL matches address mode xaddrX4.
23 define i64 @test_xaddrX4(i8* %p) {
24 ; CHECK-LABEL: test_xaddrX4:
25 ; CHECK: # %bb.0: # %entry
26 ; CHECK-NEXT: li r4, 3
27 ; CHECK-NEXT: std r3, -8(r1)
28 ; CHECK-NEXT: ldx r3, r3, r4
31 %p.addr = alloca i8*, align 8
32 store i8* %p, i8** %p.addr, align 8
33 %0 = load i8*, i8** %p.addr, align 8
34 %add.ptr = getelementptr inbounds i8, i8* %0, i64 3
35 %1 = bitcast i8* %add.ptr to i64*
36 %2 = load i64, i64* %1, align 8
40 ; ISEL matches address mode xaddrX16.
41 define <2 x double> @test_xaddrX16(double* %arr) {
42 ; CHECK-LABEL: test_xaddrX16:
43 ; CHECK: # %bb.0: # %entry
44 ; CHECK-NEXT: li r4, 40
45 ; CHECK-NEXT: lxvx vs34, r3, r4
48 %arrayidx1 = getelementptr inbounds double, double* %arr, i64 5
49 %0 = bitcast double* %arrayidx1 to <2 x double>*
50 %1 = load <2 x double>, <2 x double>* %0, align 16
54 ; ISEL matches address mode xoaddr.
55 define void @test_xoaddr(i32* %arr, i32* %arrTo) {
56 ; CHECK-LABEL: test_xoaddr:
57 ; CHECK: # %bb.0: # %entry
58 ; CHECK-NEXT: addi r3, r3, 8
59 ; CHECK-NEXT: lxvx vs0, 0, r3
60 ; CHECK-NEXT: addi r4, r4, 4
61 ; CHECK-NEXT: stxvx vs0, 0, r4
64 %arrayidx = getelementptr inbounds i32, i32* %arrTo, i64 1
65 %0 = bitcast i32* %arrayidx to <4 x i32>*
66 %arrayidx1 = getelementptr inbounds i32, i32* %arr, i64 2
67 %1 = bitcast i32* %arrayidx1 to <4 x i32>*
68 %2 = load <4 x i32>, <4 x i32>* %1, align 8
69 store <4 x i32> %2, <4 x i32>* %0, align 8
73 ; ISEL matches address mode xaddrX4 and generates LI which can be moved outside of
75 define i64 @test_xaddrX4_loop(i8* %p) {
76 ; CHECK-LABEL: test_xaddrX4_loop:
77 ; CHECK: # %bb.0: # %entry
78 ; CHECK-NEXT: addi r4, r3, -8
79 ; CHECK-NEXT: li r3, 8
80 ; CHECK-NEXT: mtctr r3
81 ; CHECK-NEXT: li r3, 0
82 ; CHECK-NEXT: li r5, 3
83 ; loop instruction number is changed from 5 to 4, so its align is changed from 5 to 4.
84 ; CHECK-NEXT: .p2align 4
85 ; CHECK-NEXT: .LBB4_1: # %for.body
86 ; CHECK: ldu r6, 8(r4)
87 ; CHECK-NEXT: ldx r7, r4, r5
88 ; CHECK-NEXT: maddld r3, r7, r6, r3
89 ; CHECK-NEXT: bdnz .LBB4_1
90 ; CHECK-NEXT: # %bb.2: # %for.end
95 for.body: ; preds = %for.body, %entry
96 %i.015 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
97 %res.014 = phi i64 [ 0, %entry ], [ %add, %for.body ]
98 %mul = shl i64 %i.015, 3
99 %add.ptr = getelementptr inbounds i8, i8* %p, i64 %mul
100 %0 = bitcast i8* %add.ptr to i64*
101 %1 = load i64, i64* %0, align 8
102 %add.ptr3 = getelementptr inbounds i8, i8* %add.ptr, i64 3
103 %2 = bitcast i8* %add.ptr3 to i64*
104 %3 = load i64, i64* %2, align 8
105 %mul4 = mul i64 %3, %1
106 %add = add i64 %mul4, %res.014
107 %inc = add nuw nsw i64 %i.015, 1
108 %exitcond = icmp eq i64 %inc, 8
109 br i1 %exitcond, label %for.end, label %for.body
111 for.end: ; preds = %for.body