Add support for cases where only some c1+c2 results exceed the max bitshift, clamping accordingly.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Isn't it a little regression for scalar types?
N1.getValueType() == N0.getOperand(1).getValueType()
Instead of
zeroExtendToMatch(c1, c2, 1 /* Overflow Bit */);
There is no vector analog of zeroExtendToMatch currently, right?
Btw, I don't think I have rights to accept the revision.
Resurrecting this old patch, refactored to correctly handle overflows of the sum of shifts.
test/CodeGen/X86/combine-sra.ll | ||
---|---|---|
133–134 ↗ | (On Diff #160079) | To provide better coverage, add (or adjust this) test where both of the component shifts are below bitwidth, but the sum exceeds bitwidth? |
test/CodeGen/X86/combine-sra.ll | ||
---|---|---|
133–134 ↗ | (On Diff #160079) | See @combine_vec_ashr_ashr2 above |
LGTM. I notice we don't fold the non-splat case of this pattern in IR. Do you think it's worth adding there too, or backend is good enough?
Add it if you can, properly supporting vectors is always a good idea ;-)
Is there the equivalent logical shifts -> zero combine?
AFAIK, no. I think splats are well supported now in instcombine, but we haven't generalized many transforms for non-splats.