Skip to content

Commit 158d0ab

Browse files
googlewaltaokblast
authored andcommitted
[Hexagon] Fix unused variables for llvm#164421 (llvm#165012)
1 parent 4aec729 commit 158d0ab

File tree

1 file changed

+43
-38
lines changed

1 file changed

+43
-38
lines changed

llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Lines changed: 43 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,11 @@ 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 =
2253+
dyn_cast<VectorType>(In.getOperand(0)->getType());
22532254
assert(InpTy && "Cannot handle no vector type for llvm.gather");
2254-
auto *ElemTy = dyn_cast<PointerType>(InpTy->getElementType());
2255+
[[maybe_unused]] auto *ElemTy =
2256+
dyn_cast<PointerType>(InpTy->getElementType());
22552257
assert(ElemTy && "llvm.gather needs vector of ptr argument");
22562258
auto *F = In.getFunction();
22572259
LLVMContext &Ctx = F->getContext();
@@ -2264,8 +2266,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
22642266
<< ElemTy->getAddressSpace() << ")\n");
22652267

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

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

23542356
auto V6_hi = HVC.HST.getIntrinsicId(Hexagon::V6_hi);
23552357
auto V6_lo = HVC.HST.getIntrinsicId(Hexagon::V6_lo);
2356-
Value *IndexHi =
2358+
[[maybe_unused]] Value *IndexHi =
23572359
HVC.createHvxIntrinsic(Builder, V6_hi, NT, UnpackedIndexes);
2358-
Value *IndexLo =
2360+
[[maybe_unused]] Value *IndexLo =
23592361
HVC.createHvxIntrinsic(Builder, V6_lo, NT, UnpackedIndexes);
23602362
LLVM_DEBUG(dbgs() << " UnpackedIndHi : " << *IndexHi << ")\n");
23612363
LLVM_DEBUG(dbgs() << " UnpackedIndLo : " << *IndexLo << ")\n");
@@ -2365,14 +2367,14 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
23652367
// We use our destination allocation as a temp storage
23662368
// This is unlikely to work properly for masked gather.
23672369
auto V6_vgather = HVC.HST.getIntrinsicId(Hexagon::V6_vgathermhq);
2368-
auto GatherHi = Builder.CreateIntrinsic(
2370+
[[maybe_unused]] auto GatherHi = Builder.CreateIntrinsic(
23692371
Type::getVoidTy(Ctx), V6_vgather,
23702372
{Ptr, QByteMask, CastedPtr,
23712373
HVC.getConstInt(DEFAULT_HVX_VTCM_PAGE_SIZE), IndexHi},
23722374
nullptr);
23732375
LLVM_DEBUG(dbgs() << " GatherHi : " << *GatherHi << ")\n");
23742376
// Rematerialize the result
2375-
Value *LoadedResultHi = Builder.CreateLoad(
2377+
[[maybe_unused]] Value *LoadedResultHi = Builder.CreateLoad(
23762378
HVC.getHvxTy(HVC.getIntTy(32), false), Ptr, "temp_result_hi");
23772379
LLVM_DEBUG(dbgs() << " LoadedResultHi : " << *LoadedResultHi << "\n");
23782380
// Same for the low part. Here we use Gather to return non-NULL result
@@ -2392,10 +2394,10 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
23922394
// B . b . A . a . c . a . A . b . B . c . f . F . g . G . h . H
23932395
// Use vpack to gather them
23942396
auto V6_vpackeb = HVC.HST.getIntrinsicId(Hexagon::V6_vpackeb);
2395-
auto Res = Builder.CreateIntrinsic(
2397+
[[maybe_unused]] auto Res = Builder.CreateIntrinsic(
23962398
NT, V6_vpackeb, {LoadedResultHi, LoadedResultLo}, nullptr);
23972399
LLVM_DEBUG(dbgs() << " ScaledRes : " << *Res << "\n");
2398-
auto *StoreRes = Builder.CreateStore(Res, Ptr);
2400+
[[maybe_unused]] auto *StoreRes = Builder.CreateStore(Res, Ptr);
23992401
LLVM_DEBUG(dbgs() << " StoreRes : " << *StoreRes << "\n");
24002402
} else if (ElemWidth == 2) {
24012403
// v32i16
@@ -2473,18 +2475,19 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
24732475
Dst->eraseFromParent();
24742476
} else if (Qual == HvxIdioms::LLVM_Scatter) {
24752477
// 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");
2478+
LLVM_DEBUG({
2479+
auto *DstInpTy = cast<VectorType>(Dst->getOperand(1)->getType());
2480+
assert(DstInpTy && "Cannot handle no vector type for llvm.scatter");
2481+
unsigned DstInpSize = HVC.getSizeOf(DstInpTy);
2482+
unsigned DstElements = HVC.length(DstInpTy);
2483+
auto *DstElemTy = cast<PointerType>(DstInpTy->getElementType());
2484+
assert(DstElemTy && "llvm.scatter needs vector of ptr argument");
2485+
dbgs() << " Gather feeds into scatter\n Values to scatter : "
2486+
<< *Dst->getOperand(0) << "\n";
2487+
dbgs() << " Dst type(" << *DstInpTy << ") elements(" << DstElements
2488+
<< ") VecLen(" << DstInpSize << ") type(" << *DstElemTy
2489+
<< ") Access alignment(" << *Dst->getOperand(2) << ")\n";
2490+
});
24882491
// Address of source
24892492
auto *Src = getPointer(IndexLoad);
24902493
if (!Src)
@@ -2539,7 +2542,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
25392542
// This most likely will not work properly since alloca gives us DDR
25402543
// stack location. This will be fixed once we teach compiler about VTCM.
25412544
AllocaInst *IndexesAlloca = Builder.CreateAlloca(NT);
2542-
auto *StoreIndexes = Builder.CreateStore(cstDataVector, IndexesAlloca);
2545+
[[maybe_unused]] auto *StoreIndexes =
2546+
Builder.CreateStore(cstDataVector, IndexesAlloca);
25432547
LLVM_DEBUG(dbgs() << " StoreIndexes : " << *StoreIndexes << "\n");
25442548
Value *LoadedIndex = Builder.CreateLoad(
25452549
IndexesAlloca->getAllocatedType(), IndexesAlloca, "reload_index");
@@ -2619,7 +2623,8 @@ Value *HvxIdioms::processVGather(Instruction &In) const {
26192623
// Our indexes are represented as a constant. We need it in a reg.
26202624
AllocaInst *IndexesAlloca = Builder.CreateAlloca(NT);
26212625

2622-
auto *StoreIndexes = Builder.CreateStore(cstDataVector, IndexesAlloca);
2626+
[[maybe_unused]] auto *StoreIndexes =
2627+
Builder.CreateStore(cstDataVector, IndexesAlloca);
26232628
LLVM_DEBUG(dbgs() << " StoreIndexes : " << *StoreIndexes << "\n");
26242629
Value *LoadedIndex = Builder.CreateLoad(
26252630
IndexesAlloca->getAllocatedType(), IndexesAlloca, "reload_index");

0 commit comments

Comments
 (0)