[PATCH] D38313: [InstCombine] Introducing Aggressive Instruction Combine pass

Zvi Rackover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 19 00:51:03 PST 2017


zvi added inline comments.


================
Comment at: lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp:210
+    MinBitWidth = Ty ? Ty->getScalarSizeInBits() : OrigBitWidth;
+  } else { // MinBitWidth == ValidBitWidth
+    // In this case the expression can be evaluated with the trunc instruction
----------------
craig.topper wrote:
> zvi wrote:
> > craig.topper wrote:
> > > Isn't this MinBitWidth == TruncBitWidth?
> > Your observation is correct but the comment is also correct and it explains something that may not be obvious.
> > At this point, we completed visiting the expression tree starting from the truncate's operand and found 'MinBitWidth' by taking the max of all min-bit-width requirements of the predecessors. Now, since this is a truncate instruction, and by construction of the expression tree it follows that the computed MinBitWidth can never be less than the truncate's return types's size in bits or in other words MinBitWidth >= TruncBitWidth.
> > The case of MinBitWidth > TruncBitWidth is hand;ed in the then block just above, and what remains in to handle the MinBitWidth == TruncBitWidth in the else block here.
> > I can put this in a comment if you think it would be helpful.
> I was just saying that it should say TruncBitWidth not ValidBitWidth right?
Ah, right :)


https://reviews.llvm.org/D38313





More information about the llvm-commits mailing list