Open dcci opened 2 months ago
to clarify: in the example, when number
is 4
, wouldn't the nested loop be expected to run forever?
to clarify: in the example, when
number
is4
, wouldn't the nested loop be expected to run forever?
That is correct, but I think you can slightly change the example keeping the codegen identical, e.g.
// Dead nested while loop, will never be reached
while (number + 1 == 5 && number * 2 == 9) {}
(Apologies, I reduced this incorrectly, but the point stands, I believe). New example: https://godbolt.org/z/ab5WqzE5K (& modified top post)
Description
https://godbolt.org/z/ab5WqzE5K
Reduced from a large example. This loop can be folded into a constant. Commenting this line (which is dead),
results in this code being generated:
So, the dead code prevents this loop from being optimized.
Reproduction
Expected behavior
The loop is folded into a constant
Environment
trunk/nightly x86-64
Additional information
No response