From 7b974b73ae0d0a2533431b3f22845ee9aeb3d837 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 26 Sep 2014 20:05:35 +0000 Subject: [IndVar] Don't widen loop compare unless IV user is sign extended. PR21030 llvm-svn: 218539 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp') diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 7cc34e1ad86..68a134ebfd8 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -650,7 +650,7 @@ namespace { struct WideIVInfo { PHINode *NarrowIV; Type *WidestNativeType; // Widest integer type created [sz]ext - bool IsSigned; // Was an sext user seen before a zext? + bool IsSigned; // Was a sext user seen before a zext? WideIVInfo() : NarrowIV(nullptr), WidestNativeType(nullptr), IsSigned(false) {} @@ -936,7 +936,11 @@ bool WidenIV::WidenLoopCompare(NarrowIVDefUse DU) { if (!Cmp) return false; - bool IsSigned = CmpInst::isSigned(Cmp->getPredicate()); + // Must be a signed compare. + if (!CmpInst::isSigned(Cmp->getPredicate())) + return false; + + // Must be a signed IV user. if (!IsSigned) return false; -- cgit v1.2.3