1 ; Test 32-bit unsigned comparisons between memory and a constant. 2 ; 3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5 ; Check ordered comparisons with a constant near the low end of the unsigned 6 ; 16-bit range. 7 define double @f1(double %a, double %b, i32 *%ptr) { 8 ; CHECK-LABEL: f1: 9 ; CHECK: clfhsi 0(%r2), 1 10 ; CHECK-NEXT: jh 11 ; CHECK: ldr %f0, %f2 12 ; CHECK: br %r14 13 %val = load i32 *%ptr 14 %cond = icmp ugt i32 %val, 1 15 %res = select i1 %cond, double %a, double %b 16 ret double %res 17 } 18 19 ; Check ordered comparisons with the high end of the unsigned 16-bit range. 20 define double @f2(double %a, double %b, i32 *%ptr) { 21 ; CHECK-LABEL: f2: 22 ; CHECK: clfhsi 0(%r2), 65535 23 ; CHECK-NEXT: jl 24 ; CHECK: ldr %f0, %f2 25 ; CHECK: br %r14 26 %val = load i32 *%ptr 27 %cond = icmp ult i32 %val, 65535 28 %res = select i1 %cond, double %a, double %b 29 ret double %res 30 } 31 32 ; Check the next value up, which can't use CLFHSI. 33 define double @f3(double %a, double %b, i32 *%ptr) { 34 ; CHECK-LABEL: f3: 35 ; CHECK-NOT: clfhsi 36 ; CHECK: br %r14 37 %val = load i32 *%ptr 38 %cond = icmp ult i32 %val, 65536 39 %res = select i1 %cond, double %a, double %b 40 ret double %res 41 } 42 43 ; Check equality comparisons with 32768, the lowest value for which 44 ; we prefer CLFHSI to CHSI. 45 define double @f4(double %a, double %b, i32 *%ptr) { 46 ; CHECK-LABEL: f4: 47 ; CHECK: clfhsi 0(%r2), 32768 48 ; CHECK-NEXT: je 49 ; CHECK: ldr %f0, %f2 50 ; CHECK: br %r14 51 %val = load i32 *%ptr 52 %cond = icmp eq i32 %val, 32768 53 %res = select i1 %cond, double %a, double %b 54 ret double %res 55 } 56 57 ; Check equality comparisons with the high end of the unsigned 16-bit range. 58 define double @f5(double %a, double %b, i32 *%ptr) { 59 ; CHECK-LABEL: f5: 60 ; CHECK: clfhsi 0(%r2), 65535 61 ; CHECK-NEXT: je 62 ; CHECK: ldr %f0, %f2 63 ; CHECK: br %r14 64 %val = load i32 *%ptr 65 %cond = icmp eq i32 %val, 65535 66 %res = select i1 %cond, double %a, double %b 67 ret double %res 68 } 69 70 ; Check the next value up, which can't use CLFHSI. 71 define double @f6(double %a, double %b, i32 *%ptr) { 72 ; CHECK-LABEL: f6: 73 ; CHECK-NOT: clfhsi 74 ; CHECK: br %r14 75 %val = load i32 *%ptr 76 %cond = icmp eq i32 %val, 65536 77 %res = select i1 %cond, double %a, double %b 78 ret double %res 79 } 80 81 ; Check the high end of the CLFHSI range. 82 define double @f7(double %a, double %b, i32 %i1, i32 *%base) { 83 ; CHECK-LABEL: f7: 84 ; CHECK: clfhsi 4092(%r3), 1 85 ; CHECK-NEXT: jh 86 ; CHECK: ldr %f0, %f2 87 ; CHECK: br %r14 88 %ptr = getelementptr i32 *%base, i64 1023 89 %val = load i32 *%ptr 90 %cond = icmp ugt i32 %val, 1 91 %res = select i1 %cond, double %a, double %b 92 ret double %res 93 } 94 95 ; Check the next word up, which needs separate address logic, 96 define double @f8(double %a, double %b, i32 *%base) { 97 ; CHECK-LABEL: f8: 98 ; CHECK: aghi %r2, 4096 99 ; CHECK: clfhsi 0(%r2), 1 100 ; CHECK-NEXT: jh 101 ; CHECK: ldr %f0, %f2 102 ; CHECK: br %r14 103 %ptr = getelementptr i32 *%base, i64 1024 104 %val = load i32 *%ptr 105 %cond = icmp ugt i32 %val, 1 106 %res = select i1 %cond, double %a, double %b 107 ret double %res 108 } 109 110 ; Check negative offsets, which also need separate address logic. 111 define double @f9(double %a, double %b, i32 *%base) { 112 ; CHECK-LABEL: f9: 113 ; CHECK: aghi %r2, -4 114 ; CHECK: clfhsi 0(%r2), 1 115 ; CHECK-NEXT: jh 116 ; CHECK: ldr %f0, %f2 117 ; CHECK: br %r14 118 %ptr = getelementptr i32 *%base, i64 -1 119 %val = load i32 *%ptr 120 %cond = icmp ugt i32 %val, 1 121 %res = select i1 %cond, double %a, double %b 122 ret double %res 123 } 124 125 ; Check that CLFHSI does not allow indices. 126 define double @f10(double %a, double %b, i64 %base, i64 %index) { 127 ; CHECK-LABEL: f10: 128 ; CHECK: agr {{%r2, %r3|%r3, %r2}} 129 ; CHECK: clfhsi 0({{%r[23]}}), 1 130 ; CHECK-NEXT: jh 131 ; CHECK: ldr %f0, %f2 132 ; CHECK: br %r14 133 %add = add i64 %base, %index 134 %ptr = inttoptr i64 %add to i32 * 135 %val = load i32 *%ptr 136 %cond = icmp ugt i32 %val, 1 137 %res = select i1 %cond, double %a, double %b 138 ret double %res 139 } 140