File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,15 @@ static bool eliminateRedundantTemporaryCopyInFunc(IRFunc* func)
553
553
554
554
auto loadedPtr = loadInst->getPtr ();
555
555
556
+ // Check address space compatibility before optimization
557
+ auto destPtrType = as<IRPtrTypeBase>(destPtr->getDataType ());
558
+ auto loadedPtrType = as<IRPtrTypeBase>(loadedPtr->getDataType ());
559
+ SLANG_ASSERT (destPtrType);
560
+ SLANG_ASSERT (loadedPtrType);
561
+
562
+ if (destPtrType->getAddressSpace () != loadedPtrType->getAddressSpace ())
563
+ continue ;
564
+
556
565
// Do not optimize loads from semantic parameters because some semantics have
557
566
// builtin types that are vector types but pretend to be scalar types (e.g.,
558
567
// SV_DispatchThreadID is used as 'int id' but maps to 'float3
@@ -631,8 +640,7 @@ static bool eliminateRedundantTemporaryCopyInFunc(IRFunc* func)
631
640
goto unsafeToOptimize;
632
641
}
633
642
634
- // If we get here, all uses are safe to optimize
635
- // safeToOptimize:
643
+ // If we get here, all uses are safe to optimize.
636
644
637
645
// Replace all uses of destPtr with loadedPtr
638
646
destPtr->replaceUsesWith (loadedPtr);
You can’t perform that action at this time.
0 commit comments