[llvm] [TTI][TLI] Support scalable immediates with isLegalAddImmediate (PR #84173)

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 01:34:12 PDT 2024


================
@@ -0,0 +1,62 @@
+#include "AArch64Subtarget.h"
+#include "AArch64TargetMachine.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+
+#include "gtest/gtest.h"
+#include <initializer_list>
+#include <memory>
+
+using namespace llvm;
+
+namespace {
+
+struct TestCase {
+  int64_t Imm;
+  bool Result;
+};
+
+const std::initializer_list<TestCase> Tests = {
+    // ScalableImm, Result
+    // No change, easily 'supported'
+    {0, true},
+
+    // addvl increments by whole registers, range [-32,31]
+    // +(16 * vscale), one register's worth
+    {16, true},
+    // +(8 * vscale), half a register's worth
+    {8, false},
----------------
davemgreen wrote:

8 could be a `inch` if that wouldn't cause problems with your analysis. Same for 2 and 4.

https://github.com/llvm/llvm-project/pull/84173


More information about the llvm-commits mailing list