Skip to content

Conversation

midronij
Copy link
Contributor

Implement PPC codegen for m2i (Mask to Integer) on P8+. This operation accepts an IntVector mask (four elements) and converts it into four elements of a boolean array with the corresponding values.

@midronij
Copy link
Contributor Author

@zl-wang @gita-omr could you please review when you have a chance?

@midronij midronij changed the title Implement vectorized m2i on PPC WIP: Implement vectorized m2i on PPC Sep 18, 2025

// set all but least significant bit of each word element to 0
generateTrg1ImmInstruction(cg, TR::InstOpCode::vspltisw, node, tmpReg, 1);
generateTrg1Src2Instruction(cg, TR::InstOpCode::vand, node, tmpReg, srcReg, tmpReg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. isn't java vector mask defined to be in that format already? (i.e. each word element is either 0 or 1)
  2. code below appeared to assume in-coming element order is not right for LE but right for BE. that is an odd assumption.
    such that, i questioned the necessity of code below to flip elements around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.) Vector masks elements are represented with either -1 (i.e.: all 1 bits) for true or 0 for false, while boolean values use 1 for true and 0 for false. So, it's because of this difference that the two instructions highlighted above are needed (just like how with i2m, we need to subtract from 0 to get an all 1/all 0 mask from the given input boolean values)
2.) I think m2i would be affected by endianness the same way that i2m would be, no? For little endian specifically, because the four boolean values are loaded/stored as a single integer value, the byte order is reversed. So if you don't flip it beforehand, when the mask values are stored back to the boolean array, they end up in the wrong order (e.g.: a mask of { false, true, false, true } will end up as a boolean array of { true, false, true, false}.

Signed-off-by: midronij <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants