1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 < %s | FileCheck -check-prefix=CHECK-P9 %s 3; RUN: llc -relocation-model=pic -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck -check-prefix=CHECK-P8 %s 4 5; As the constant could be represented as float, a float is 6; loaded from constant pool. 7define double @doubleConstant1() { 8; CHECK-P9-LABEL: doubleConstant1: 9; CHECK-P9: # %bb.0: 10; CHECK-P9-NEXT: addis 3, 2, .LCPI0_0@toc@ha 11; CHECK-P9-NEXT: lfs 1, .LCPI0_0@toc@l(3) 12; CHECK-P9-NEXT: blr 13; 14; CHECK-P8-LABEL: doubleConstant1: 15; CHECK-P8: # %bb.0: 16; CHECK-P8-NEXT: addis 3, 2, .LCPI0_0@toc@ha 17; CHECK-P8-NEXT: lfs 1, .LCPI0_0@toc@l(3) 18; CHECK-P8-NEXT: blr 19 ret double 1.400000e+01 20} 21 22; As the constant couldn't be represented as float, a double is 23; loaded from constant pool. 24define double @doubleConstant2() { 25; CHECK-P9-LABEL: doubleConstant2: 26; CHECK-P9: # %bb.0: 27; CHECK-P9-NEXT: addis 3, 2, .LCPI1_0@toc@ha 28; CHECK-P9-NEXT: lfd 1, .LCPI1_0@toc@l(3) 29; CHECK-P9-NEXT: blr 30; 31; CHECK-P8-LABEL: doubleConstant2: 32; CHECK-P8: # %bb.0: 33; CHECK-P8-NEXT: addis 3, 2, .LCPI1_0@toc@ha 34; CHECK-P8-NEXT: lfd 1, .LCPI1_0@toc@l(3) 35; CHECK-P8-NEXT: blr 36 ret double 2.408904e+01 37} 38 39@FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4 40 41define float @floatConstantArray() local_unnamed_addr { 42; CHECK-P9-LABEL: floatConstantArray: 43; CHECK-P9: # %bb.0: 44; CHECK-P9-NEXT: addis 3, 2, FArr@toc@ha+12 45; CHECK-P9-NEXT: lfs 0, FArr@toc@l+12(3) 46; CHECK-P9-NEXT: addis 3, 2, .LCPI2_0@toc@ha 47; CHECK-P9-NEXT: lfs 1, .LCPI2_0@toc@l(3) 48; CHECK-P9-NEXT: xsaddsp 1, 0, 1 49; CHECK-P9-NEXT: blr 50; 51; CHECK-P8-LABEL: floatConstantArray: 52; CHECK-P8: # %bb.0: 53; CHECK-P8-NEXT: addis 3, 2, FArr@toc@ha 54; CHECK-P8-NEXT: addis 4, 2, .LCPI2_0@toc@ha 55; CHECK-P8-NEXT: addi 3, 3, FArr@toc@l 56; CHECK-P8-NEXT: lfs 1, .LCPI2_0@toc@l(4) 57; CHECK-P8-NEXT: lfs 0, 12(3) 58; CHECK-P8-NEXT: xsaddsp 1, 0, 1 59; CHECK-P8-NEXT: blr 60 %1 = load float, float* getelementptr inbounds ([10 x float], [10 x float]* @FArr, i64 0, i64 3), align 4 61 %2 = fadd float %1, 0x400B333340000000 62 ret float %2 63} 64 65define float @floatConstant() { 66; CHECK-P9-LABEL: floatConstant: 67; CHECK-P9: # %bb.0: 68; CHECK-P9-NEXT: addis 3, 2, .LCPI3_0@toc@ha 69; CHECK-P9-NEXT: lfs 1, .LCPI3_0@toc@l(3) 70; CHECK-P9-NEXT: blr 71; 72; CHECK-P8-LABEL: floatConstant: 73; CHECK-P8: # %bb.0: 74; CHECK-P8-NEXT: addis 3, 2, .LCPI3_0@toc@ha 75; CHECK-P8-NEXT: lfs 1, .LCPI3_0@toc@l(3) 76; CHECK-P8-NEXT: blr 77 ret float 0x400470A3E0000000 78} 79 80; llvm put the hidden globals into the TOC table. 81; TODO - do some analysis and decide which globals could be put into TOC. 82@d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8 83 84define double @doubleConstantArray() { 85; CHECK-P9-LABEL: doubleConstantArray: 86; CHECK-P9: # %bb.0: 87; CHECK-P9-NEXT: addis 3, 2, d@toc@ha+24 88; CHECK-P9-NEXT: lfd 0, d@toc@l+24(3) 89; CHECK-P9-NEXT: addis 3, 2, .LCPI4_0@toc@ha 90; CHECK-P9-NEXT: lfd 1, .LCPI4_0@toc@l(3) 91; CHECK-P9-NEXT: xsadddp 1, 0, 1 92; CHECK-P9-NEXT: blr 93; 94; CHECK-P8-LABEL: doubleConstantArray: 95; CHECK-P8: # %bb.0: 96; CHECK-P8-NEXT: addis 3, 2, d@toc@ha 97; CHECK-P8-NEXT: addis 4, 2, .LCPI4_0@toc@ha 98; CHECK-P8-NEXT: addi 3, 3, d@toc@l 99; CHECK-P8-NEXT: lfd 1, .LCPI4_0@toc@l(4) 100; CHECK-P8-NEXT: lfd 0, 24(3) 101; CHECK-P8-NEXT: xsadddp 1, 0, 1 102; CHECK-P8-NEXT: blr 103 %1 = load double, double* getelementptr inbounds ([200 x double], [200 x double]* @d, i64 0, i64 3), align 8 104 %2 = fadd double %1, 6.880000e+00 105 ret double %2 106} 107 108@arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8 109 110; Access an element with an offset that doesn't fit in the displacement field of LFD. 111define double @doubleLargeConstantArray() { 112; CHECK-P9-LABEL: doubleLargeConstantArray: 113; CHECK-P9: # %bb.0: 114; CHECK-P9-NEXT: addis 3, 2, arr@toc@ha 115; CHECK-P9-NEXT: li 4, 0 116; CHECK-P9-NEXT: addi 3, 3, arr@toc@l 117; CHECK-P9-NEXT: ori 4, 4, 32768 118; CHECK-P9-NEXT: lfdx 0, 3, 4 119; CHECK-P9-NEXT: addis 3, 2, .LCPI5_0@toc@ha 120; CHECK-P9-NEXT: lfd 1, .LCPI5_0@toc@l(3) 121; CHECK-P9-NEXT: xsadddp 1, 0, 1 122; CHECK-P9-NEXT: blr 123; 124; CHECK-P8-LABEL: doubleLargeConstantArray: 125; CHECK-P8: # %bb.0: 126; CHECK-P8-NEXT: addis 3, 2, arr@toc@ha 127; CHECK-P8-NEXT: li 4, 0 128; CHECK-P8-NEXT: addis 5, 2, .LCPI5_0@toc@ha 129; CHECK-P8-NEXT: addi 3, 3, arr@toc@l 130; CHECK-P8-NEXT: ori 4, 4, 32768 131; CHECK-P8-NEXT: lfdx 0, 3, 4 132; CHECK-P8-NEXT: lfd 1, .LCPI5_0@toc@l(5) 133; CHECK-P8-NEXT: xsadddp 1, 0, 1 134; CHECK-P8-NEXT: blr 135 %1 = load double, double* getelementptr inbounds ([20000 x double], [20000 x double]* @arr, i64 0, i64 4096), align 8 136 %2 = fadd double %1, 6.880000e+00 137 ret double %2 138} 139 140@vec_arr = global [10 x <4 x i32>] zeroinitializer, align 16 141 142define <4 x i32> @vectorArray() #0 { 143; CHECK-P9-LABEL: vectorArray: 144; CHECK-P9: # %bb.0: # %entry 145; CHECK-P9-NEXT: addis 3, 2, .LC0@toc@ha 146; CHECK-P9-NEXT: ld 3, .LC0@toc@l(3) 147; CHECK-P9-NEXT: lxv 34, 32(3) 148; CHECK-P9-NEXT: blr 149; 150; CHECK-P8-LABEL: vectorArray: 151; CHECK-P8: # %bb.0: # %entry 152; CHECK-P8-NEXT: addis 3, 2, .LC0@toc@ha 153; CHECK-P8-NEXT: ld 3, .LC0@toc@l(3) 154; CHECK-P8-NEXT: addi 3, 3, 32 155; CHECK-P8-NEXT: lvx 2, 0, 3 156; CHECK-P8-NEXT: blr 157entry: 158 %0 = load <4 x i32>, <4 x i32>* getelementptr inbounds ([10 x <4 x i32>], [10 x <4 x i32>]* @vec_arr, i64 0, i64 2), align 16 159 ret <4 x i32> %0 160} 161