In at least one case, DAGCombiner calls isTruncateFree() with operands in reverse order. Fixed that and improved comments to make the direction and corner case behavior more obvious.
Diff Detail
Event Timeline
Removed the assert() due to cases that call isTruncateFree without regard to type size. Improved comment for these odd cases.
Verified regression checks pass.
include/llvm/Target/TargetLowering.h | ||
---|---|---|
1527–1528 | Would be nice to fix this one too. |
Tried to address review comments from Jonathan Roelofs. NFC from previous patch. Updated patch title text and summary to remove statement about asserts.
Unfortunately, I do not see a succinct way to test for this. The bug is buried in a cost analysis algorithm. The problem was detected by investigating nonsense truncation cases, i.e. where From < To. By inspection, we see the original code places the destination as "From" and the operand as "To" in the truncation check.
I verified all "make check" tests pass with the patch.
Thanks,
-steve
Fix more old style comments caught by Jonathan. NFC.
The meaning of one of the original comments is mysterious. This patch does not clarify it.
include/llvm/Target/TargetLowering.h | ||
---|---|---|
1567–1575 | Now that I've read it again, I don't get what it's trying to say either... I can kind of see it making sense if the operands were accidentally swapped. |
include/llvm/Target/TargetLowering.h | ||
---|---|---|
1567–1575 | Ya, I tried for a while to assimilate this one. Confusing comments are often worse than nothing. If you aprove, I will update the patch to delete this comment. |
This LGTM. If you have a test case, great, otherwise you can commit without one.
include/llvm/Target/TargetLowering.h | ||
---|---|---|
1567–1575 | Exactly what would you want to delete? Perhaps we should just reword this to say that the function should return true when it is likely that the truncate can be freely folded with an instruction defining a value of FromTy. If the defining instruction is unknown (because you're looking at a function argument, PHI, etc.) then you may need an explicit truncate, and that's not necessarily free (but this function does not deal with those cases). |
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245385 91177308-0d34-0410-b5e6-96231b3b80d8
Would be nice to fix this one too.