Add generic helper function that matches constant splat. It also has an option
to match constant splat with undef (some elements can be undef but not all).
Add util function and matcher for G_FCONSTANT splat.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/CodeGen/GlobalISel/Utils.h | ||
---|---|---|
362 | Would a return type of Optional<ValueAndVReg> (like getConstantVRegValWithLookThrough) be more useful? Actually I'm not sure if returning the register is useful, maybe just Optional<APInt>? | |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
1022 | Isn't there an existing utility you can call to do this? |
llvm/include/llvm/CodeGen/GlobalISel/Utils.h | ||
---|---|---|
362 | ValueAndVReg would be fine but in later patch APFloat would be useful. I did it with reg so that once it is matched caller knows if it matched int or float constant and can get APInt or APFloat and check what it needs. | |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
1022 | There is code that does similar thing with look through in a few places but not a utility function. |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
374 | This will need a nullptr check. I'm not sure about how I feel about adding functions for generic opcode checks, since I think it could end up being confusing if we don't add them for every opcode. :/ That being said, these do look nicer than using MI->getOpcode() everywhere. (Maybe someone else can give a stronger opinion here.) |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
374 | I don't think alone this helper has much benefit. I think it would be nice to have some wrapper classes around MachineInstr to do some of that while also proving some abstractions over operand accessors etc. I haven't got around to it but was on my todo list. |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
374 | I meant to add it for a number of opcodes (~50). | |
374 | I like this better than util function. |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
988 | Splat of NaN value, if we get value as APFloat all comparisons with it are false and we cant check for splat. We check for splat using APInt and check if constant is g_fconstant with getFConstantVRegValWithLookThrough and get APFloat. |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
988 | OK, I just assumed that any floating point splat detection code would use bitwiseIsEqual instead of operator== anyway. |
Remove comment about constant splat with NaN value. Seems unnecessary to mention it since we match all constants.
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h | ||
---|---|---|
111 | Could this function be a one-liner? return getFConstantSplat(Reg, MRI) || getFConstantVRegValWithLookThrough(Reg, MRI); | |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
933 | check that this is not nullptr? | |
939 | Maybe use for (MachineOperand &Op : MI->uses()) { ... |
Could this function be a one-liner?
return getFConstantSplat(Reg, MRI) || getFConstantVRegValWithLookThrough(Reg, MRI);