[llvm] [VPlan] Fix VPInstruction::AnyOf combine undoing freeze (PR #223640)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 02:50:16 PDT 2026


================
@@ -1696,6 +1696,8 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
 
   VPValue *AnyNaNLane =
       LatchBuilder.createNaryOp(VPInstruction::AnyOf, {AllNaNLanes});
+  // Freeze to prevent immediate UB from branching on poison.
+  AnyNaNLane = LatchBuilder.createFreeze(AnyNaNLane);
----------------
fhahn wrote:

Do we need to freeze the condition? With previous semantics, `AnyNaNLane` would be true, if any of the leading lanes was true. Now any lane poisons the full `AnyOf`. We freeze it later, but that may give an incorrect result (`false` instead of `true`)?

```suggestion
VPValue *AnyNaNLane =
LatchBuilder.createNaryOp(VPInstruction::AnyOf, {LatchBuilder.createFreeze(AnyNaNLane(AllNaNLanes)});

```

https://github.com/llvm/llvm-project/pull/223640


More information about the llvm-commits mailing list