This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFold] Return the correct type when folding a GEP with vector indices
ClosedPublic

Authored by davide on Sep 15 2017, 1:36 PM.

Details

Summary

As Eli pointed out (and I got wrong in the first place), langref says: "The getelementptr returns a vector of pointers, instead of a single address, when one or more of its arguments is a vector. In such cases, all vector arguments should have the same number of elements, and every scalar argument will be effectively broadcast into a vector during address calculation."

Costantfold for gep doesn't really take in account this paragraph, returning a pointer instead of a vector of pointer which triggers an assertion in RAUW, as we're trying to replace values with mistmatching types.

Diff Detail

Repository
rL LLVM

Event Timeline

davide created this revision.Sep 15 2017, 1:36 PM
efriedma edited edge metadata.Sep 15 2017, 1:44 PM

This looks right.

lib/IR/ConstantFold.cpp
2074 ↗(On Diff #115478)

Redundant call to PointerType::get()?

davide added inline comments.Sep 15 2017, 1:47 PM
lib/IR/ConstantFold.cpp
2074 ↗(On Diff #115478)

Yes, let me fix that before committing.

This revision was automatically updated to reflect the committed changes.