[PATCH] D23630: [PPC] Expand ISEL instruction into if-then-else sequence

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 15:33:54 PST 2016


hfinkel added a comment.

As a general note: I'd like to see this controlled with our existing isel toggle. In other words, take all of the existing places that call hasISEL() and hard-code them to true and then have this pass expand the isel instructions when hasISEL() is false.

There are a lot of loops here that could be range-based for loops. Please make them range-based for loops.

I've been thinking about how difficult it might be to handle the case where multiple isels use the same condition. I don't think it would be too difficult to support this:  As you iterate through the isels in each block, keep track of the true block, false block and condition for the last expanded isel. If this isel has the same condition as the last one, then scan between them to make sure that nothing defines this isel's input registers in between the two isels and that this isel does not depend on the last one. If that's true, then insert the generated instructions into the blocks from the last isel instead of making new ones.

As a quick example, I'm thinking about something like this:

  int foo(int a, int b, int d, int f, int g) {
    int q = g > 0 ? a : b;
    int r = g > 0 ? d : f;
    return q+r;
  }

which generates code like this:

cmpwi 0, 7, 0
	isel 3, 3, 4, 1
	isel 12, 5, 6, 1
	add 3, 3, 12
	extsw 3, 3
blr



================
Comment at: lib/Target/PowerPC/PPCExpandISEL.cpp:11
+// A pass that expands the ISEL instruction into an if-then-else sequence
+//
+//===----------------------------------------------------------------------===//
----------------
Please note here that this pass is intended to be run post-RA only.


https://reviews.llvm.org/D23630





More information about the llvm-commits mailing list