[llvm-bugs] [Bug 50735] Missing optimization for member function with const attribute

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 17 05:44:09 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50735

Allen zhong <zhongyunde at tom.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |REOPENED

--- Comment #2 from Allen zhong <zhongyunde at tom.com> ---
thanks for your answer.

how about the following new case.
As member functions const will not change the member variable, so the value 
nPair.bins[0] will not change in function exclusion, then we can assert the
return value must be true?


class NPair /*: protected Pointers */ {
public:
  int bins[10];
  int exclusion(int n) const;
  // int exclusion(int n) __attribute__((const));
};

// extern int * __restrict bins;
extern class NPair nPair;

int foo (void)
{
  int tmp = nPair.bins[0];
  nPair.exclusion(1);

  return tmp == nPair.bins[0];
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210617/a1435587/attachment.html>


More information about the llvm-bugs mailing list