https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117420
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |15.0 Last reconfirmed| |2024-11-02 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Before fre: # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0 _3 = (intD.6) _2; _4 = -_3; ... # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0 _8 = -_3; The value assigned to _8 is wrong I think. Before forwprop2: # RANGE [irange] int [-INF, +INF] MASK 0xfffffffe VALUE 0x0 _12 = _3 * -2; # RANGE [irange] int [0, 0][2, 2] MASK 0x2 VALUE 0x0 _7 = _12 & 2; # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0 _8 = _7 / 2; After: # RANGE [irange] int [0, 1] MASK 0x1 VALUE 0x0 _8 = -_3; Comes from: Matching expression match.pd:197, gimple-match-6.cc:22 Matching expression match.pd:2311, gimple-match-5.cc:64 Matching expression match.pd:197, gimple-match-6.cc:22 Matching expression match.pd:2878, gimple-match-8.cc:90 Matching expression match.pd:2883, gimple-match-4.cc:94 Matching expression match.pd:2311, gimple-match-5.cc:64 Applying pattern match.pd:5607, gimple-match-9.cc:17041 Applying pattern match.pd:990, gimple-match-1.cc:4265 Applying pattern match.pd:5508, gimple-match-10.cc:14607 gimple_simplified to _8 = -_3; /* Simplify (t * u) / v -> t * (u / v) if u is multiple of v. */ /* X / (1 << C) -> X /[ex] (1 << C) if the low C bits of X are clear. */ I think the issue is how with_possible_nonzero_bits2 is defined or its use in the pattern added by r15-4601-ge2e798b8607401 . It is causing to remove the &2.