This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFold][SVE] Fix constant fold for FoldReinterpretLoadFromConstPtr.
ClosedPublic

Authored by huihuiz on Feb 11 2020, 10:39 AM.

Details

Summary

Bail out early for scalable vectors. As global variables are not expected
to be scalable.

Use explicit call of getFixedSize() to assert on places where scalable size
doesn't make sense.

Diff Detail

Event Timeline

huihuiz created this revision.Feb 11 2020, 10:39 AM

Current upstream crash with : include/llvm/Support/TypeSize.h:126: uint64_t llvm::TypeSize::getFixedSize() const: Assertion `!IsScalable && "Request for a fixed size on a scalable object"' failed.

test.ll

define <vscale x 2 x double> @load() {
  %r = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
  ret <vscale x 2 x double> %r
}

run: opt -S -constprop test.ll -o -

sdesmalen added inline comments.Feb 11 2020, 12:04 PM
llvm/lib/Analysis/ConstantFolding.cpp
522

It seems a bit arbitrary to special case this condition, given that the remainder of the function also doesn't work for scalable vectors (scalable vectors cannot be global variables according to the LangRef).

It probably makes more sense to bail out at the beginning of this function and to query the fixed-size explicit using getTypeSizeInBits().getFixed().

huihuiz updated this revision to Diff 244039.Feb 11 2020, 5:15 PM
huihuiz marked an inline comment as done.

Thanks Sander for the review!

huihuiz edited the summary of this revision. (Show Details)Feb 11 2020, 5:18 PM
sdesmalen accepted this revision.Feb 12 2020, 8:37 AM

Thanks, LGTM!

This revision is now accepted and ready to land.Feb 12 2020, 8:37 AM
This revision was automatically updated to reflect the committed changes.