Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3315–3325 | return 1 here, we don't want to fall through to computeKnownBits (the ComptueNumSignBits will have already used it if possible). | |
3319 | I don't think this is right for vectors. You're taking the size of the full vector here, not of the vector elements. Using U->getOperand(0)->getType()->getScalarSizeInBits() should be fine here (as trunc is only defined on integers, so we don't need fancy DL machinery). Please also add a vector test. | |
3320 | nit: Omit braces for single-line if. |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3315–3325 | I don't think that's the case? We invoked ComputeNumSignBits on the input to the trunc, so we haven't yet had an opportunity to use computeKnownBits results for the output. |
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3315–3325 | Hm, I guess you are right. If the truncated part doesn't have sign bits and the part directly following has more than one known zero/one bits, then the computeKnownBits() call is still useful. Do we already have a test that fails if it is removed? | |
llvm/test/Transforms/InstCombine/vector-trunc.ll | ||
25 | It would be slightly better to test the values where the behavior flips, so I guess that should be a shift by 17 above and by 16 here. | |
42 | Am I missing something, or is this test the same as the previous one? |
Update for feedback
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
3315–3325 | No test currently fails, so I've gone ahead and changed it. |
I don't think this is right for vectors. You're taking the size of the full vector here, not of the vector elements. Using U->getOperand(0)->getType()->getScalarSizeInBits() should be fine here (as trunc is only defined on integers, so we don't need fancy DL machinery).
Please also add a vector test.