@@ -220,29 +220,22 @@ TEST(InstructionsTest, CastInst) {
220
220
Type *VScaleV4Int16Ty = ScalableVectorType::get (Int16Ty, 4 );
221
221
Type *VScaleV1Int16Ty = ScalableVectorType::get (Int16Ty, 1 );
222
222
223
- Type *Int32PtrTy = PointerType::get (C, 0 );
224
- Type *Int64PtrTy = PointerType::get (C, 0 );
225
-
226
- Type *Int32PtrAS1Ty = PointerType::get (C, 1 );
227
- Type *Int64PtrAS1Ty = PointerType::get (C, 1 );
223
+ Type *PtrTy = PointerType::get (C, 0 );
224
+ Type *PtrAS1Ty = PointerType::get (C, 1 );
228
225
229
- Type *V2Int32PtrAS1Ty = FixedVectorType::get (Int32PtrAS1Ty, 2 );
230
- Type *V2Int64PtrAS1Ty = FixedVectorType::get (Int64PtrAS1Ty, 2 );
231
- Type *V4Int32PtrAS1Ty = FixedVectorType::get (Int32PtrAS1Ty, 4 );
232
- Type *VScaleV4Int32PtrAS1Ty = ScalableVectorType::get (Int32PtrAS1Ty, 4 );
233
- Type *V4Int64PtrAS1Ty = FixedVectorType::get (Int64PtrAS1Ty, 4 );
226
+ Type *V2PtrAS1Ty = FixedVectorType::get (PtrAS1Ty, 2 );
227
+ Type *V4PtrAS1Ty = FixedVectorType::get (PtrAS1Ty, 4 );
228
+ Type *VScaleV4PtrAS1Ty = ScalableVectorType::get (PtrAS1Ty, 4 );
234
229
235
- Type *V2Int64PtrTy = FixedVectorType::get (Int64PtrTy, 2 );
236
- Type *V2Int32PtrTy = FixedVectorType::get (Int32PtrTy, 2 );
237
- Type *VScaleV2Int32PtrTy = ScalableVectorType::get (Int32PtrTy, 2 );
238
- Type *V4Int32PtrTy = FixedVectorType::get (Int32PtrTy, 4 );
239
- Type *VScaleV4Int32PtrTy = ScalableVectorType::get (Int32PtrTy, 4 );
240
- Type *VScaleV4Int64PtrTy = ScalableVectorType::get (Int64PtrTy, 4 );
230
+ Type *V2PtrTy = FixedVectorType::get (PtrTy, 2 );
231
+ Type *V4PtrTy = FixedVectorType::get (PtrTy, 4 );
232
+ Type *VScaleV2PtrTy = ScalableVectorType::get (PtrTy, 2 );
233
+ Type *VScaleV4PtrTy = ScalableVectorType::get (PtrTy, 4 );
241
234
242
235
const Constant* c8 = Constant::getNullValue (V8x8Ty);
243
236
const Constant* c64 = Constant::getNullValue (V8x64Ty);
244
237
245
- const Constant *v2ptr32 = Constant::getNullValue (V2Int32PtrTy );
238
+ const Constant *v2ptr32 = Constant::getNullValue (V2PtrTy );
246
239
247
240
EXPECT_EQ (CastInst::Trunc, CastInst::getCastOpcode (c64, true , V8x8Ty, true ));
248
241
EXPECT_EQ (CastInst::SExt, CastInst::getCastOpcode (c8, true , V8x64Ty, true ));
@@ -251,23 +244,22 @@ TEST(InstructionsTest, CastInst) {
251
244
EXPECT_FALSE (CastInst::isBitCastable (V8x8Ty, V8x64Ty));
252
245
253
246
// Check address space casts are rejected since we don't know the sizes here
254
- EXPECT_FALSE (CastInst::isBitCastable (Int32PtrTy, Int32PtrAS1Ty));
255
- EXPECT_FALSE (CastInst::isBitCastable (Int32PtrAS1Ty, Int32PtrTy));
256
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrTy, V2Int32PtrAS1Ty));
257
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrAS1Ty, V2Int32PtrTy));
258
- EXPECT_TRUE (CastInst::isBitCastable (V2Int32PtrAS1Ty, V2Int64PtrAS1Ty));
259
- EXPECT_EQ (CastInst::AddrSpaceCast, CastInst::getCastOpcode (v2ptr32, true ,
260
- V2Int32PtrAS1Ty,
261
- true ));
247
+ EXPECT_FALSE (CastInst::isBitCastable (PtrTy, PtrAS1Ty));
248
+ EXPECT_FALSE (CastInst::isBitCastable (PtrAS1Ty, PtrTy));
249
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrTy, V2PtrAS1Ty));
250
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrAS1Ty, V2PtrTy));
251
+ EXPECT_TRUE (CastInst::isBitCastable (V2PtrAS1Ty, V2PtrAS1Ty));
252
+ EXPECT_EQ (CastInst::AddrSpaceCast,
253
+ CastInst::getCastOpcode (v2ptr32, true , V2PtrAS1Ty, true ));
262
254
263
255
// Test mismatched number of elements for pointers
264
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrAS1Ty, V4Int64PtrAS1Ty ));
265
- EXPECT_FALSE (CastInst::isBitCastable (V4Int64PtrAS1Ty, V2Int32PtrAS1Ty ));
266
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrAS1Ty, V4Int32PtrAS1Ty ));
267
- EXPECT_FALSE (CastInst::isBitCastable (Int32PtrTy, V2Int32PtrTy ));
268
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrTy, Int32PtrTy ));
256
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrTy, V2PtrTy ));
257
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrAS1Ty, V2PtrAS1Ty ));
258
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrAS1Ty, V4PtrAS1Ty ));
259
+ EXPECT_FALSE (CastInst::isBitCastable (PtrTy, V2PtrTy ));
260
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrTy, PtrTy ));
269
261
270
- EXPECT_TRUE (CastInst::isBitCastable (Int32PtrTy, Int64PtrTy ));
262
+ EXPECT_TRUE (CastInst::isBitCastable (PtrTy, PtrTy ));
271
263
EXPECT_FALSE (CastInst::isBitCastable (DoubleTy, FloatTy));
272
264
EXPECT_FALSE (CastInst::isBitCastable (FloatTy, DoubleTy));
273
265
EXPECT_TRUE (CastInst::isBitCastable (FloatTy, FloatTy));
@@ -281,55 +273,48 @@ TEST(InstructionsTest, CastInst) {
281
273
EXPECT_FALSE (CastInst::isBitCastable (Int32Ty, Int64Ty));
282
274
EXPECT_FALSE (CastInst::isBitCastable (Int64Ty, Int32Ty));
283
275
284
- EXPECT_FALSE (CastInst::isBitCastable (V2Int32PtrTy, Int64Ty));
285
- EXPECT_FALSE (CastInst::isBitCastable (Int64Ty, V2Int32PtrTy));
286
- EXPECT_TRUE (CastInst::isBitCastable (V2Int64PtrTy, V2Int32PtrTy));
287
- EXPECT_TRUE (CastInst::isBitCastable (V2Int32PtrTy, V2Int64PtrTy));
276
+ EXPECT_FALSE (CastInst::isBitCastable (V2PtrTy, Int64Ty));
277
+ EXPECT_FALSE (CastInst::isBitCastable (Int64Ty, V2PtrTy));
288
278
EXPECT_FALSE (CastInst::isBitCastable (V2Int32Ty, V2Int64Ty));
289
279
EXPECT_FALSE (CastInst::isBitCastable (V2Int64Ty, V2Int32Ty));
290
280
291
-
292
281
EXPECT_FALSE (CastInst::castIsValid (Instruction::BitCast,
293
- Constant::getNullValue (V4Int32PtrTy),
294
- V2Int32PtrTy));
282
+ Constant::getNullValue (V4PtrTy), V2PtrTy));
295
283
EXPECT_FALSE (CastInst::castIsValid (Instruction::BitCast,
296
- Constant::getNullValue (V2Int32PtrTy),
297
- V4Int32PtrTy));
284
+ Constant::getNullValue (V2PtrTy), V4PtrTy));
298
285
299
- EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
300
- Constant::getNullValue (V4Int32PtrAS1Ty),
301
- V2Int32PtrTy));
302
- EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
303
- Constant::getNullValue (V2Int32PtrTy),
304
- V4Int32PtrAS1Ty));
286
+ EXPECT_FALSE (CastInst::castIsValid (
287
+ Instruction::AddrSpaceCast, Constant::getNullValue (V4PtrAS1Ty), V2PtrTy));
288
+ EXPECT_FALSE (CastInst::castIsValid (
289
+ Instruction::AddrSpaceCast, Constant::getNullValue (V2PtrTy), V4PtrAS1Ty));
305
290
306
291
// Address space cast of fixed/scalable vectors of pointers to scalable/fixed
307
292
// vector of pointers.
308
- EXPECT_FALSE (CastInst::castIsValid (
309
- Instruction::AddrSpaceCast, Constant::getNullValue (VScaleV4Int32PtrAS1Ty),
310
- V4Int32PtrTy));
311
293
EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
312
- Constant::getNullValue (V4Int32PtrTy),
313
- VScaleV4Int32PtrAS1Ty));
294
+ Constant::getNullValue (VScaleV4PtrAS1Ty),
295
+ V4PtrTy));
296
+ EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
297
+ Constant::getNullValue (V4PtrTy),
298
+ VScaleV4PtrAS1Ty));
314
299
// Address space cast of scalable vectors of pointers to scalable vector of
315
300
// pointers.
316
- EXPECT_FALSE (CastInst::castIsValid (
317
- Instruction::AddrSpaceCast, Constant::getNullValue (VScaleV4Int32PtrAS1Ty),
318
- VScaleV2Int32PtrTy));
319
301
EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
320
- Constant::getNullValue (VScaleV2Int32PtrTy),
321
- VScaleV4Int32PtrAS1Ty));
302
+ Constant::getNullValue (VScaleV4PtrAS1Ty),
303
+ VScaleV2PtrTy));
304
+ EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
305
+ Constant::getNullValue (VScaleV2PtrTy),
306
+ VScaleV4PtrAS1Ty));
322
307
EXPECT_TRUE (CastInst::castIsValid (Instruction::AddrSpaceCast,
323
- Constant::getNullValue (VScaleV4Int64PtrTy ),
324
- VScaleV4Int32PtrAS1Ty ));
308
+ Constant::getNullValue (VScaleV4PtrTy ),
309
+ VScaleV4PtrAS1Ty ));
325
310
// Same number of lanes, different address space.
326
- EXPECT_TRUE (CastInst::castIsValid (
327
- Instruction::AddrSpaceCast, Constant::getNullValue (VScaleV4Int32PtrAS1Ty ),
328
- VScaleV4Int32PtrTy ));
311
+ EXPECT_TRUE (CastInst::castIsValid (Instruction::AddrSpaceCast,
312
+ Constant::getNullValue (VScaleV4PtrAS1Ty ),
313
+ VScaleV4PtrTy ));
329
314
// Same number of lanes, same address space.
330
315
EXPECT_FALSE (CastInst::castIsValid (Instruction::AddrSpaceCast,
331
- Constant::getNullValue (VScaleV4Int64PtrTy ),
332
- VScaleV4Int32PtrTy ));
316
+ Constant::getNullValue (VScaleV4PtrTy ),
317
+ VScaleV4PtrTy ));
333
318
334
319
// Bit casting fixed/scalable vector to scalable/fixed vectors.
335
320
EXPECT_FALSE (CastInst::castIsValid (Instruction::BitCast,
@@ -377,10 +362,10 @@ TEST(InstructionsTest, CastInst) {
377
362
// pointers
378
363
// First form
379
364
BasicBlock *BB = BasicBlock::Create (C);
380
- Constant *NullV2I32Ptr = Constant::getNullValue (V2Int32PtrTy );
365
+ Constant *NullV2I32Ptr = Constant::getNullValue (V2PtrTy );
381
366
auto Inst1 = CastInst::CreatePointerCast (NullV2I32Ptr, V2Int32Ty, " foo" , BB);
382
367
383
- Constant *NullVScaleV2I32Ptr = Constant::getNullValue (VScaleV2Int32PtrTy );
368
+ Constant *NullVScaleV2I32Ptr = Constant::getNullValue (VScaleV2PtrTy );
384
369
auto Inst1VScale = CastInst::CreatePointerCast (
385
370
NullVScaleV2I32Ptr, VScaleV2Int32Ty, " foo.vscale" , BB);
386
371
@@ -400,14 +385,12 @@ TEST(InstructionsTest, CastCAPI) {
400
385
LLVMContext C;
401
386
402
387
Type *Int8Ty = Type::getInt8Ty (C);
403
- Type *Int32Ty = Type::getInt32Ty (C);
404
388
Type *Int64Ty = Type::getInt64Ty (C);
405
389
406
390
Type *FloatTy = Type::getFloatTy (C);
407
391
Type *DoubleTy = Type::getDoubleTy (C);
408
392
409
- Type *Int8PtrTy = PointerType::get (C, 0 );
410
- Type *Int32PtrTy = PointerType::get (C, 0 );
393
+ Type *PtrTy = PointerType::get (C, 0 );
411
394
412
395
const Constant *C8 = Constant::getNullValue (Int8Ty);
413
396
const Constant *C64 = Constant::getNullValue (Int64Ty);
@@ -433,12 +416,11 @@ TEST(InstructionsTest, CastCAPI) {
433
416
EXPECT_EQ (LLVMFPExt,
434
417
LLVMGetCastOpcode (wrap (CF32), true , wrap (DoubleTy), true ));
435
418
436
- const Constant *CPtr8 = Constant::getNullValue (Int8PtrTy );
419
+ const Constant *CPtr8 = Constant::getNullValue (PtrTy );
437
420
438
421
EXPECT_EQ (LLVMPtrToInt,
439
422
LLVMGetCastOpcode (wrap (CPtr8), true , wrap (Int8Ty), true ));
440
- EXPECT_EQ (LLVMIntToPtr,
441
- LLVMGetCastOpcode (wrap (C8), true , wrap (Int8PtrTy), true ));
423
+ EXPECT_EQ (LLVMIntToPtr, LLVMGetCastOpcode (wrap (C8), true , wrap (PtrTy), true ));
442
424
443
425
Type *V8x8Ty = FixedVectorType::get (Int8Ty, 8 );
444
426
Type *V8x64Ty = FixedVectorType::get (Int64Ty, 8 );
@@ -448,26 +430,22 @@ TEST(InstructionsTest, CastCAPI) {
448
430
EXPECT_EQ (LLVMTrunc, LLVMGetCastOpcode (wrap (CV64), true , wrap (V8x8Ty), true ));
449
431
EXPECT_EQ (LLVMSExt, LLVMGetCastOpcode (wrap (CV8), true , wrap (V8x64Ty), true ));
450
432
451
- Type *Int32PtrAS1Ty = PointerType::get (C, 1 );
452
- Type *V2Int32PtrAS1Ty = FixedVectorType::get (Int32PtrAS1Ty , 2 );
453
- Type *V2Int32PtrTy = FixedVectorType::get (Int32PtrTy , 2 );
454
- const Constant *CV2ptr32 = Constant::getNullValue (V2Int32PtrTy );
433
+ Type *PtrAS1Ty = PointerType::get (C, 1 );
434
+ Type *V2PtrAS1Ty = FixedVectorType::get (PtrAS1Ty , 2 );
435
+ Type *V2PtrTy = FixedVectorType::get (PtrTy , 2 );
436
+ const Constant *CV2Ptr = Constant::getNullValue (V2PtrTy );
455
437
456
- EXPECT_EQ (LLVMAddrSpaceCast, LLVMGetCastOpcode ( wrap (CV2ptr32), true ,
457
- wrap (V2Int32PtrAS1Ty ), true ));
438
+ EXPECT_EQ (LLVMAddrSpaceCast,
439
+ LLVMGetCastOpcode ( wrap (CV2Ptr), true , wrap (V2PtrAS1Ty ), true ));
458
440
}
459
441
460
442
TEST (InstructionsTest, VectorGep) {
461
443
LLVMContext C;
462
444
463
445
// Type Definitions
464
- Type *I8Ty = IntegerType::get (C, 8 );
465
446
Type *I32Ty = IntegerType::get (C, 32 );
466
- PointerType *Ptri8Ty = PointerType::get (C, 0 );
467
- PointerType *Ptri32Ty = PointerType::get (C, 0 );
468
-
469
- VectorType *V2xi8PTy = FixedVectorType::get (Ptri8Ty, 2 );
470
- VectorType *V2xi32PTy = FixedVectorType::get (Ptri32Ty, 2 );
447
+ PointerType *PtrTy = PointerType::get (C, 0 );
448
+ VectorType *V2xPTy = FixedVectorType::get (PtrTy, 2 );
471
449
472
450
// Test different aspects of the vector-of-pointers type
473
451
// and GEPs which use this type.
@@ -478,8 +456,8 @@ TEST(InstructionsTest, VectorGep) {
478
456
Constant *C2xi32a = ConstantVector::get (ConstVa);
479
457
Constant *C2xi32b = ConstantVector::get (ConstVb);
480
458
481
- CastInst *PtrVecA = new IntToPtrInst (C2xi32a, V2xi32PTy );
482
- CastInst *PtrVecB = new IntToPtrInst (C2xi32b, V2xi32PTy );
459
+ CastInst *PtrVecA = new IntToPtrInst (C2xi32a, V2xPTy );
460
+ CastInst *PtrVecB = new IntToPtrInst (C2xi32b, V2xPTy );
483
461
484
462
ICmpInst *ICmp0 = new ICmpInst (ICmpInst::ICMP_SGT, PtrVecA, PtrVecB);
485
463
ICmpInst *ICmp1 = new ICmpInst (ICmpInst::ICMP_ULT, PtrVecA, PtrVecB);
@@ -495,10 +473,10 @@ TEST(InstructionsTest, VectorGep) {
495
473
GetElementPtrInst *Gep2 = GetElementPtrInst::Create (I32Ty, PtrVecB, C2xi32a);
496
474
GetElementPtrInst *Gep3 = GetElementPtrInst::Create (I32Ty, PtrVecB, C2xi32b);
497
475
498
- CastInst *BTC0 = new BitCastInst (Gep0, V2xi8PTy );
499
- CastInst *BTC1 = new BitCastInst (Gep1, V2xi8PTy );
500
- CastInst *BTC2 = new BitCastInst (Gep2, V2xi8PTy );
501
- CastInst *BTC3 = new BitCastInst (Gep3, V2xi8PTy );
476
+ CastInst *BTC0 = new BitCastInst (Gep0, V2xPTy );
477
+ CastInst *BTC1 = new BitCastInst (Gep1, V2xPTy );
478
+ CastInst *BTC2 = new BitCastInst (Gep2, V2xPTy );
479
+ CastInst *BTC3 = new BitCastInst (Gep3, V2xPTy );
502
480
503
481
Value *S0 = BTC0->stripPointerCasts ();
504
482
Value *S1 = BTC1->stripPointerCasts ();
0 commit comments