You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hmm, I tried fixing this on the rust side (for how we emit enum discriminants, rust-lang/rust#139729), but it looks like the "move inside the select" part runs before the "it's an add on both sides of eq" part: https://llvm.godbolt.org/z/7q3bsKMP9
Take the following IR, extracted from part of how Rust generates
==
on enums:Today, when optimizing
get_discr
InstCombine will change the https://llvm.godbolt.org/z/6Eq87h6h7to
which is reasonable on its own.
The problem, though, is that that makes things worse later in
discr_eq
.It's unable to undo that transformation after the inlining, and thus ends up as https://llvm.godbolt.org/z/31MdEhfcv
But there's no reason to do those
add
s any more -- they could be pulled outside theselect
s where they'd cancel out.Phrased as C, it's doing
when instead it could be doing
So InstCombine should be able to detect this case, and rewrite it back to
Alive2 proof of correctness for that: https://alive2.llvm.org/ce/z/AWCmDs
The text was updated successfully, but these errors were encountered: