https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95799
Bug ID: 95799
Summary: Assumed conjunctions are not broken down into clauses
if their pureness is checked first
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.von.s at posteo dot de
Target Milestone: ---
In the attached sample, foo is compiled into returning a constant 1, while bar
will compare a to 0, even though bar’s assumption implies foo’s.
If I replace __builtin_pure_p() testing with a constant 1, both functions
compile to the same assembly code, returning a constant 1. If I change bar to
return (a >= 0 && b >= 0), it also compiles to returning a constant 1.
It seems as if the optimiser becomes unaware that conjunction elimination is a
valid rule of inference if the conjunction’s pureness is checked first.