[PATCH] D110158: [Analysis] Fix issues when querying vscale attributes on functions
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 01:58:23 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2634fc6abe7: [Analysis] Fix issues when querying vscale attributes on functions (authored by david-arm).
Changed prior to commit:
https://reviews.llvm.org/D110158?vs=374492&id=374761#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110158/new/
https://reviews.llvm.org/D110158
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/unittests/Analysis/ValueTrackingTest.cpp
Index: llvm/unittests/Analysis/ValueTrackingTest.cpp
===================================================================
--- llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -12,6 +12,7 @@
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
@@ -1597,6 +1598,22 @@
EXPECT_EQ(Known.getMaxValue(), 131071);
}
+TEST_F(ComputeKnownBitsTest, ComputeKnownBitsUnknownVScale) {
+ Module M("", Context);
+ IRBuilder<> Builder(Context);
+ Function *TheFn =
+ Intrinsic::getDeclaration(&M, Intrinsic::vscale, {Builder.getInt32Ty()});
+ CallInst *CI = Builder.CreateCall(TheFn, {}, {}, "");
+
+ KnownBits Known = computeKnownBits(CI, M.getDataLayout(), /* Depth */ 0);
+ delete CI;
+
+ // There is no parent function so we cannot look up the vscale_range
+ // attribute to determine the number of bits.
+ EXPECT_EQ(Known.One.getZExtValue(), 0u);
+ EXPECT_EQ(Known.Zero.getZExtValue(), 0u);
+}
+
// 512 + [32, 64) doesn't produce overlapping bits.
// Make sure we get all the individual bits properly.
TEST_F(ComputeKnownBitsTest, ComputeKnownBitsAddWithRangeNoOverlap) {
Index: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -963,7 +963,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (Trunc.getFunction() &&
+ Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = Trunc.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
@@ -1334,7 +1335,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (CI.getFunction() &&
+ CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = CI.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
@@ -1604,7 +1606,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (CI.getFunction() &&
+ CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = CI.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -1685,7 +1685,8 @@
Known.Zero.setBitsFrom(31);
break;
case Intrinsic::vscale: {
- if (!II->getFunction()->hasFnAttribute(Attribute::VScaleRange))
+ if (!II->getParent() ||
+ !II->getFunction()->hasFnAttribute(Attribute::VScaleRange))
break;
auto VScaleRange = II->getFunction()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110158.374761.patch
Type: text/x-patch
Size: 3323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210924/738767e1/attachment.bin>
More information about the llvm-commits
mailing list