Feeding vector values to InstCombiner::OptimizeOverflowCheck produces a scalar boolean flag if it proves the overflow check can be eliminated.
This causes InstCombiner::CreateOverflowTuple to crash as it correctly expects a vector of i1 values instead.
Details
Diff Detail
Event Timeline
Oh well, it turns out the results are evaluated according to all the elements so it's ok to splat it.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
4595 | This seems like wrong granularity. |
Doesn't the same issue apply to the isNeutralValue branch?
Duh, fixed that too.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
4595 | That's the prettiest way to get a constant i1xN vector I found. I'm not too familiar with the internal LLVM APIs so suggestions are more than welcome. |
Cleaned up the true/false building parts.
Added a note about LLVM not detecting if signed multiplication overflow, not much of a problem and can be fixed later.
Looks good to me, thanks.
Great, can you commit this on my behalf? I have no commit access.
@hans Is it too early to request this patch to be included in 11.0.1?
The name is LemonBoy, you can get the mail from running git log --author=LemonBoy in the LLVM repo.
TIA
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
4582–4584 | I think this can be simplified to CmpInst::makeCmpResultType(LHS->getType()) |
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | ||
---|---|---|
4582–4584 | Yup, I didn't use that because this is not the result of a comparison despite having the same type as one. |
I think this can be simplified to CmpInst::makeCmpResultType(LHS->getType())