1; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 3 4; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_eq_0: 5; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 6; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 7; SI: v_cmp_eq_i32_e32 vcc, 1, [[TMP]]{{$}} 8; SI: s_xor_b64 s{{\[[0-9]+:[0-9]+\]}}, vcc, -1{{$}} 9; SI: v_cndmask_b32_e64 10; SI: buffer_store_byte 11define void @sextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 12 %load = load i1, i1 addrspace(1)* %in 13 %ext = sext i1 %load to i32 14 %cmp = icmp eq i32 %ext, 0 15 store i1 %cmp, i1 addrspace(1)* %out 16 ret void 17} 18 19; FIXME: The negate should be inverting the compare. 20; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_0: 21; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 22; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 23; SI: v_cmp_eq_i32_e32 vcc, 1, [[TMP]]{{$}} 24; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1 25; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]] 26; SI-NEXT: buffer_store_byte [[RESULT]] 27define void @zextload_i1_to_i32_trunc_cmp_eq_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 28 %load = load i1, i1 addrspace(1)* %in 29 %ext = zext i1 %load to i32 30 %cmp = icmp eq i32 %ext, 0 31 store i1 %cmp, i1 addrspace(1)* %out 32 ret void 33} 34 35; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_1: 36; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}} 37; SI: buffer_store_byte [[RESULT]] 38define void @sextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 39 %load = load i1, i1 addrspace(1)* %in 40 %ext = sext i1 %load to i32 41 %cmp = icmp eq i32 %ext, 1 42 store i1 %cmp, i1 addrspace(1)* %out 43 ret void 44} 45 46; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_1: 47; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 48; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]] 49; SI-NEXT: buffer_store_byte [[RESULT]] 50define void @zextload_i1_to_i32_trunc_cmp_eq_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 51 %load = load i1, i1 addrspace(1)* %in 52 %ext = zext i1 %load to i32 53 %cmp = icmp eq i32 %ext, 1 54 store i1 %cmp, i1 addrspace(1)* %out 55 ret void 56} 57 58; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_eq_neg1: 59; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 60; SI: v_and_b32_e32 [[RESULT:v[0-9]+]], 1, [[LOAD]] 61; SI-NEXT: buffer_store_byte [[RESULT]] 62define void @sextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 63 %load = load i1, i1 addrspace(1)* %in 64 %ext = sext i1 %load to i32 65 %cmp = icmp eq i32 %ext, -1 66 store i1 %cmp, i1 addrspace(1)* %out 67 ret void 68} 69 70; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_eq_neg1: 71; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}} 72; SI: buffer_store_byte [[RESULT]] 73define void @zextload_i1_to_i32_trunc_cmp_eq_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 74 %load = load i1, i1 addrspace(1)* %in 75 %ext = zext i1 %load to i32 76 %cmp = icmp eq i32 %ext, -1 77 store i1 %cmp, i1 addrspace(1)* %out 78 ret void 79} 80 81 82; FUNC-LABEL {{^}}sextload_i1_to_i32_trunc_cmp_ne_0: 83; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 84; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 85; SI-NEXT: buffer_store_byte [[RESULT]] 86define void @sextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 87 %load = load i1, i1 addrspace(1)* %in 88 %ext = sext i1 %load to i32 89 %cmp = icmp ne i32 %ext, 0 90 store i1 %cmp, i1 addrspace(1)* %out 91 ret void 92} 93 94; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_0: 95; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 96; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 97; SI-NEXT: buffer_store_byte [[RESULT]] 98define void @zextload_i1_to_i32_trunc_cmp_ne_0(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 99 %load = load i1, i1 addrspace(1)* %in 100 %ext = zext i1 %load to i32 101 %cmp = icmp ne i32 %ext, 0 102 store i1 %cmp, i1 addrspace(1)* %out 103 ret void 104} 105 106; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_1: 107; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}} 108; SI: buffer_store_byte [[RESULT]] 109define void @sextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 110 %load = load i1, i1 addrspace(1)* %in 111 %ext = sext i1 %load to i32 112 %cmp = icmp ne i32 %ext, 1 113 store i1 %cmp, i1 addrspace(1)* %out 114 ret void 115} 116 117; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_1: 118; SI: buffer_load_ubyte [[LOAD:v[0-9]+]] 119; SI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 120; SI: v_cmp_eq_i32_e32 vcc, 1, [[TMP]]{{$}} 121; SI-NEXT: s_xor_b64 [[NEG:s\[[0-9]+:[0-9]+\]]], vcc, -1 122; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[NEG]] 123; SI-NEXT: buffer_store_byte [[RESULT]] 124define void @zextload_i1_to_i32_trunc_cmp_ne_1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 125 %load = load i1, i1 addrspace(1)* %in 126 %ext = zext i1 %load to i32 127 %cmp = icmp ne i32 %ext, 1 128 store i1 %cmp, i1 addrspace(1)* %out 129 ret void 130} 131 132; FIXME: This should be one compare. 133; FUNC-LABEL: {{^}}sextload_i1_to_i32_trunc_cmp_ne_neg1: 134; XSI: buffer_load_ubyte [[LOAD:v[0-9]+]] 135; XSI: v_and_b32_e32 [[TMP:v[0-9]+]], 1, [[LOAD]] 136; XSI: v_cmp_eq_i32_e64 [[CMP0:s\[[0-9]+:[0-9]+\]]], [[TMP]], 0{{$}} 137; XSI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1, [[CMP0]] 138; XSI-NEXT: buffer_store_byte [[RESULT]] 139define void @sextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 140 %load = load i1, i1 addrspace(1)* %in 141 %ext = sext i1 %load to i32 142 %cmp = icmp ne i32 %ext, -1 143 store i1 %cmp, i1 addrspace(1)* %out 144 ret void 145} 146 147; FUNC-LABEL: {{^}}zextload_i1_to_i32_trunc_cmp_ne_neg1: 148; SI: v_mov_b32_e32 [[RESULT:v[0-9]+]], 1{{$}} 149; SI: buffer_store_byte [[RESULT]] 150define void @zextload_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i1 addrspace(1)* %in) nounwind { 151 %load = load i1, i1 addrspace(1)* %in 152 %ext = zext i1 %load to i32 153 %cmp = icmp ne i32 %ext, -1 154 store i1 %cmp, i1 addrspace(1)* %out 155 ret void 156} 157 158; FUNC-LABEL: {{^}}masked_load_i1_to_i32_trunc_cmp_ne_neg1: 159; SI: buffer_load_sbyte [[LOAD:v[0-9]+]] 160; SI: v_cmp_ne_i32_e32 vcc, -1, [[LOAD]]{{$}} 161; SI-NEXT: v_cndmask_b32_e64 162; SI-NEXT: buffer_store_byte 163define void @masked_load_i1_to_i32_trunc_cmp_ne_neg1(i1 addrspace(1)* %out, i8 addrspace(1)* %in) nounwind { 164 %load = load i8, i8 addrspace(1)* %in 165 %masked = and i8 %load, 255 166 %ext = sext i8 %masked to i32 167 %cmp = icmp ne i32 %ext, -1 168 store i1 %cmp, i1 addrspace(1)* %out 169 ret void 170} 171