From 1c7c69c795b22d73d038dd9b49de921cfd9d3468 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 24 Jul 2020 17:28:01 +0100 Subject: [ValueTracking] Check for ConstantExpr before using recursive helpers. Make sure we do not call constainsConstantExpression/containsUndefElement on ConstantExpression, which is not supported. In particular, containsUndefElement/constainsConstantExpression are only supported on constants which are supported by getAggregateElement. Unfortunately there's no convenient way to check if a constant supports getAggregateElement, so just check for non-constantexpressions with vector type. Other users of those functions do so too. Reviewers: spatel, nikic, craig.topper, lebedev.ri, jdoerfert, aqjune Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D84512 --- llvm/lib/Analysis/ValueTracking.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Analysis/ValueTracking.cpp') diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 0ab2a13..116916a 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4794,8 +4794,8 @@ bool llvm::isGuaranteedNotToBeUndefOrPoison(const Value *V, isa(C) || isa(C)) return true; - if (C->getType()->isVectorTy()) - return !C->containsUndefElement() && !C->containsConstantExpression(); + if (C->getType()->isVectorTy() && !isa(C)) + return !C->containsConstantExpression() && !C->containsUndefElement(); } // Strip cast operations from a pointer value. -- cgit v1.1