In the current setup the change to SPMD is abandoned if the target region does not contain any parallel regions. This actually does not stop the kernel from being considered SPMD by OpenMP Opt because this check is performed after the fixpoint is reached. This leads to an inconsistency between what the runtime thinks the execution mode is (generic) and what the code inside the kernel thinks the execution mode is (SPMD).
This patch fixes this problem by being more fine grained:
- eliminate instruction guarding if no parallel regions are present.
- since instructions aren't guarded anymore ensure that only the team main thread executes the target region.
Style: Given that we have now a conditional, let's move the two long code sequences in helper methods. It's hard to read like this as the "else" is easily over looked (by me).
Remove all the llvm:: above.