[PATCH] D129477: [InstCombine][SVE] Bail out of isSafeToLoadUnconditionally for scalable types
Peter Waller via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 11 04:09:07 PDT 2022
peterwaller-arm created this revision.
peterwaller-arm added reviewers: c-rhodes, paulwalker-arm, sdesmalen, david-arm.
Herald added subscribers: psnobl, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
peterwaller-arm requested review of this revision.
Herald added subscribers: llvm-commits, alextsao1999.
Herald added a project: LLVM.
`isSafeToLoadUnconditionally` currently assumes sized types. Bail out for now.
This fixes a TypeSize warning reachable from instcombine via (load (select
cond, ptr, ptr)).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129477
Files:
llvm/lib/Analysis/Loads.cpp
llvm/test/Transforms/InstCombine/scalable-select.ll
Index: llvm/test/Transforms/InstCombine/scalable-select.ll
===================================================================
--- llvm/test/Transforms/InstCombine/scalable-select.ll
+++ llvm/test/Transforms/InstCombine/scalable-select.ll
@@ -15,3 +15,17 @@
%d = select <vscale x 1 x i1> %m, <vscale x 1 x i32> %c, <vscale x 1 x i32> %b
ret <vscale x 1 x i32> %d
}
+
+define <vscale x 2 x i64> @load_scalable_of_selected_ptrs(ptr %p0, ptr %p1, i64 %idx) {
+entry:
+ ; Test introduced in response to a TypeSize warning arising from isSafeToLoadUnconditionally via instcombine.
+ ; deref (p0[0] < p1[0] ? p0 : p1) as <vscale x 2 x i64>.
+ %arrayidx0 = getelementptr inbounds i32, ptr %p0, i64 %idx
+ %arrayidx1 = getelementptr inbounds i32, ptr %p1, i64 %idx
+ %l0 = load i32, ptr %arrayidx0
+ %l1 = load i32, ptr %arrayidx1
+ %cmp = icmp slt i32 %l0, %l1
+ %sel = select i1 %cmp, ptr %arrayidx0, ptr %arrayidx1
+ %ret = load <vscale x 2 x i64>, ptr %sel
+ ret <vscale x 2 x i64> %ret
+}
Index: llvm/lib/Analysis/Loads.cpp
===================================================================
--- llvm/lib/Analysis/Loads.cpp
+++ llvm/lib/Analysis/Loads.cpp
@@ -405,7 +405,10 @@
Instruction *ScanFrom,
const DominatorTree *DT,
const TargetLibraryInfo *TLI) {
- APInt Size(DL.getIndexTypeSizeInBits(V->getType()), DL.getTypeStoreSize(Ty));
+ TypeSize TySize = DL.getTypeStoreSize(Ty);
+ if (TySize.isScalable())
+ return false;
+ APInt Size(DL.getIndexTypeSizeInBits(V->getType()), TySize);
return isSafeToLoadUnconditionally(V, Alignment, Size, DL, ScanFrom, DT, TLI);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129477.443595.patch
Type: text/x-patch
Size: 1716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220711/e8e74067/attachment.bin>
More information about the llvm-commits
mailing list