[PATCH] D41029: [JumpTables][PowerPC] Let targets decide which switch instructions are suitable for jump tables
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 14:27:42 PST 2017
efriedma added inline comments.
================
Comment at: lib/Target/PowerPC/PPCISelLowering.cpp:1151
+ case Intrinsic::ppc_is_decremented_ctr_nonzero:
+ case Intrinsic::ppc_mtctr:
+ return true;
----------------
These intrinsics come out of PPCCTRLoops, right? Would it make sense to avoid loop transform rather than disabling the jump table transform?
================
Comment at: lib/Target/PowerPC/PPCISelLowering.cpp:1204
+ }
+ if (mightUseCTR(It.getCaseSuccessor())) {
+ NumSwitchesNotSuitableForJT++;
----------------
nemanjai wrote:
> efriedma wrote:
> > This is worst-case quadratic (N switches times M instructions in the successor); you might need to cache the mightUseCTR computation.
> Well, this is linear in the sum of instructions in successors of all the cases in the switch. This is since no block is visited twice. If a CTR use is found in a block, we return so definitely won't re-vist it. If no CTR use is found in a block, it is not visited again because we skip it in the `if` block above.
>
> I don't think I can make it any faster than that since I have to check each instruction for using the CTR.
>
> Or did you have something else in mind? Perhaps you mean across multiple invocations of `isSuitableForJumpTable()` on the same `SwitchInst`?
I mean across multiple invocations of isSuitableForJumpTable for different switches (assuming we don't break the critical edge, which I don't think we do unconditionally).
Repository:
rL LLVM
https://reviews.llvm.org/D41029
More information about the llvm-commits
mailing list