https://gcc.gnu.org/g:02e910576f1ec4ce9c919306c7ed333494110717

commit r16-9243-g02e910576f1ec4ce9c919306c7ed333494110717
Author: Tamar Christina <[email protected]>
Date:   Fri Jun 12 11:55:46 2026 +0100

    middle-end: introduce IFN_VARYING for temporary statements [PR125597]
    
    This defines a new IFN "VARYING" to indicate that the operation has no 
current
    defining statement and so things like range analysis should just not report
    anything yet.
    
    In the vectorizer we can create new SSA variables that are only defined 
after
    vectorization is finishing.  For instance the actual control statement for
    masked loops.
    
    However intermediate values need to be able to perform build expressions 
using
    this SSA name but since GCC 16 ranger now tries to analyze these and we ICE.
    
    This replaces the uses of gimple_nop in the definition with a value with a 
more
    defined semantics.
    
    gcc/ChangeLog:
    
            PR tree-optimization/125597
            * internal-fn.def (VARYING): New.
            * doc/ifn.texi: Document it.
            * internal-fn.cc (expand_VARYING): New.
            * internal-fn.h (expand_VARYING): New.
            * tree-cfg.cc (verify_gimple_call): Check for leaked IFN_VARYING.
    
    (cherry picked from commit ad36cd942cd9c16df93ada46af38e72cf4e15981)

Diff:
---
 gcc/doc/ifn.texi    | 6 ++++++
 gcc/internal-fn.cc  | 7 +++++++
 gcc/internal-fn.def | 4 ++++
 gcc/internal-fn.h   | 1 +
 gcc/tree-cfg.cc     | 8 ++++++++
 5 files changed, 26 insertions(+)

diff --git a/gcc/doc/ifn.texi b/gcc/doc/ifn.texi
index 8600dcfa62a7..ada827ea5a3b 100644
--- a/gcc/doc/ifn.texi
+++ b/gcc/doc/ifn.texi
@@ -1535,5 +1535,11 @@ The @code{IFN_FLOATTOBITINT} internal function is 
expanded by the
 The @code{IFN_BITINTTOFLOAT} internal function is expanded by the
 @code{expand_BITINTTOFLOAT} function.
 
+@cindex @code{IFN_VARYING} internal function
+@item @samp{IFN_VARYING}
+Use @code{IFN_VARYING} as a temporary placeholder for a value whose
+definition is still being built by the current pass.  The pass that creates
+it must replace it before finishing; the verifier rejects any remaining calls.
+
 @end table
 
diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 65be5aed35ca..25acc63b247b 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -5686,6 +5686,13 @@ expand_MASK_CALL (internal_fn, gcall *)
   gcc_unreachable ();
 }
 
+void
+expand_VARYING (internal_fn, gcall *)
+{
+  /* This IFN should reach expand.  */
+  gcc_unreachable ();
+}
+
 void
 expand_MULBITINT (internal_fn, gcall *stmt)
 {
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 084a92716312..d142416725a2 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -599,6 +599,10 @@ DEF_INTERNAL_FN (CO_FRAME, ECF_PURE | ECF_NOTHROW | 
ECF_LEAF, NULL)
 /* A NOP function with arbitrary arguments and return value.  */
 DEF_INTERNAL_FN (NOP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
 
+/* A GIMPLE value with no definition and not Virtual Opeands for temporary
+   assignment cases within a pass.  */
+DEF_INTERNAL_FN (VARYING , ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW, NULL)
+
 /* Temporary vehicle for __builtin_shufflevector.  */
 DEF_INTERNAL_FN (SHUFFLEVECTOR, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
 
diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h
index b97c0dc60315..79c1453dc756 100644
--- a/gcc/internal-fn.h
+++ b/gcc/internal-fn.h
@@ -275,6 +275,7 @@ extern void expand_SPACESHIP (internal_fn, gcall *);
 extern void expand_TRAP (internal_fn, gcall *);
 extern void expand_ASSUME (internal_fn, gcall *);
 extern void expand_MASK_CALL (internal_fn, gcall *);
+extern void expand_VARYING (internal_fn, gcall *);
 extern void expand_MULBITINT (internal_fn, gcall *);
 extern void expand_DIVMODBITINT (internal_fn, gcall *);
 extern void expand_FLOATTOBITINT (internal_fn, gcall *);
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 3b95e0a68f13..2e61e68c988e 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -3466,6 +3466,14 @@ verify_gimple_call (gcall *stmt)
          }
     }
 
+  /* IFN_VARING is not allowed to be present after the completion of any pass
+     as it should have been replaced.  */
+  if (gimple_call_internal_p (stmt, IFN_VARYING))
+    {
+      error ("%<.VARYING%> calls should have been replaced and are not allowed 
"
+            "outside of the pass that introduced them");
+      return true;
+    }
   /* ???  The C frontend passes unpromoted arguments in case it
      didn't see a function declaration before the call.  So for now
      leave the call arguments mostly unverified.  Once we gimplify

Reply via email to