1; RUN: opt -S -passes=verify < %s | FileCheck %s 2target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 3target triple = "aarch64--linux-gnu" 4 5;; Check supported instructions are accepted without dropping 'vscale'. 6;; Same order as the LangRef 7 8;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9;; Unary Operations 10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 11 12 13define <vscale x 2 x double> @fneg(<vscale x 2 x double> %val) { 14; CHECK-LABEL: @fneg 15; CHECK: %r = fneg <vscale x 2 x double> %val 16; CHECK-NEXT: ret <vscale x 2 x double> %r 17 %r = fneg <vscale x 2 x double> %val 18 ret <vscale x 2 x double> %r 19} 20 21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 22;; Binary Operations 23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 25define <vscale x 8 x i16> @add(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b) { 26; CHECK-LABEL: @add 27; CHECK: %r = add <vscale x 8 x i16> %a, %b 28; CHECK-NEXT: ret <vscale x 8 x i16> %r 29 %r = add <vscale x 8 x i16> %a, %b 30 ret <vscale x 8 x i16> %r 31} 32 33define <vscale x 4 x float> @fadd(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 34; CHECK-LABEL: @fadd 35; CHECK: %r = fadd <vscale x 4 x float> %a, %b 36; CHECK-NEXT: ret <vscale x 4 x float> %r 37 %r = fadd <vscale x 4 x float> %a, %b 38 ret <vscale x 4 x float> %r 39} 40 41define <vscale x 4 x i32> @sub(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 42; CHECK-LABEL: @sub 43; CHECK: %r = sub <vscale x 4 x i32> %a, %b 44; CHECK-NEXT: ret <vscale x 4 x i32> %r 45 %r = sub <vscale x 4 x i32> %a, %b 46 ret <vscale x 4 x i32> %r 47} 48 49define <vscale x 4 x float> @fsub(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 50; CHECK-LABEL: @fsub 51; CHECK: %r = fsub <vscale x 4 x float> %a, %b 52; CHECK-NEXT: ret <vscale x 4 x float> %r 53 %r = fsub <vscale x 4 x float> %a, %b 54 ret <vscale x 4 x float> %r 55} 56 57define <vscale x 4 x i32> @mul(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 58; CHECK-LABEL: @mul 59; CHECK: %r = mul <vscale x 4 x i32> %a, %b 60; CHECK-NEXT: ret <vscale x 4 x i32> %r 61 %r = mul <vscale x 4 x i32> %a, %b 62 ret <vscale x 4 x i32> %r 63} 64 65define <vscale x 4 x float> @fmul(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 66; CHECK-LABEL: @fmul 67; CHECK: %r = fmul <vscale x 4 x float> %a, %b 68; CHECK-NEXT: ret <vscale x 4 x float> %r 69 %r = fmul <vscale x 4 x float> %a, %b 70 ret <vscale x 4 x float> %r 71} 72 73define <vscale x 4 x i32> @udiv(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 74; CHECK-LABEL: @udiv 75; CHECK: %r = udiv <vscale x 4 x i32> %a, %b 76; CHECK-NEXT: ret <vscale x 4 x i32> %r 77 %r = udiv <vscale x 4 x i32> %a, %b 78 ret <vscale x 4 x i32> %r 79} 80 81define <vscale x 4 x i32> @sdiv(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 82; CHECK-LABEL: @sdiv 83; CHECK: %r = sdiv <vscale x 4 x i32> %a, %b 84; CHECK-NEXT: ret <vscale x 4 x i32> %r 85 %r = sdiv <vscale x 4 x i32> %a, %b 86 ret <vscale x 4 x i32> %r 87} 88 89define <vscale x 4 x float> @fdiv(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 90; CHECK-LABEL: @fdiv 91; CHECK: %r = fdiv <vscale x 4 x float> %a, %b 92; CHECK-NEXT: ret <vscale x 4 x float> %r 93 %r = fdiv <vscale x 4 x float> %a, %b 94 ret <vscale x 4 x float> %r 95} 96 97define <vscale x 4 x i32> @urem(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 98; CHECK-LABEL: @urem 99; CHECK: %r = urem <vscale x 4 x i32> %a, %b 100; CHECK-NEXT: ret <vscale x 4 x i32> %r 101 %r = urem <vscale x 4 x i32> %a, %b 102 ret <vscale x 4 x i32> %r 103} 104 105define <vscale x 4 x i32> @srem(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 106; CHECK-LABEL: @srem 107; CHECK: %r = srem <vscale x 4 x i32> %a, %b 108; CHECK-NEXT: ret <vscale x 4 x i32> %r 109 %r = srem <vscale x 4 x i32> %a, %b 110 ret <vscale x 4 x i32> %r 111} 112 113define <vscale x 4 x float> @frem(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 114; CHECK-LABEL: @frem 115; CHECK: %r = frem <vscale x 4 x float> %a, %b 116; CHECK-NEXT: ret <vscale x 4 x float> %r 117 %r = frem <vscale x 4 x float> %a, %b 118 ret <vscale x 4 x float> %r 119} 120 121;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 122;; Bitwise Binary Operations 123;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 124 125define <vscale x 4 x i32> @shl(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 126; CHECK-LABEL: @shl 127; CHECK: %r = shl <vscale x 4 x i32> %a, %b 128; CHECK-NEXT: ret <vscale x 4 x i32> %r 129 %r = shl <vscale x 4 x i32> %a, %b 130 ret <vscale x 4 x i32> %r 131} 132 133define <vscale x 4 x i32> @lshr(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 134; CHECK-LABEL: @lshr 135; CHECK: %r = lshr <vscale x 4 x i32> %a, %b 136; CHECK-NEXT: ret <vscale x 4 x i32> %r 137 %r = lshr <vscale x 4 x i32> %a, %b 138 ret <vscale x 4 x i32> %r 139} 140 141define <vscale x 4 x i32> @ashr(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 142; CHECK-LABEL: @ashr 143; CHECK: %r = ashr <vscale x 4 x i32> %a, %b 144; CHECK-NEXT: ret <vscale x 4 x i32> %r 145 %r = ashr <vscale x 4 x i32> %a, %b 146 ret <vscale x 4 x i32> %r 147} 148 149define <vscale x 4 x i32> @and(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 150; CHECK-LABEL: @and 151; CHECK: %r = and <vscale x 4 x i32> %a, %b 152; CHECK-NEXT: ret <vscale x 4 x i32> %r 153 %r = and <vscale x 4 x i32> %a, %b 154 ret <vscale x 4 x i32> %r 155} 156 157define <vscale x 4 x i32> @or(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 158; CHECK-LABEL: @or 159; CHECK: %r = or <vscale x 4 x i32> %a, %b 160; CHECK-NEXT: ret <vscale x 4 x i32> %r 161 %r = or <vscale x 4 x i32> %a, %b 162 ret <vscale x 4 x i32> %r 163} 164 165define <vscale x 4 x i32> @xor(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 166; CHECK-LABEL: @xor 167; CHECK: %r = xor <vscale x 4 x i32> %a, %b 168; CHECK-NEXT: ret <vscale x 4 x i32> %r 169 %r = xor <vscale x 4 x i32> %a, %b 170 ret <vscale x 4 x i32> %r 171} 172 173;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 174;; Vector Operations 175;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 176 177define i64 @extractelement(<vscale x 2 x i64> %val) { 178; CHECK-LABEL: @extractelement 179; CHECK: %r = extractelement <vscale x 2 x i64> %val, i32 0 180; CHECK-NEXT: ret i64 %r 181 %r = extractelement <vscale x 2 x i64> %val, i32 0 182 ret i64 %r 183} 184 185define <vscale x 16 x i8> @insertelement(<vscale x 16 x i8> %vec, i8 %ins) { 186; CHECK-LABEL: @insertelement 187; CHECK: %r = insertelement <vscale x 16 x i8> %vec, i8 %ins, i32 0 188; CHECK-NEXT: ret <vscale x 16 x i8> %r 189 %r = insertelement <vscale x 16 x i8> %vec, i8 %ins, i32 0 190 ret <vscale x 16 x i8> %r 191} 192 193define <vscale x 8 x half> @shufflevector(half %val) { 194; CHECK-LABEL: @shufflevector 195; CHECK: %insvec = insertelement <vscale x 8 x half> undef, half %val, i32 0 196; CHECK-NEXT: %r = shufflevector <vscale x 8 x half> %insvec, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer 197; CHECK-NEXT: ret <vscale x 8 x half> %r 198 %insvec = insertelement <vscale x 8 x half> undef, half %val, i32 0 199 %r = shufflevector <vscale x 8 x half> %insvec, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer 200 ret <vscale x 8 x half> %r 201} 202 203define <vscale x 8 x half> @shufflevector2(half %val) { 204; CHECK-LABEL: @shufflevector 205; CHECK: %insvec = insertelement <vscale x 8 x half> poison, half %val, i32 0 206; CHECK-NEXT: %r = shufflevector <vscale x 8 x half> %insvec, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer 207; CHECK-NEXT: ret <vscale x 8 x half> %r 208 %insvec = insertelement <vscale x 8 x half> poison, half %val, i32 0 209 %r = shufflevector <vscale x 8 x half> %insvec, <vscale x 8 x half> undef, <vscale x 8 x i32> zeroinitializer 210 ret <vscale x 8 x half> %r 211} 212 213;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 214;; Memory Access and Addressing Operations 215;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 216 217define void @alloca() { 218; CHECK-LABEL: @alloca 219; CHECK: %vec = alloca <vscale x 4 x i32> 220; CHECK-NEXT: ret void 221 %vec = alloca <vscale x 4 x i32> 222 ret void 223} 224 225define <vscale x 2 x double> @load(ptr %ptr) { 226; CHECK-LABEL: @load 227; CHECK: %r = load <vscale x 2 x double>, ptr %ptr 228; CHECK-NEXT: ret <vscale x 2 x double> %r 229 %r = load <vscale x 2 x double>, ptr %ptr 230 ret <vscale x 2 x double> %r 231} 232 233define void @store(<vscale x 4 x i32> %data, ptr %ptr) { 234; CHECK-LABEL: @store 235; CHECK: store <vscale x 4 x i32> %data, ptr %ptr 236; CHECK-NEXT: ret void 237 store <vscale x 4 x i32> %data, ptr %ptr 238 ret void 239} 240 241define ptr @getelementptr(ptr %base) { 242; CHECK-LABEL: @getelementptr 243; CHECK-NEXT: ret ptr %base 244 ret ptr %base 245} 246 247;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 248;; Conversion Operations 249;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 250 251define <vscale x 4 x i32> @truncto(<vscale x 4 x i64> %val) { 252; CHECK-LABEL: @truncto 253; CHECK: %r = trunc <vscale x 4 x i64> %val to <vscale x 4 x i32> 254; CHECK-NEXT: ret <vscale x 4 x i32> %r 255 %r = trunc <vscale x 4 x i64> %val to <vscale x 4 x i32> 256 ret <vscale x 4 x i32> %r 257} 258 259define <vscale x 2 x i64> @zextto(<vscale x 2 x i16> %val) { 260; CHECK-LABEL: @zextto 261; CHECK: %r = zext <vscale x 2 x i16> %val to <vscale x 2 x i64> 262; CHECK-NEXT: ret <vscale x 2 x i64> %r 263 %r = zext <vscale x 2 x i16> %val to <vscale x 2 x i64> 264 ret <vscale x 2 x i64> %r 265} 266 267define <vscale x 4 x i32> @sextto(<vscale x 4 x i8> %val) { 268; CHECK-LABEL: @sextto 269; CHECK: %r = sext <vscale x 4 x i8> %val to <vscale x 4 x i32> 270; CHECK-NEXT: ret <vscale x 4 x i32> %r 271 %r = sext <vscale x 4 x i8> %val to <vscale x 4 x i32> 272 ret <vscale x 4 x i32> %r 273} 274 275define <vscale x 4 x half> @fptruncto(<vscale x 4 x float> %val) { 276; CHECK-LABEL: @fptruncto 277; CHECK: %r = fptrunc <vscale x 4 x float> %val to <vscale x 4 x half> 278; CHECK-NEXT: ret <vscale x 4 x half> %r 279 %r = fptrunc <vscale x 4 x float> %val to <vscale x 4 x half> 280 ret <vscale x 4 x half> %r 281} 282 283define <vscale x 2 x double> @fpextto(<vscale x 2 x half> %val) { 284; CHECK-LABEL: @fpextto 285; CHECK: %r = fpext <vscale x 2 x half> %val to <vscale x 2 x double> 286; CHECK-NEXT: ret <vscale x 2 x double> %r 287 %r = fpext <vscale x 2 x half> %val to <vscale x 2 x double> 288 ret <vscale x 2 x double> %r 289} 290 291define <vscale x 4 x i32> @fptouito(<vscale x 4 x float> %val) { 292; CHECK-LABEL: @fptoui 293; CHECK: %r = fptoui <vscale x 4 x float> %val to <vscale x 4 x i32> 294; CHECK-NEXT: ret <vscale x 4 x i32> %r 295 %r = fptoui <vscale x 4 x float> %val to <vscale x 4 x i32> 296 ret <vscale x 4 x i32> %r 297} 298 299define <vscale x 4 x i32> @fptosito(<vscale x 4 x float> %val) { 300; CHECK-LABEL: @fptosi 301; CHECK: %r = fptosi <vscale x 4 x float> %val to <vscale x 4 x i32> 302; CHECK-NEXT: ret <vscale x 4 x i32> %r 303 %r = fptosi <vscale x 4 x float> %val to <vscale x 4 x i32> 304 ret <vscale x 4 x i32> %r 305} 306 307define <vscale x 4 x float> @uitofpto(<vscale x 4 x i32> %val) { 308; CHECK-LABEL: @uitofp 309; CHECK: %r = uitofp <vscale x 4 x i32> %val to <vscale x 4 x float> 310; CHECK-NEXT: ret <vscale x 4 x float> %r 311 %r = uitofp <vscale x 4 x i32> %val to <vscale x 4 x float> 312 ret <vscale x 4 x float> %r 313} 314 315define <vscale x 4 x float> @sitofpto(<vscale x 4 x i32> %val) { 316; CHECK-LABEL: @sitofp 317; CHECK: %r = sitofp <vscale x 4 x i32> %val to <vscale x 4 x float> 318; CHECK-NEXT: ret <vscale x 4 x float> %r 319 %r = sitofp <vscale x 4 x i32> %val to <vscale x 4 x float> 320 ret <vscale x 4 x float> %r 321} 322 323define <vscale x 2 x i64> @ptrtointto(<vscale x 2 x ptr> %val) { 324; CHECK-LABEL: @ptrtointto 325; CHECK: %r = ptrtoint <vscale x 2 x ptr> %val to <vscale x 2 x i64> 326; CHECK-NEXT: ret <vscale x 2 x i64> %r 327 %r = ptrtoint <vscale x 2 x ptr> %val to <vscale x 2 x i64> 328 ret <vscale x 2 x i64> %r 329} 330 331define <vscale x 2 x ptr> @inttoptrto(<vscale x 2 x i64> %val) { 332; CHECK-LABEL: @inttoptrto 333; CHECK: %r = inttoptr <vscale x 2 x i64> %val to <vscale x 2 x ptr> 334; CHECK-NEXT: ret <vscale x 2 x ptr> %r 335 %r = inttoptr <vscale x 2 x i64> %val to <vscale x 2 x ptr> 336 ret <vscale x 2 x ptr> %r 337} 338 339define <vscale x 2 x i64> @bitcastto(<vscale x 2 x double> %a) { 340; CHECK-LABEL: @bitcast 341; CHECK: %r = bitcast <vscale x 2 x double> %a to <vscale x 2 x i64> 342; CHECK-NEXT: ret <vscale x 2 x i64> %r 343 %r = bitcast <vscale x 2 x double> %a to <vscale x 2 x i64> 344 ret <vscale x 2 x i64> %r 345} 346 347;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 348;; Other Operations 349;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 350 351define <vscale x 4 x i1> @icmp(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) { 352; CHECK-LABEL: @icmp 353; CHECK: %r = icmp eq <vscale x 4 x i32> %a, %b 354; CHECK-NEXT: ret <vscale x 4 x i1> %r 355 %r = icmp eq <vscale x 4 x i32> %a, %b 356 ret <vscale x 4 x i1> %r 357} 358 359define <vscale x 4 x i1> @fcmp(<vscale x 4 x float> %a, <vscale x 4 x float> %b) { 360; CHECK-LABEL: @fcmp 361; CHECK: %r = fcmp une <vscale x 4 x float> %a, %b 362; CHECK-NEXT: ret <vscale x 4 x i1> %r 363 %r = fcmp une <vscale x 4 x float> %a, %b 364 ret <vscale x 4 x i1> %r 365} 366 367define <vscale x 16 x i8> @phi(<vscale x 16 x i8> %a, i32 %val) { 368; CHECK-LABEL: @phi 369; CHECK: %r = phi <vscale x 16 x i8> [ %a, %entry ], [ %added, %iszero ] 370; CHECK-NEXT: ret <vscale x 16 x i8> %r 371entry: 372 %cmp = icmp eq i32 %val, 0 373 br i1 %cmp, label %iszero, label %end 374 375iszero: 376 %ins = insertelement <vscale x 16 x i8> undef, i8 1, i32 0 377 %splatone = shufflevector <vscale x 16 x i8> %ins, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer 378 %added = add <vscale x 16 x i8> %a, %splatone 379 br label %end 380 381end: 382 %r = phi <vscale x 16 x i8> [ %a, %entry ], [ %added, %iszero ] 383 ret <vscale x 16 x i8> %r 384} 385 386define <vscale x 8 x half> @select(<vscale x 8 x half> %a, <vscale x 8 x half> %b, <vscale x 8 x i1> %sval) { 387; CHECK-LABEL: @select 388; CHECK: %r = select <vscale x 8 x i1> %sval, <vscale x 8 x half> %a, <vscale x 8 x half> %b 389; CHECK-NEXT: ret <vscale x 8 x half> %r 390 %r = select <vscale x 8 x i1> %sval, <vscale x 8 x half> %a, <vscale x 8 x half> %b 391 ret <vscale x 8 x half> %r 392} 393 394declare <vscale x 4 x i32> @callee(<vscale x 4 x i32>) 395define <vscale x 4 x i32> @call(<vscale x 4 x i32> %val) { 396; CHECK-LABEL: @call 397; CHECK: %r = call <vscale x 4 x i32> @callee(<vscale x 4 x i32> %val) 398; CHECK-NEXT: ret <vscale x 4 x i32> %r 399 %r = call <vscale x 4 x i32> @callee(<vscale x 4 x i32> %val) 400 ret <vscale x 4 x i32> %r 401} 402