Skip to content

Commit 238ec08

Browse files
committed
[Hexagon] Fix unused variables for llvm#164421
1 parent bf55333 commit 238ec08

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,17 +2113,18 @@ Value *HvxIdioms::processVScatter(Instruction &In) const {
21132113
auto *InpTy = dyn_cast<VectorType>(In.getOperand(0)->getType());
21142114
assert(InpTy && "Cannot handle no vector type for llvm.scatter/gather");
21152115
unsigned InpSize = HVC.getSizeOf(InpTy);
2116-
unsigned Elements = HVC.length(InpTy);
2116+
auto *F = In.getFunction();
2117+
LLVMContext &Ctx = F->getContext();
21172118
auto *ElemTy = dyn_cast<IntegerType>(InpTy->getElementType());
21182119
assert(ElemTy && "llvm.scatter needs integer type argument");
21192120
unsigned ElemWidth = HVC.DL.getTypeAllocSize(ElemTy);
2120-
auto *F = In.getFunction();
2121-
LLVMContext &Ctx = F->getContext();
2122-
LLVM_DEBUG(dbgs() << "\n[Process scatter](" << In << ")\n"
2123-
<< *In.getParent() << "\n");
2124-
LLVM_DEBUG(dbgs() << " Input type(" << *InpTy << ") elements(" << Elements
2125-
<< ") VecLen(" << InpSize << ") type(" << *ElemTy
2126-
<< ") ElemWidth(" << ElemWidth << ")\n");
2121+
LLVM_DEBUG({
2122+
unsigned Elements = HVC.length(InpTy);
2123+
dbgs() << "\n[Process scatter](" << In << ")\n" << *In.getParent() << "\n";
2124+
dbgs() << " Input type(" << *InpTy << ") elements(" << Elements
2125+
<< ") VecLen(" << InpSize << ") type(" << *ElemTy << ") ElemWidth("
2126+
<< ElemWidth << ")\n";
2127+
});
21272128

21282129
IRBuilder Builder(In.getParent(), In.getIterator(),
21292130
InstSimplifyFolder(HVC.DL));
@@ -2190,9 +2191,9 @@ Value *HvxIdioms::processVScatter(Instruction &In) const {
21902191

21912192
auto V6_hi = HVC.HST.getIntrinsicId(Hexagon::V6_hi);
21922193
auto V6_lo = HVC.HST.getIntrinsicId(Hexagon::V6_lo);
2193-
Value *IndexHi =
2194+
[[maybe_unused]] Value *IndexHi =
21942195
HVC.createHvxIntrinsic(Builder, V6_hi, NT, UnpackedIndexes);
2195-
Value *IndexLo =
2196+
[[maybe_unused]] Value *IndexLo =
21962197
HVC.createHvxIntrinsic(Builder, V6_lo, NT, UnpackedIndexes);
21972198
LLVM_DEBUG(dbgs() << " UnpackedIndHi : " << *IndexHi << ")\n");
21982199
LLVM_DEBUG(dbgs() << " UnpackedIndLo : " << *IndexLo << ")\n");
@@ -2205,18 +2206,17 @@ Value *HvxIdioms::processVScatter(Instruction &In) const {
22052206
LLVM_DEBUG(dbgs() << " UnpackedValToScat: " << *UnpackedValueToScatter
22062207
<< ")\n");
22072208

2208-
Value *UVSHi =
2209+
[[maybe_unused]] Value *UVSHi =
22092210
HVC.createHvxIntrinsic(Builder, V6_hi, NT, UnpackedValueToScatter);
2210-
Value *UVSLo =
2211+
[[maybe_unused]] Value *UVSLo =
22112212
HVC.createHvxIntrinsic(Builder, V6_lo, NT, UnpackedValueToScatter);
22122213
LLVM_DEBUG(dbgs() << " UVSHi : " << *UVSHi << ")\n");
22132214
LLVM_DEBUG(dbgs() << " UVSLo : " << *UVSLo << ")\n");
22142215

22152216
// Create the mask for individual bytes
22162217
auto *QByteMask = get_i32_Mask(HVC, Builder, Ctx, 0x00ff00ff);
22172218
LLVM_DEBUG(dbgs() << " QByteMask : " << *QByteMask << "\n");
2218-
2219-
auto *ResHi = Builder.CreateIntrinsic(
2219+
[[maybe_unused]] auto *ResHi = Builder.CreateIntrinsic(
22202220
Type::getVoidTy(Ctx), Intrinsic::hexagon_V6_vscattermhq_128B,
22212221
{QByteMask, CastedDst, HVC.getConstInt(DEFAULT_HVX_VTCM_PAGE_SIZE),
22222222
IndexHi, UVSHi},
@@ -2249,9 +2249,9 @@ Value *HvxIdioms::processVScatter(Instruction &In) const {
22492249
}
22502250

22512251
Value *HvxIdioms::processVGather(Instruction &In) const {
2252-
auto *InpTy = dyn_cast<VectorType>(In.getOperand(0)->getType());
2252+
[[maybe_unused]] auto *InpTy = dyn_cast<VectorType>(In.getOperand(0)->getType());
22532253
assert(InpTy && "Cannot handle no vector type for llvm.gather");
2254-
auto *ElemTy = dyn_cast<PointerType>(InpTy->getElementType());
2254+
[[maybe_unused]] auto *ElemTy = dyn_cast<PointerType>(InpTy->getElementType());
22552255
assert(ElemTy && "llvm.gather needs vector of ptr argument");
22562256
auto *F = In.getFunction();
22572257
LLVMContext &Ctx = F->getContext();
@@ -2264,8 +2264,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
22642264
<< ElemTy->getAddressSpace() << ")\n");
22652265

22662266
// TODO: Handle masking of elements.
2267-
auto *MaskTy = dyn_cast<VectorType>(In.getOperand(2)->getType());
2268-
assert(MaskTy && "llvm.gather needs vector for mask");
2267+
assert(dyn_cast<VectorType>(In.getOperand(2)->getType()) &&
2268+
"llvm.gather needs vector for mask");
22692269
IRBuilder Builder(In.getParent(), In.getIterator(),
22702270
InstSimplifyFolder(HVC.DL));
22712271

@@ -2353,9 +2353,9 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
23532353

23542354
auto V6_hi = HVC.HST.getIntrinsicId(Hexagon::V6_hi);
23552355
auto V6_lo = HVC.HST.getIntrinsicId(Hexagon::V6_lo);
2356-
Value *IndexHi =
2356+
[[maybe_unused]] Value *IndexHi =
23572357
HVC.createHvxIntrinsic(Builder, V6_hi, NT, UnpackedIndexes);
2358-
Value *IndexLo =
2358+
[[maybe_unused]] Value *IndexLo =
23592359
HVC.createHvxIntrinsic(Builder, V6_lo, NT, UnpackedIndexes);
23602360
LLVM_DEBUG(dbgs() << " UnpackedIndHi : " << *IndexHi << ")\n");
23612361
LLVM_DEBUG(dbgs() << " UnpackedIndLo : " << *IndexLo << ")\n");
@@ -2365,14 +2365,14 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
23652365
// We use our destination allocation as a temp storage
23662366
// This is unlikely to work properly for masked gather.
23672367
auto V6_vgather = HVC.HST.getIntrinsicId(Hexagon::V6_vgathermhq);
2368-
auto GatherHi = Builder.CreateIntrinsic(
2368+
[[maybe_unused]] auto GatherHi = Builder.CreateIntrinsic(
23692369
Type::getVoidTy(Ctx), V6_vgather,
23702370
{Ptr, QByteMask, CastedPtr,
23712371
HVC.getConstInt(DEFAULT_HVX_VTCM_PAGE_SIZE), IndexHi},
23722372
nullptr);
23732373
LLVM_DEBUG(dbgs() << " GatherHi : " << *GatherHi << ")\n");
23742374
// Rematerialize the result
2375-
Value *LoadedResultHi = Builder.CreateLoad(
2375+
[[maybe_unused]] Value *LoadedResultHi = Builder.CreateLoad(
23762376
HVC.getHvxTy(HVC.getIntTy(32), false), Ptr, "temp_result_hi");
23772377
LLVM_DEBUG(dbgs() << " LoadedResultHi : " << *LoadedResultHi << "\n");
23782378
// Same for the low part. Here we use Gather to return non-NULL result
@@ -2392,10 +2392,10 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
23922392
// B . b . A . a . c . a . A . b . B . c . f . F . g . G . h . H
23932393
// Use vpack to gather them
23942394
auto V6_vpackeb = HVC.HST.getIntrinsicId(Hexagon::V6_vpackeb);
2395-
auto Res = Builder.CreateIntrinsic(
2395+
[[maybe_unused]] auto Res = Builder.CreateIntrinsic(
23962396
NT, V6_vpackeb, {LoadedResultHi, LoadedResultLo}, nullptr);
23972397
LLVM_DEBUG(dbgs() << " ScaledRes : " << *Res << "\n");
2398-
auto *StoreRes = Builder.CreateStore(Res, Ptr);
2398+
[[maybe_unused]] auto *StoreRes = Builder.CreateStore(Res, Ptr);
23992399
LLVM_DEBUG(dbgs() << " StoreRes : " << *StoreRes << "\n");
24002400
} else if (ElemWidth == 2) {
24012401
// v32i16
@@ -2473,18 +2473,19 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
24732473
Dst->eraseFromParent();
24742474
} else if (Qual == HvxIdioms::LLVM_Scatter) {
24752475
// Gather feeds directly into scatter.
2476-
auto *DstInpTy = cast<VectorType>(Dst->getOperand(1)->getType());
2477-
assert(DstInpTy && "Cannot handle no vector type for llvm.scatter");
2478-
unsigned DstInpSize = HVC.getSizeOf(DstInpTy);
2479-
unsigned DstElements = HVC.length(DstInpTy);
2480-
auto *DstElemTy = cast<PointerType>(DstInpTy->getElementType());
2481-
assert(DstElemTy && "llvm.scatter needs vector of ptr argument");
2482-
LLVM_DEBUG(dbgs() << " Gather feeds into scatter\n Values to scatter : "
2483-
<< *Dst->getOperand(0) << "\n");
2484-
LLVM_DEBUG(dbgs() << " Dst type(" << *DstInpTy << ") elements("
2485-
<< DstElements << ") VecLen(" << DstInpSize << ") type("
2486-
<< *DstElemTy << ") Access alignment("
2487-
<< *Dst->getOperand(2) << ")\n");
2476+
LLVM_DEBUG({
2477+
auto *DstInpTy = cast<VectorType>(Dst->getOperand(1)->getType());
2478+
assert(DstInpTy && "Cannot handle no vector type for llvm.scatter");
2479+
unsigned DstInpSize = HVC.getSizeOf(DstInpTy);
2480+
unsigned DstElements = HVC.length(DstInpTy);
2481+
auto *DstElemTy = cast<PointerType>(DstInpTy->getElementType());
2482+
assert(DstElemTy && "llvm.scatter needs vector of ptr argument");
2483+
dbgs() << " Gather feeds into scatter\n Values to scatter : "
2484+
<< *Dst->getOperand(0) << "\n";
2485+
dbgs() << " Dst type(" << *DstInpTy << ") elements(" << DstElements
2486+
<< ") VecLen(" << DstInpSize << ") type(" << *DstElemTy
2487+
<< ") Access alignment(" << *Dst->getOperand(2) << ")\n";
2488+
});
24882489
// Address of source
24892490
auto *Src = getPointer(IndexLoad);
24902491
if (!Src)
@@ -2539,7 +2540,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
25392540
// This most likely will not work properly since alloca gives us DDR
25402541
// stack location. This will be fixed once we teach compiler about VTCM.
25412542
AllocaInst *IndexesAlloca = Builder.CreateAlloca(NT);
2542-
auto *StoreIndexes = Builder.CreateStore(cstDataVector, IndexesAlloca);
2543+
[[maybe_unused]] auto *StoreIndexes =
2544+
Builder.CreateStore(cstDataVector, IndexesAlloca);
25432545
LLVM_DEBUG(dbgs() << " StoreIndexes : " << *StoreIndexes << "\n");
25442546
Value *LoadedIndex = Builder.CreateLoad(
25452547
IndexesAlloca->getAllocatedType(), IndexesAlloca, "reload_index");
@@ -2619,7 +2621,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
26192621
// Our indexes are represented as a constant. We need it in a reg.
26202622
AllocaInst *IndexesAlloca = Builder.CreateAlloca(NT);
26212623

2622-
auto *StoreIndexes = Builder.CreateStore(cstDataVector, IndexesAlloca);
2624+
[[maybe_unused]] auto *StoreIndexes =
2625+
Builder.CreateStore(cstDataVector, IndexesAlloca);
26232626
LLVM_DEBUG(dbgs() << " StoreIndexes : " << *StoreIndexes << "\n");
26242627
Value *LoadedIndex = Builder.CreateLoad(
26252628
IndexesAlloca->getAllocatedType(), IndexesAlloca, "reload_index");

0 commit comments

Comments
 (0)