New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't remove shufflevector if input might be poison #43530
Comments
Similar optimization in Transforms/InstCombine/shuffle_select.ll:
|
This seems unfortunate. Can you please remind me why we choose these semantics? It seems to me that (add undef, poison) should be poison, not undef, no? |
See the discussion here: #43303 Short version, this semantics is needed if we want to support things introduction of broadcast: %t = insertelement <4 x float> undef, float %arg, i32 1 IMHO, the correct fix is to introduce a poison value and use that to initialize vectors. Also, a poison mask would give poison, so no more of these problems of choosing "undef or poison -> undef". Using shufflevector to stop poison isn't ideal, since then we can't remove it. |
That makes sense to me. I expect that in many cases where we use an 'undef' constant, a poison constant would be a better fit. It's the "I need to put a value here, but the program shouldn't ever actually depend on it" value, and at least informally, that's how undef has often been used (as opposed to "the program can depend on it, and it's arbitrary, but that won't matter to the user" undef semantics).
|
This is a nice succinct explanation of the difference between the two, that seems to be missing from the langref's explanation of the constants. |
mentioned in issue #47292 |
Juneyoung's patches so they don't get lost: |
FWIW, I've switched the semantics of shufflevector in Alive2 to yield poison elements when idx is OOB.
I've inspected all of them. They are all related with mixed insertelement starting with undef vectors. I suggest we restrict these optimizations to just poison vectors as undef vectors should be very rare nowadays. |
Extended Description
Test case from Transforms/InstCombine/insert-extract-shuffle.ll:
This is with the semantics of LangRef, where an undef mask stops propagation of poison. This implies this kind of shufflevectors can't be removed.
The text was updated successfully, but these errors were encountered: