https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78879

--- Comment #11 from Yuan Pengfei <coolypf at qq dot com> ---
It seems that if a variable has two or more constant values, gcc does not treat
it as a constant and b_c_p returns 0. Is that correct?

If so, I might have figured out where the problem is.

With unordered_remove, the case is:

sector_size {256, 512, 1024, 2048, 4096}
  |
  +-----------+-----------+ ...
  | {256}     | {512}
b_c_p       b_c_p
  |           |
  +-----------+
  | b_c_p == 1
"calculations for constant sector_size"

In "calculations for constant sector_size", sector_size has two or more
constant values, making gcc not treat it as a constant. Therefore, the call to
ilog2_NaN is not optimized away.

With ordered_remove, the case is:

sector_size {256, 512, 1024, 2048, 4096}
  |
  +-----------------------+ ...
  | {256, 512}
b_c_p
  | b_c_p == 0
"calculations for non-constant sector_size"

The call to ilog2_NaN is optimized away with "calculations for constant
sector_size".

Reply via email to