[Bug 52173] New: [polly] buildFADOutermostDimensionLoad - suspicious unused sub

5 views
Skip to first unread message

bugzill...@llvm.org

unread,
Oct 14, 2021, 5:24:33 AM10/14/21
to poll...@googlegroups.com
Bug ID 52173
Summary [polly] buildFADOutermostDimensionLoad - suspicious unused sub
Product Polly
Version unspecified
Hardware PC
OS Windows NT
Status NEW
Severity enhancement
Priority P
Component isl
Assignee poll...@googlegroups.com
Reporter llvm...@redking.me.uk
CC llvm...@lists.llvm.org, ll...@meinersbur.de, siddhar...@research.iiit.ac.in

This was reported as a dead code warning on coverity:

/// Generate the computation of the size of the outermost dimension from the
/// Fortran array descriptor (in this case, `@g_arr`). The final `%size`
/// contains the size of the array.
///
/// %arrty = type { i8*, i64, i64, [3 x %desc.dimensionty] }
/// %desc.dimensionty = type { i64, i64, i64 }
/// @g_arr = global %arrty zeroinitializer, align 32
/// ...
/// %0 = load i64, i64* getelementptr inbounds
///                       (%arrty, %arrty* @g_arr, i64 0, i32 3, i64 0, i32 2)
/// %1 = load i64, i64* getelementptr inbounds
///                      (%arrty, %arrty* @g_arr, i64 0, i32 3, i64 0, i32 1)
/// %2 = sub nsw i64 %0, %1
/// %size = add nsw i64 %2, 1
static Value *buildFADOutermostDimensionLoad(Value *GlobalDescriptor,
                                             PollyIRBuilder &Builder,
                                             std::string ArrayName) {
  assert(GlobalDescriptor && "invalid global descriptor given");
  Type *Ty = GlobalDescriptor->getType()->getPointerElementType();

  Value *endIdx[4] = {Builder.getInt64(0), Builder.getInt32(3),
                      Builder.getInt64(0), Builder.getInt32(2)};
  Value *endPtr = Builder.CreateInBoundsGEP(Ty, GlobalDescriptor, endIdx,
                                            ArrayName + "_end_ptr");
  Type *type = cast<GEPOperator>(endPtr)->getResultElementType();
  assert(isa<IntegerType>(type) && "expected type of end to be integral");

  Value *end = Builder.CreateLoad(type, endPtr, ArrayName + "_end");

  Value *beginIdx[4] = {Builder.getInt64(0), Builder.getInt32(3),
                        Builder.getInt64(0), Builder.getInt32(1)};
  Value *beginPtr = Builder.CreateInBoundsGEP(Ty, GlobalDescriptor, beginIdx,
                                              ArrayName + "_begin_ptr");
  Value *begin = Builder.CreateLoad(type, beginPtr, ArrayName + "_begin");

  Value *size =
      Builder.CreateNSWSub(end, begin, ArrayName + "_end_begin_delta");

  size = Builder.CreateNSWAdd(
      end, ConstantInt::get(type, 1, /* signed = */ true), ArrayName +
"_size");

  return size;
}

The first 'size' is created but never used; from the comment at the top, I
believe the code should be something like:

/// %0 = load i64, i64* getelementptr inbounds
///                       (%arrty, %arrty* @g_arr, i64 0, i32 3, i64 0, i32 2)
/// %1 = load i64, i64* getelementptr inbounds
///                      (%arrty, %arrty* @g_arr, i64 0, i32 3, i64 0, i32 1)
/// %2 = sub nsw i64 %0, %1
/// %size = add nsw i64 %2, 1

....

  Value *delta =
      Builder.CreateNSWSub(end, begin, ArrayName + "_end_begin_delta");

  Value *size = Builder.CreateNSWAdd(
      delta, ConstantInt::get(type, 1, /* signed = */ true), ArrayName +
"_size");

  return size;
}


You are receiving this mail because:
  • You are the assignee for the bug.

bugzill...@llvm.org

unread,
Oct 14, 2021, 3:15:50 PM10/14/21
to poll...@googlegroups.com
Michael Kruse changed bug 52173
What Removed Added
Fixed By Commit(s)   19db33c06e7e7b5991f8f4b22d3bd7651b1f854d
Status NEW RESOLVED
Resolution --- FIXED

Comment # 2 on bug 52173 from Michael Kruse
It was DragonEgg, not llvm-gcc. I also should have read your entire comment
before  coming to the same conclusion.

Fixed in https://reviews.llvm.org/rG19db33c06e7e7b5991f8f4b22d3bd7651b1f854d

Reply all
Reply to author
Forward
0 new messages