This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFold][SVE] Fix constant folding for scalable vector compare instruction.
ClosedPublic

Authored by huihuiz on Jan 30 2020, 4:42 PM.

Details

Summary

Do not iterate on scalable vector. Also do not return constant scalable vector
from ConstantInt::get().
Fix result type by using getElementCount() instead of getNumElements().

Diff Detail

Event Timeline

huihuiz created this revision.Jan 30 2020, 4:42 PM

current upstream crash at : llvm/lib/IR/Value.cpp:404: void llvm::Value::doRAUW(llvm::Value *, llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.

take test.ll

define <vscale x 4 x i1> @icmp_undef() {
  %r = icmp eq <vscale x 4 x i32> undef, undef
  ret <vscale x 4 x i1> %r
}

run : ./bin/opt -S -constprop t.ll -o -

We should fix ConstantInt::get and Constant::getAllOnesValue to work with scalable types; it doesn't make sense to avoid them given we can generate an appropriate constant (splat using insertelement/shufflevector).

huihuiz updated this revision to Diff 243748.Feb 10 2020, 11:34 PM

Thanks Eli for the feedback!

Supporting scalable vector for ConstantInt::get() and Constant::getAllOnesValue() in D74386

This revision is now accepted and ready to land.Feb 11 2020, 2:12 PM
This revision was automatically updated to reflect the committed changes.