@@ -394,12 +394,16 @@ define void @foo(ptr noalias %ptr, float %val) {
394
394
395
395
TEST_F (SeedBundleTest, VectorStores) {
396
396
parseIR (C, R"IR(
397
- define void @foo(ptr noalias %ptr, <2 x float> %val ) {
397
+ define void @foo(ptr noalias %ptr, <2 x float> %val0, i64 %val1 ) {
398
398
bb:
399
399
%ptr0 = getelementptr float, ptr %ptr, i32 0
400
400
%ptr1 = getelementptr float, ptr %ptr, i32 1
401
- store <2 x float> %val, ptr %ptr1
402
- store <2 x float> %val, ptr %ptr0
401
+ %ptr2 = getelementptr i64, ptr %ptr, i32 2
402
+ store <2 x float> %val0, ptr %ptr1
403
+ store <2 x float> %val0, ptr %ptr0
404
+ store atomic i64 %val1, ptr %ptr2 unordered, align 8
405
+ store volatile i64 %val1, ptr %ptr2
406
+
403
407
ret void
404
408
}
405
409
)IR" );
@@ -418,14 +422,16 @@ define void @foo(ptr noalias %ptr, <2 x float> %val) {
418
422
sandboxir::SeedCollector SC (&*BB, SE);
419
423
420
424
// Find the stores
421
- auto It = std::next (BB->begin (), 2 );
425
+ auto It = std::next (BB->begin (), 3 );
422
426
// StX with X as the order by offset in memory
423
427
auto *St1 = &*It++;
424
428
auto *St0 = &*It++;
425
429
426
430
auto StoreSeedsRange = SC.getStoreSeeds ();
427
431
EXPECT_EQ (range_size (StoreSeedsRange), 1u );
428
432
auto &SB = *StoreSeedsRange.begin ();
433
+ // isValidMemSeed check: The atomic and volatile stores should not
434
+ // be included in the bundle, but the vector stores should be.
429
435
ExpectThatElementsAre (SB, {St0, St1});
430
436
}
431
437
@@ -466,5 +472,50 @@ define void @foo(ptr noalias %ptr, float %v, <2 x float> %val) {
466
472
auto StoreSeedsRange = SC.getStoreSeeds ();
467
473
EXPECT_EQ (range_size (StoreSeedsRange), 1u );
468
474
auto &SB = *StoreSeedsRange.begin ();
475
+ // isValidMemSeedCheck here: all of the three stores should be included.
469
476
ExpectThatElementsAre (SB, {St0, St1, St3});
470
477
}
478
+
479
+ TEST_F (SeedBundleTest, VectorLoads) {
480
+ parseIR (C, R"IR(
481
+ define void @foo(ptr noalias %ptr, <2 x float> %val0) {
482
+ bb:
483
+ %ptr0 = getelementptr float, ptr %ptr, i32 0
484
+ %ptr1 = getelementptr float, ptr %ptr, i32 1
485
+ %r0 = load <2 x float>, ptr %ptr0
486
+ %r1 = load <2 x float>, ptr %ptr1
487
+ %r2 = load atomic i64, ptr %ptr0 unordered, align 8
488
+ %r3 = load volatile i64, ptr %ptr1
489
+ %r4 = load void()*, ptr %ptr1
490
+
491
+ ret void
492
+ }
493
+ )IR" );
494
+ Function &LLVMF = *M->getFunction (" foo" );
495
+ DominatorTree DT (LLVMF);
496
+ TargetLibraryInfoImpl TLII;
497
+ TargetLibraryInfo TLI (TLII);
498
+ DataLayout DL (M->getDataLayout ());
499
+ LoopInfo LI (DT);
500
+ AssumptionCache AC (LLVMF);
501
+ ScalarEvolution SE (LLVMF, TLI, AC, DT, LI);
502
+
503
+ sandboxir::Context Ctx (C);
504
+ auto &F = *Ctx.createFunction (&LLVMF);
505
+ auto BB = F.begin ();
506
+ sandboxir::SeedCollector SC (&*BB, SE);
507
+
508
+ // Find the loads
509
+ auto It = std::next (BB->begin (), 2 );
510
+ // StX with X as the order by offset in memory
511
+ auto *Ld0 = cast<sandboxir::LoadInst>(&*It++);
512
+ auto *Ld1 = cast<sandboxir::LoadInst>(&*It++);
513
+
514
+ auto LoadSeedsRange = SC.getLoadSeeds ();
515
+ EXPECT_EQ (range_size (LoadSeedsRange), 2u );
516
+ auto &SB = *LoadSeedsRange.begin ();
517
+ // isValidMemSeed check: The atomic and volatile loads should not
518
+ // be included in the bundle, the vector stores should be, but the
519
+ // void-typed load should not.
520
+ ExpectThatElementsAre (SB, {Ld0, Ld1});
521
+ }
0 commit comments