[Bug c++/100956] Unused variable warnings ignore "if constexpr" blocks where variables are conditionally used

2021-06-08 Thread mattreecebentley at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100956

--- Comment #2 from Matt Bentley  ---
Thank you - I'm aware GCC might optimize it out (and failed to test with
GCC10), at least in O2 mode, but other compilers might not, hence the code.

[Bug c++/100956] New: Unused variable warnings ignore "if constexpr" blocks where variables are conditionally used

2021-06-07 Thread mattreecebentley at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100956

Bug ID: 100956
   Summary: Unused variable warnings ignore "if constexpr" blocks
where variables are conditionally used
   Product: gcc
   Version: 9.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mattreecebentley at gmail dot com
  Target Milestone: ---

For example, as part of a container class:

void remove_memory_blocks(pointer back_element_in_final_block)
{
   if constexpr(!std::is_trivially_destructible::value)
   {
  // destroy each element in each memory block until the back_element is
reached
   }

   // remove memory blocks
}


If element_type is_trivially_destructible, G++ will warn that
back_element_in_final_block is unused every time the function is called.

Ideally this warning should be performed before constexpr blocks are removed by
a parser (I have no idea what the procedure is for GCC, I'm just guessing here)

[Bug middle-end/96750] 10-12% performance decrease in benchmark going from GCC8 to GCC9/GCC10

2020-09-27 Thread mattreecebentley at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96750

--- Comment #6 from Matt Bentley  ---
Created attachment 49278
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49278=edit
Demonstration of code which doesn't trigger the performance anomaly.

plf_colony_fast.h does not trigger the problem, has one branch eliminated in
each insert/emplace function.

[Bug middle-end/96750] 10-12% performance decrease in benchmark going from GCC8 to GCC9/GCC10

2020-09-27 Thread mattreecebentley at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96750

--- Comment #5 from Matt Bentley  ---
If anyone out there is interested in working on this, 
I found the smallest change possible to create the same performance as GCC8- 
it is literally eliminating one branch possibility in one function
(move-insert).

The branch in question questions whether there are existing memory blocks to
re-use or if we need to create a new memory block. For example, if the
reserve() function has been called there will be existing memory blocks to
re-use.

However the performance drop occurs whether or not there are memory blocks to
reuse. The actual if statement is irrelevant. I have tested and can remove all
instances of memory block storage (reserve(), erase()) and problem still exists
if this one branch is still in insert.

I've attached the source files to demonstrate this above, including one
plf_colony.h with the branch removed (renamed to plf_colony_fast.h), so you can
see what difference there is.
This code is all zlib license, free to share, but is early beta so don't
redistribute please.

Thanks,
Matt

ps. For consistency I've also removed the non-move-insert and emplace instances
of this branch statement, even though they won't be called by the benchmark
code in a C++11-compliant compiler.