[InstCombine] replace undef in vector constant for safe shift transform (PR45447)
authorSanjay Patel <spatel@rotateright.com>
Thu, 9 Apr 2020 11:55:55 +0000 (07:55 -0400)
committerSanjay Patel <spatel@rotateright.com>
Thu, 9 Apr 2020 12:00:46 +0000 (08:00 -0400)
commit812970edda3617fcee98729fc33e2ca8d226a01d
tree31ffea5e87360bbc64007ccf1d2c2eec23ba840a
parent8b3d3921b0684dd71b7486c01a447fdb378c2ac3
[InstCombine] replace undef in vector constant for safe shift transform (PR45447)

As noted in PR45447, we have a vector-constant-with-undef-element transform bug:
https://bugs.llvm.org/show_bug.cgi?id=45447

We replace undefs with a safe constant (0 or -1) based on the (non-)negative
predicate constraint.

So this is correct:
http://volta.cs.utah.edu:8080/z/WZE36H
...but this is not:
http://volta.cs.utah.edu:8080/z/boj8gJ

Previously, we were relying on getSafeVectorConstantForBinop() in the related fold (D76800).
But that's making an assumption about what qualifies as "safe", and that assumption may
not always hold.

Differential Revision: https://reviews.llvm.org/D77739
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/vector-xor.ll