https://gcc.gnu.org/g:ad36cd942cd9c16df93ada46af38e72cf4e15981

commit r17-1509-gad36cd942cd9c16df93ada46af38e72cf4e15981
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.

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 95813a264730..9a2c60a5768a 100644
--- a/gcc/doc/ifn.texi
+++ b/gcc/doc/ifn.texi
@@ -1546,5 +1546,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 8a4622da7949..0138c6f7ef01 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 a9fb933021f8..af9f92950c73 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -622,6 +622,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 bd9ba8d6929a..30930f388b06 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 8fb80b8121ed..dc07dde8cfd4 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -3419,6 +3419,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