[llvm] [InstCombine] Optimize addition of selects (PR #224477)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 23:31:50 PDT 2026
================
@@ -0,0 +1,25 @@
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64"
+
+; Test transform of:
+; ((P == A ? X : Def) + Base) + (P == B ? Y : 0)
+; into:
+; Base + (P == A ? X : (Def + (P == B ? Y : 0))
+define i32 @test_sum_selects(i32 %p, i32 %x, i32 %y, i32 %default, i32 %base) {
+; CHECK-LABEL: @test_sum_selects
+; CHECK-DAG: [[C0:%.*]] = icmp eq i32 %p, 288
+; CHECK-DAG: [[C1:%.*]] = icmp eq i32 %p, 128
----------------
boomanaiden154 wrote:
Can we get a test case with profile information to ensure we directly preserve/drop branch weights on the selects.
https://github.com/llvm/llvm-project/pull/224477
More information about the llvm-commits
mailing list