These flags are documented as generating poison values for particular input values. As such, we should really be consistent about their handling with how we handle nsw/nuw/exact/inbounds.
In terms of the test changes, a couple notes:
- I did a bunch of cleanup in previous change series to reduce the test diff. Make sure you apply to ToT if applying locally.
- The freeze changes are correct, and desired.
- The shuffle changes look to be over conservative to me, but glancing at the history, it appears that's a complicated area. I think we should take the potential regression in quality here to have the consistency, and revisit the basic question of where we need to drop flags separately.
I looked at the code for this and related transforms in "foldSelectShuffle", and it's a mess.
We have lots of miscompiles like this:
https://alive2.llvm.org/ce/z/MHoacO
...and I don't think proposed but uncommitted patches like D93818 / D103874 resolve those.
We probably need to add an identity shuffle with undef/poison elements preserved from the original code. Otherwise, we are potentially leaking poison from the variable value in the original code. This could take a few patches to fix, so I wouldn't hold this patch up for it (but I'll try to get that sorted out soon).