[PATCH] D24280: [IndVarSimplify] Wisely choose sext or zext when widening IV

Li Huang via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 13:27:09 PDT 2016


lihuang marked an inline comment as done.

================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:1159-1161
@@ -1148,4 +1158,5 @@
     cast<OverflowingBinaryOperator>(DU.NarrowUse);
-  if (IsSigned && OBO->hasNoSignedWrap())
+  ExtendKind ExtKind = ExtendKindMap[DU.NarrowDef];
+  if (ExtKind == SignExtended && OBO->hasNoSignedWrap())
     ExtendOperExpr = SE->getSignExtendExpr(
       SE->getSCEV(DU.NarrowUse->getOperand(ExtendOperIdx)), WideType);
----------------
sanjoy wrote:
> This was not done.
> 
> To be clear: I was suggesting adding a method:
> 
> ```
> ExtendKind getExtendKind(Instruction *I) {
>   auto It = ExtendKindMap.find(I);
>   assert(It != ExtendKindMap.end() && "Not found!");
>   return It->second;
> }
> ```
> 
> to the `WidenIV` class, and using that instead of `ExtendKindMap[DU.NarrowDef]` here and below.
I see... 

I think DenseMap should have an "at" like std::map::at, but it doesn't. Okay, I will add a method like you are suggesting here. 


https://reviews.llvm.org/D24280





More information about the llvm-commits mailing list