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

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 13:12:46 PDT 2016


sanjoy requested changes to this revision.
sanjoy added a comment.
This revision now requires changes to proceed.

Only one thing left. :)


================
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);
----------------
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.


https://reviews.llvm.org/D24280





More information about the llvm-commits mailing list