Details
Diff Detail
Event Timeline
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1480 | "32" should be "31" here, but in any case this whole clause makes no sense to me. Why would shifting a 64-bit value right by 31 leave the low half unchanged? | |
1485 | Why not generalize this to: (G_ASHR i64:x, 63) for C >= 32 -> G_MERGE_VALUES (G_ASHR hi_32(x), C-32), (G_ASHR hi_32(x), 31) ? |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1485 | I meant (G_ASHR i64:x, C) of course. |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1480 | I broke this when I did a cleanup pass, this should just be HalfSize |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1485 | I copied this from the existing AMDGPUTargetLowering::performSrlCombine, I'm not sure why this restricts it to the one shift case |
I feel weird relying on such things, especially when I can see the cases. If I just delete the special case, it does not manage to take care of it
I guess it's up to you, but given that we already have a constant folding MIR builder it seems silly to write (and test and review) extra code to handle cases that it could handle for you. I was a bit surprised that we're not already using it. I had to tweak Combiner::combineMachineInstrs to create a ConstantFoldingMIRBuilder instead of plain MachineIRBuilder, but then your new tests still pass even if I delete the "NarrowShiftAmt == 0" special cases for all of shl, lshr and ashr.
I was wrong. ConstantFoldingMIRBuilder only handles genuine constant folding like 3+4. It doesn't simplify degenerate cases like adding or shifting by 0.
LGTM.
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1482 | Actually this still needs fixing; LGTM apart from that. |
"32" should be "31" here, but in any case this whole clause makes no sense to me. Why would shifting a 64-bit value right by 31 leave the low half unchanged?