1; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 <%s | FileCheck %s 2 3; As the constant could be represented as float, a float is 4; loaded from constant pool. 5define double @doubleConstant1() { 6 ret double 1.400000e+01 7} 8 9; CHECK-LABEL: doubleConstant1: 10; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha 11; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]]) 12 13; As the constant couldn't be represented as float, a double is 14; loaded from constant pool. 15define double @doubleConstant2() { 16 ret double 2.408904e+01 17} 18 19; CHECK-LABEL: doubleConstant2: 20; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha 21; CHECK: lfd {{[0-9]+}}, [[VAR]]@toc@l([[REG1]]) 22 23@FArr = hidden local_unnamed_addr global [10 x float] zeroinitializer, align 4 24 25define float @floatConstantArray() local_unnamed_addr { 26 %1 = load float, float* getelementptr inbounds ([10 x float], [10 x float]* @FArr, i64 0, i64 3), align 4 27 %2 = fadd float %1, 0x400B333340000000 28 ret float %2 29} 30 31; CHECK-LABEL: floatConstantArray 32; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]] 33; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]]) 34 35define float @floatConstant() { 36 ret float 0x400470A3E0000000 37} 38 39; CHECK-LABEL: floatConstant: 40; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha 41; CHECK: lfs {{[0-9]+}}, [[VAR]]@toc@l([[REG1]]) 42 43; llvm put the hidden globals into the TOC table. 44; TODO - do some analysis and decide which globals could be put into TOC. 45@d = hidden local_unnamed_addr global [200 x double] zeroinitializer, align 8 46 47define double @doubleConstantArray() { 48 %1 = load double, double* getelementptr inbounds ([200 x double], [200 x double]* @d, i64 0, i64 3), align 8 49 %2 = fadd double %1, 6.880000e+00 50 ret double %2 51} 52 53; CHECK-LABEL: doubleConstantArray 54; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha+[[REG2:[0-9]+]] 55; CHECK: lfd {{[0-9]+}}, [[VAR]]@toc@l+[[REG2]]([[REG1]]) 56 57@arr = hidden local_unnamed_addr global [20000 x double] zeroinitializer, align 8 58 59define double @doubleLargeConstantArray() { 60 %1 = load double, double* getelementptr inbounds ([20000 x double], [20000 x double]* @arr, i64 0, i64 4096), align 8 61 %2 = fadd double %1, 6.880000e+00 62 ret double %2 63} 64 65; access element that out of range 66; CHECK-LABEL: doubleLargeConstantArray 67; CHECK: addis [[REG1:[0-9]+]], 2, [[VAR:[a-z0-9A-Z_.]+]]@toc@ha 68; CHECK: li [[REG2:[0-9]+]], 0 69; CHECK: addi [[REG3:[0-9]+]], [[REG1]], [[VAR:[a-z0-9A-Z_.]+]]@toc@l 70; CHECK: ori [[REG4:[0-9]+]], [[REG2]], 32768 71; CHECK: lfdx {{[0-9]+}}, [[REG3]], [[REG4]] 72