This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] peek through bitcasted vector/array pointer GEP operand
ClosedPublic

Authored by spatel on Mar 23 2018, 10:40 AM.

Details

Summary

The bitcast may be interfering with other combines or vectorization as shown in PR16739:
https://bugs.llvm.org/show_bug.cgi?id=16739

I haven't looked at GEPs very much, so I'm not sure if I've missed any safety checks here. I'm also not sure if this warning (still) applies:

http://llvm.org/docs/GetElementPtr.html#can-gep-index-into-vector-elements
"This hasn’t always been forcefully disallowed, though it’s not recommended. It leads to awkward special cases in the optimizers, and fundamental inconsistency in the IR. In the future, it will probably be outright disallowed."

...but it's 5 years since the bug was filed, and the IR looks the same.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Mar 23 2018, 10:40 AM

...but it's 5 years since the bug was filed, and the IR looks the same.

Yes, it's still a little awkward, but it would be too disruptive to change at this point.

That said, I'm surprised this matters; most pointer-related optimizations look through bitcasts.

That said, I'm surprised this matters; most pointer-related optimizations look through bitcasts.

Yes, I think you're correct. I assumed the differing types might trip up the vectorizers, but at least SLP doesn't seem to care in the motivating example.

So not sure if we want to add code for this. It does still remove the bitcast from PR16739, so the IR shrinks even if we don't vectorize it as expected.

This revision is now accepted and ready to land.Apr 17 2018, 2:50 PM
xbolva00 accepted this revision.Apr 17 2018, 3:11 PM
This revision was automatically updated to reflect the committed changes.