278 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -passes=instcombine -mtriple=nvptx64-nvidia-cuda -S | FileCheck %s3target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"4target triple = "nvptx64-nvidia-cuda"5 6; Source data in different AS.7@shared_data = dso_local addrspace(3) global i32 undef, align 48@global_data = dso_local addrspace(1) externally_initialized global i32 0, align 49@const_data = dso_local addrspace(4) externally_initialized constant i32 3, align 410 11; Results get stored here.12@gen = dso_local addrspace(1) externally_initialized global i8 0, align 113@g1 = dso_local addrspace(1) externally_initialized global i8 0, align 114@g2 = dso_local addrspace(1) externally_initialized global i8 0, align 115@s1 = dso_local addrspace(1) externally_initialized global i8 0, align 116@s2 = dso_local addrspace(1) externally_initialized global i8 0, align 117@c1 = dso_local addrspace(1) externally_initialized global i8 0, align 118@c2 = dso_local addrspace(1) externally_initialized global i8 0, align 119@l = dso_local addrspace(1) externally_initialized global i8 0, align 120 21declare i1 @llvm.nvvm.isspacep.global(ptr nocapture)22declare i1 @llvm.nvvm.isspacep.shared(ptr nocapture)23declare i1 @llvm.nvvm.isspacep.const(ptr nocapture)24declare i1 @llvm.nvvm.isspacep.local(ptr nocapture)25 26define dso_local void @check_global(ptr nocapture noundef readnone %out, ptr nocapture noundef readnone %genp,27; CHECK-LABEL: define dso_local void @check_global(28; CHECK-SAME: ptr noundef readnone captures(none) [[OUT:%.*]], ptr noundef readnone captures(none) [[GENP:%.*]], ptr addrspace(1) [[GP:%.*]], ptr addrspace(3) [[SP:%.*]], ptr addrspace(4) [[CP:%.*]], ptr addrspace(5) [[LP:%.*]]) local_unnamed_addr {29; CHECK-NEXT: [[ENTRY:.*:]]30; CHECK-NEXT: [[GEN0:%.*]] = tail call i1 @llvm.nvvm.isspacep.global(ptr [[GENP]])31; CHECK-NEXT: [[STOREDV:%.*]] = zext i1 [[GEN0]] to i832; CHECK-NEXT: store i8 [[STOREDV]], ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 133; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 134; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 135; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 136; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 137; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 138; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 139; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 140; CHECK-NEXT: ret void41;42 ptr addrspace(1) %gp,43 ptr addrspace(3) %sp,44 ptr addrspace(4) %cp,45 ptr addrspace(5) %lp) local_unnamed_addr {46entry:47 ; No constant folding for generic pointers of unknown origin.48 %gen0 = tail call i1 @llvm.nvvm.isspacep.global(ptr %genp)49 %storedv = zext i1 %gen0 to i850 store i8 %storedv, ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 151 52 %isg1 = tail call i1 @llvm.nvvm.isspacep.global(ptr addrspacecast (ptr addrspace(1) @global_data to ptr))53 %isg18 = zext i1 %isg1 to i854 store i8 %isg18, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 155 56 %gp_asc = addrspacecast ptr addrspace(1) %gp to ptr57 %isg2 = tail call i1 @llvm.nvvm.isspacep.global(ptr %gp_asc)58 %isg28 = zext i1 %isg2 to i859 store i8 %isg28, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 160 61 %iss1 = tail call i1 @llvm.nvvm.isspacep.global(ptr addrspacecast (ptr addrspace(3) @shared_data to ptr))62 %iss18 = zext i1 %iss1 to i863 store i8 %iss18, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 164 65 %sp_asc = addrspacecast ptr addrspace(3) %sp to ptr66 %iss2 = tail call i1 @llvm.nvvm.isspacep.global(ptr %sp_asc)67 %iss28 = zext i1 %iss2 to i868 store i8 %iss28, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 169 70 %isc1 = tail call i1 @llvm.nvvm.isspacep.global(ptr addrspacecast (ptr addrspace(4) @const_data to ptr))71 %isc18 = zext i1 %isc1 to i872 store i8 %isc18, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 173 74 %cp_asc = addrspacecast ptr addrspace(4) %cp to ptr75 %isc2 = tail call i1 @llvm.nvvm.isspacep.global(ptr %cp_asc)76 %isc28 = zext i1 %isc2 to i877 store i8 %isc28, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 178 79 ; Local data can't ihave a constant address, so we can't have a constant ASC expression80 ; We can only use an ASC instruction.81 %lp_asc = addrspacecast ptr addrspace(5) %lp to ptr82 %isl = call i1 @llvm.nvvm.isspacep.global(ptr nonnull %lp_asc)83 %isl8 = zext i1 %isl to i884 store i8 %isl8, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 185 86 ret void87}88 89define dso_local void @check_shared(ptr nocapture noundef readnone %out, ptr nocapture noundef readnone %genp,90; CHECK-LABEL: define dso_local void @check_shared(91; CHECK-SAME: ptr noundef readnone captures(none) [[OUT:%.*]], ptr noundef readnone captures(none) [[GENP:%.*]], ptr addrspace(1) [[GP:%.*]], ptr addrspace(3) [[SP:%.*]], ptr addrspace(4) [[CP:%.*]], ptr addrspace(5) [[LP:%.*]]) local_unnamed_addr {92; CHECK-NEXT: [[ENTRY:.*:]]93; CHECK-NEXT: [[GEN0:%.*]] = tail call i1 @llvm.nvvm.isspacep.shared(ptr [[GENP]])94; CHECK-NEXT: [[STOREDV:%.*]] = zext i1 [[GEN0]] to i895; CHECK-NEXT: store i8 [[STOREDV]], ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 196; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 197; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 198; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 199; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1100; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1101; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1102; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1103; CHECK-NEXT: ret void104;105 ptr addrspace(1) %gp,106 ptr addrspace(3) %sp,107 ptr addrspace(4) %cp,108 ptr addrspace(5) %lp) local_unnamed_addr {109entry:110 ; No constant folding for generic pointers of unknown origin.111 %gen0 = tail call i1 @llvm.nvvm.isspacep.shared(ptr %genp)112 %storedv = zext i1 %gen0 to i8113 store i8 %storedv, ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 1114 115 %isg1 = tail call i1 @llvm.nvvm.isspacep.shared(ptr addrspacecast (ptr addrspace(1) @global_data to ptr))116 %isg18 = zext i1 %isg1 to i8117 store i8 %isg18, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 1118 119 %gp_asc = addrspacecast ptr addrspace(1) %gp to ptr120 %isg2 = tail call i1 @llvm.nvvm.isspacep.shared(ptr %gp_asc)121 %isg28 = zext i1 %isg2 to i8122 store i8 %isg28, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 1123 124 %iss1 = tail call i1 @llvm.nvvm.isspacep.shared(ptr addrspacecast (ptr addrspace(3) @shared_data to ptr))125 %iss18 = zext i1 %iss1 to i8126 store i8 %iss18, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 1127 128 %sp_asc = addrspacecast ptr addrspace(3) %sp to ptr129 %iss2 = tail call i1 @llvm.nvvm.isspacep.shared(ptr %sp_asc)130 %iss28 = zext i1 %iss2 to i8131 store i8 %iss28, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1132 133 %isc1 = tail call i1 @llvm.nvvm.isspacep.shared(ptr addrspacecast (ptr addrspace(4) @const_data to ptr))134 %isc18 = zext i1 %isc1 to i8135 store i8 %isc18, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1136 137 %cp_asc = addrspacecast ptr addrspace(4) %cp to ptr138 %isc2 = tail call i1 @llvm.nvvm.isspacep.shared(ptr %cp_asc)139 %isc28 = zext i1 %isc2 to i8140 store i8 %isc28, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1141 142 ; Local data can't have a constant address, so we can't have a constant ASC expression143 ; We can only use an ASC instruction.144 %lp_asc = addrspacecast ptr addrspace(5) %lp to ptr145 %isl = call i1 @llvm.nvvm.isspacep.shared(ptr nonnull %lp_asc)146 %isl8 = zext i1 %isl to i8147 store i8 %isl8, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1148 149 ret void150}151 152define dso_local void @check_const(ptr nocapture noundef readnone %out, ptr nocapture noundef readnone %genp,153; CHECK-LABEL: define dso_local void @check_const(154; CHECK-SAME: ptr noundef readnone captures(none) [[OUT:%.*]], ptr noundef readnone captures(none) [[GENP:%.*]], ptr addrspace(1) [[GP:%.*]], ptr addrspace(3) [[SP:%.*]], ptr addrspace(4) [[CP:%.*]], ptr addrspace(5) [[LP:%.*]]) local_unnamed_addr {155; CHECK-NEXT: [[ENTRY:.*:]]156; CHECK-NEXT: [[GEN0:%.*]] = tail call i1 @llvm.nvvm.isspacep.const(ptr [[GENP]])157; CHECK-NEXT: [[STOREDV:%.*]] = zext i1 [[GEN0]] to i8158; CHECK-NEXT: store i8 [[STOREDV]], ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 1159; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 1160; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 1161; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 1162; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1163; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1164; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1165; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1166; CHECK-NEXT: ret void167;168 ptr addrspace(1) %gp,169 ptr addrspace(3) %sp,170 ptr addrspace(4) %cp,171 ptr addrspace(5) %lp) local_unnamed_addr {172entry:173 ; No constant folding for generic pointers of unknown origin.174 %gen0 = tail call i1 @llvm.nvvm.isspacep.const(ptr %genp)175 %storedv = zext i1 %gen0 to i8176 store i8 %storedv, ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 1177 178 %isg1 = tail call i1 @llvm.nvvm.isspacep.const(ptr addrspacecast (ptr addrspace(1) @global_data to ptr))179 %isg18 = zext i1 %isg1 to i8180 store i8 %isg18, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 1181 182 %gp_asc = addrspacecast ptr addrspace(1) %gp to ptr183 %isg2 = tail call i1 @llvm.nvvm.isspacep.const(ptr %gp_asc)184 %isg28 = zext i1 %isg2 to i8185 store i8 %isg28, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 1186 187 %iss1 = tail call i1 @llvm.nvvm.isspacep.const(ptr addrspacecast (ptr addrspace(3) @shared_data to ptr))188 %iss18 = zext i1 %iss1 to i8189 store i8 %iss18, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 1190 191 %sp_asc = addrspacecast ptr addrspace(3) %sp to ptr192 %iss2 = tail call i1 @llvm.nvvm.isspacep.const(ptr %sp_asc)193 %iss28 = zext i1 %iss2 to i8194 store i8 %iss28, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1195 196 %isc1 = tail call i1 @llvm.nvvm.isspacep.const(ptr addrspacecast (ptr addrspace(4) @const_data to ptr))197 %isc18 = zext i1 %isc1 to i8198 store i8 %isc18, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1199 200 %cp_asc = addrspacecast ptr addrspace(4) %cp to ptr201 %isc2 = tail call i1 @llvm.nvvm.isspacep.const(ptr %cp_asc)202 %isc28 = zext i1 %isc2 to i8203 store i8 %isc28, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1204 205 ; Local data can't have a constant address, so we can't have a constant ASC expression206 ; We can only use an ASC instruction.207 %lp_asc = addrspacecast ptr addrspace(5) %lp to ptr208 %isl = call i1 @llvm.nvvm.isspacep.const(ptr nonnull %lp_asc)209 %isl8 = zext i1 %isl to i8210 store i8 %isl8, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1211 212 ret void213}214 215define dso_local void @check_local(ptr nocapture noundef readnone %out, ptr nocapture noundef readnone %genp,216; CHECK-LABEL: define dso_local void @check_local(217; CHECK-SAME: ptr noundef readnone captures(none) [[OUT:%.*]], ptr noundef readnone captures(none) [[GENP:%.*]], ptr addrspace(1) [[GP:%.*]], ptr addrspace(3) [[SP:%.*]], ptr addrspace(4) [[CP:%.*]], ptr addrspace(5) [[LP:%.*]]) local_unnamed_addr {218; CHECK-NEXT: [[ENTRY:.*:]]219; CHECK-NEXT: [[GEN0:%.*]] = tail call i1 @llvm.nvvm.isspacep.local(ptr [[GENP]])220; CHECK-NEXT: [[STOREDV:%.*]] = zext i1 [[GEN0]] to i8221; CHECK-NEXT: store i8 [[STOREDV]], ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 1222; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 1223; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 1224; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 1225; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1226; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1227; CHECK-NEXT: store i8 0, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1228; CHECK-NEXT: store i8 1, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1229; CHECK-NEXT: ret void230;231 ptr addrspace(1) %gp,232 ptr addrspace(3) %sp,233 ptr addrspace(4) %cp,234 ptr addrspace(5) %lp) local_unnamed_addr {235entry:236 ; No constant folding for generic pointers of unknown origin.237 %gen0 = tail call i1 @llvm.nvvm.isspacep.local(ptr %genp)238 %storedv = zext i1 %gen0 to i8239 store i8 %storedv, ptr addrspacecast (ptr addrspace(1) @gen to ptr), align 1240 241 %isg1 = tail call i1 @llvm.nvvm.isspacep.local(ptr addrspacecast (ptr addrspace(1) @global_data to ptr))242 %isg18 = zext i1 %isg1 to i8243 store i8 %isg18, ptr addrspacecast (ptr addrspace(1) @g1 to ptr), align 1244 245 %gp_asc = addrspacecast ptr addrspace(1) %gp to ptr246 %isg2 = tail call i1 @llvm.nvvm.isspacep.local(ptr %gp_asc)247 %isg28 = zext i1 %isg2 to i8248 store i8 %isg28, ptr addrspacecast (ptr addrspace(1) @g2 to ptr), align 1249 250 %iss1 = tail call i1 @llvm.nvvm.isspacep.local(ptr addrspacecast (ptr addrspace(3) @shared_data to ptr))251 %iss18 = zext i1 %iss1 to i8252 store i8 %iss18, ptr addrspacecast (ptr addrspace(1) @s1 to ptr), align 1253 254 %sp_asc = addrspacecast ptr addrspace(3) %sp to ptr255 %iss2 = tail call i1 @llvm.nvvm.isspacep.local(ptr %sp_asc)256 %iss28 = zext i1 %iss2 to i8257 store i8 %iss28, ptr addrspacecast (ptr addrspace(1) @s2 to ptr), align 1258 259 %isc1 = tail call i1 @llvm.nvvm.isspacep.local(ptr addrspacecast (ptr addrspace(4) @const_data to ptr))260 %isc18 = zext i1 %isc1 to i8261 store i8 %isc18, ptr addrspacecast (ptr addrspace(1) @c1 to ptr), align 1262 263 %cp_asc = addrspacecast ptr addrspace(4) %cp to ptr264 %isc2 = tail call i1 @llvm.nvvm.isspacep.local(ptr %cp_asc)265 %isc28 = zext i1 %isc2 to i8266 store i8 %isc28, ptr addrspacecast (ptr addrspace(1) @c2 to ptr), align 1267 268 ; Local data can't have a constant address, so we can't have a constant ASC expression269 ; We can only use an ASC instruction.270 %lp_asc = addrspacecast ptr addrspace(5) %lp to ptr271 %isl = call i1 @llvm.nvvm.isspacep.local(ptr nonnull %lp_asc)272 %isl8 = zext i1 %isl to i8273 store i8 %isl8, ptr addrspacecast (ptr addrspace(1) @l to ptr), align 1274 275 ret void276}277 278