This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Make Constant::getSplatValue work for scalable vector splats
ClosedPublic

Authored by ctetreau on Jun 23 2020, 3:16 PM.

Details

Summary

Make Constant::getSplatValue recognize scalable vector splats of the
form created by ConstantVector::getSplat. Add unit test to verify that
C == ConstantVector::getSplat(C)->getSplatValue() for fixed width and
scalable vector splats

Diff Detail

Event Timeline

ctetreau created this revision.Jun 23 2020, 3:16 PM
Herald added a project: Restricted Project. · View Herald Transcript
ctetreau updated this revision to Diff 273160.Jun 24 2020, 2:22 PM

appease clang-tidy

It looks like this affects a bunch of the pattern-matchers in PatternMatch.h; for example, m_APInt. Is that right?

llvm/lib/IR/Constants.cpp
1601

I don't see any reason the index here would be a ConstantInt, in general. (I mean, the result here would be pretty silly if it wasn't, but nothing is actually enforcing it.)

This comment was removed by ctetreau.
ctetreau updated this revision to Diff 274899.Jul 1 2020, 1:13 PM

add regression test

ctetreau updated this revision to Diff 274903.Jul 1 2020, 1:26 PM

address code review issues

ctetreau marked an inline comment as done.Jul 7 2020, 9:24 AM
efriedma accepted this revision.Jul 7 2020, 1:02 PM

LGTM

This revision is now accepted and ready to land.Jul 7 2020, 1:02 PM
This revision was automatically updated to reflect the committed changes.
ro added a subscriber: ro.Jul 8 2020, 7:23 AM

This patch broke ninja check-all on the Solaris buildbots, e.g. clang-solaris11-sparcv9:

[530/724] Building CXX object unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o
FAILED: unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o 
/opt/llvm-buildbot/bin/c++  -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_LANG_CXX11=1 -D_DEBUG -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iunittests/IR -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR -Iinclude -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/Support/Solaris -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/utils/unittest/googletest/include -I/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/utils/unittest/googlemock/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3     -Wno-variadic-macros -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o -MF unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o.d -o unittests/IR/CMakeFiles/IRTests.dir/ConstantsTest.cpp.o -c /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp
In file included from /usr/include/sys/select.h:27:0,
                 from /usr/include/sys/types.h:665,
                 from /usr/include/sys/wait.h:12,
                 from /usr/include/stdlib.h:16,
                 from /opt/llvm-buildbot/include/c++/7.4.0/cstdlib:75,
                 from /opt/llvm-buildbot/include/c++/7.4.0/bits/stl_algo.h:59,
                 from /opt/llvm-buildbot/include/c++/7.4.0/algorithm:62,
                 from /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/Support/MathExtras.h:17,
                 from /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/ADT/APInt.h:19,
                 from /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/ADT/APFloat.h:19,
                 from /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/include/llvm/IR/Constants.h:23,
                 from /opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp:9:
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp: In member function ‘virtual void llvm::{anonymous}::ConstantsTest_GetSplatValueRoundTrip_Test::TestBody()’:
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp:649:18: error: expected unqualified-id before numeric constant
     ElementCount SEC = {Min, true};
                  ^
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp:652:29: error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{1, FEC}’
     for (auto EC : {SEC, FEC}) {
                             ^
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/llvm/unittests/IR/ConstantsTest.cpp:652:29: note:   deduced conf

<sys/time.h> has #define SEC 1

Please fix.

@ro That's unfortunate. I pushed D83415, I'll submit without review when my local tests pass.