From 98e3864be67be475595e816b4ebf5beff8b87929 Mon Sep 17 00:00:00 2001 From: Russel Arbore <russel.jma@gmail.com> Date: Thu, 30 Jan 2025 18:59:32 -0600 Subject: [PATCH] Get rid of most spills --- hercules_opt/src/gcm.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hercules_opt/src/gcm.rs b/hercules_opt/src/gcm.rs index 462d1087..6d36e8ac 100644 --- a/hercules_opt/src/gcm.rs +++ b/hercules_opt/src/gcm.rs @@ -421,6 +421,9 @@ fn basic_blocks( // If the next node further up the dominator tree is in a shallower // loop nest or if we can get out of a reduce loop when we don't // need to be in one, place this data node in a higher-up location. + // Only do this is the node isn't a constant or undef. + let is_constant_or_undef = + function.nodes[id.idx()].is_constant() || function.nodes[id.idx()].is_undef(); let old_nest = loops .header_of(location) .map(|header| loops.nesting(header).unwrap()); @@ -441,7 +444,7 @@ fn basic_blocks( // loop use the reduce node forming the loop, so the dominator chain // will consist of one block, and this loop won't ever iterate. let currently_at_join = function.nodes[location.idx()].is_join(); - if shallower_nest || currently_at_join { + if !is_constant_or_undef && (shallower_nest || currently_at_join) { location = control_node; } } -- GitLab