[gcc r14-12444] Add phi_arg_edge_from_use helper
Richard Biener
rguenth@gcc.gnu.org
Mon Mar 16 13:39:22 GMT 2026
https://gcc.gnu.org/g:0306ff2eae126a233a34d0ca2f5ff6769326b971
commit r14-12444-g0306ff2eae126a233a34d0ca2f5ff6769326b971
Author: Richard Biener <rguenther@suse.de>
Date: Tue Jan 20 10:22:49 2026 +0100
Add phi_arg_edge_from_use helper
I've needed this a few times now and indenting nested
phi_arg_index_from_use inside gimple_phi_arg_edge is difficult.
* tree-phinodes.h (phi_arg_index_from_use): Use gphi *.
(phi_arg_edge_from_use): New helper composing
phi_arg_index_from_use and gimple_phi_arg_edge.
(cherry picked from commit 1acf01fcb6c66bb16577ee2d452cba3104cf3d96)
Diff:
---
gcc/tree-phinodes.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index 129ccfc24e47..7955d782968f 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -50,13 +50,13 @@ phi_arg_index_from_use (use_operand_p use)
{
struct phi_arg_d *element, *root;
size_t index;
- gimple *phi;
+ gphi *phi;
/* Since the use is the first thing in a PHI argument element, we can
calculate its index based on casting it to an argument, and performing
pointer arithmetic. */
- phi = USE_STMT (use);
+ phi = as_a <gphi *> (USE_STMT (use));
element = (struct phi_arg_d *)use;
root = gimple_phi_arg (phi, 0);
@@ -71,4 +71,13 @@ phi_arg_index_from_use (use_operand_p use)
return index;
}
+/* Return the edge into the PHI node USE. */
+
+inline edge
+phi_arg_edge_from_use (use_operand_p use)
+{
+ gphi *phi = as_a <gphi *> (USE_STMT (use));
+ return gimple_phi_arg_edge (phi, phi_arg_index_from_use (use));
+}
+
#endif /* GCC_TREE_PHINODES_H */
More information about the Gcc-cvs
mailing list