[PATCH] D67977: [InstCombine] Use m_Zero instead of isNullValue() when checking if a GEP index is all zeroes to prevent an infinite loop.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:24:54 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46721bb7f521: [InstCombine] Use m_Zero instead of isNullValue() when checking if a GEP index… (authored by craig.topper).
Changed prior to commit:
https://reviews.llvm.org/D67977?vs=221843&id=221980#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67977/new/
https://reviews.llvm.org/D67977
Files:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
Index: llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
===================================================================
--- llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
+++ llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
@@ -651,3 +651,20 @@
%r = extractelement <2 x i32*> %w, i32 0
ret i32* %r
}
+
+ at global = external global [0 x i32], align 4
+
+; Make sure we don't get stuck in a loop turning the zeroinitializer into
+; <0, undef, undef, undef> and then changing it back.
+define i32* @zero_sized_type_extract(<4 x i64> %arg, i64 %arg1) {
+; CHECK-LABEL: @zero_sized_type_extract(
+; CHECK-NEXT: bb:
+; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds [0 x i32], <4 x [0 x i32]*> <[0 x i32]* @global, [0 x i32]* undef, [0 x i32]* undef, [0 x i32]* undef>, <4 x i64> <i64 0, i64 undef, i64 undef, i64 undef>, <4 x i64> [[ARG:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32*> [[TMP]], i64 0
+; CHECK-NEXT: ret i32* [[TMP2]]
+;
+bb:
+ %tmp = getelementptr inbounds [0 x i32], <4 x [0 x i32]*> <[0 x i32]* @global, [0 x i32]* @global, [0 x i32]* @global, [0 x i32]* @global>, <4 x i64> zeroinitializer, <4 x i64> %arg
+ %tmp2 = extractelement <4 x i32*> %tmp, i64 0
+ ret i32* %tmp2
+}
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1667,7 +1667,7 @@
// to an index of zero, so replace it with zero if it is not zero already.
Type *EltTy = GTI.getIndexedType();
if (EltTy->isSized() && DL.getTypeAllocSize(EltTy) == 0)
- if (!isa<Constant>(*I) || !cast<Constant>(*I)->isNullValue()) {
+ if (!isa<Constant>(*I) || !match(I->get(), m_Zero())) {
*I = Constant::getNullValue(NewIndexType);
MadeChange = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67977.221980.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190926/45ef0c4c/attachment.bin>
More information about the llvm-commits
mailing list