Diff Detail
Event Timeline
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1845 | No else after return | |
1867 | hasOneNonDBGUse? | |
1869 | For AMDGPU this would need a regbank legality check for post-regbankselect combines but I'm not sure what to do about that | |
1891 | buildShl | |
llvm/test/CodeGen/AMDGPU/GlobalISel/shl.ll | ||
85–87 | This is strange looking. It's technically neutral but the shift amount no longer appears constant? |
llvm/test/CodeGen/AMDGPU/GlobalISel/shl.ll | ||
---|---|---|
85–87 | Here is the MIR after AMDGPUPostLegalizerCombiner: bb.1 (%ir-block.0): liveins: $sgpr0 %2:_(s32) = COPY $sgpr0 %1:_(s16) = G_TRUNC %2:_(s32) %5:_(s32) = G_CONSTANT i32 7 %16:_(s16) = G_TRUNC %5:_(s32) %15:_(s16) = nuw nsw G_SHL %1:_, %16:_(s16) %8:_(s32) = G_ANYEXT %15:_(s16) %9:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.readfirstlane), %8:_(s32) $sgpr0 = COPY %9:_(s32) SI_RETURN_TO_EPILOG implicit $sgpr0 Looks like it's not constant because there is no combine to transform trunc(cst) to cst. We should add that as a part of the constant folding combines. |
For AMDGPU this would need a regbank legality check for post-regbankselect combines but I'm not sure what to do about that
Maybe it would make sense for now to add something like
SelectionStage getSelectionStage(MachineFunction &MF); ... if (getSelectionStage(MF) < SelectionStage::Legalized) return false; ... if (getSelectionStage(MF) != SelectionStage::RegBankSelected) return false; ...
So we can at least bail out when something could be unsafe for some target?
Ultimately, it would be nicest to declare which stages each combine is valid/invalid at in the tablegen somehow, but I guess something like this could be useful temporarily? :/
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1864 | Sink this down into the query statement? |
No else after return