[llvm] [InstCombine] Fix pointer replacement in `foldSelectValueEquivalence` (PR #161701)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 3 09:29:22 PDT 2025


================
@@ -286,3 +286,35 @@ define <2 x ptr> @test7(<2 x ptr> %p1, i64 %idx, <2 x i1> %cc) {
   %select = select <2 x i1> %cc, <2 x ptr> %p1, <2 x ptr> %gep
   ret <2 x ptr> %select
 }
+
+define ptr @ptr_eq_replace_freeze1(ptr %p, ptr %q) {
+; CHECK-LABEL: @ptr_eq_replace_freeze1(
+; CHECK-NEXT:    [[Q_FR:%.*]] = freeze ptr [[Q:%.*]]
+; CHECK-NEXT:    [[Q_FR1:%.*]] = freeze ptr [[Q1:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[Q_FR]], [[Q_FR1]]
+; CHECK-NEXT:    [[SELECT:%.*]] = select i1 [[CMP]], ptr [[Q_FR]], ptr [[Q_FR1]]
+; CHECK-NEXT:    ret ptr [[SELECT]]
+;
+  %p.fr = freeze ptr %p
+  %q.fr = freeze ptr %q
----------------
dtcxzyw wrote:

It is guarded by https://github.com/llvm/llvm-project/blob/bd7e228fa43d7da93aef19892cd8a7de3350835e/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L1456-L1458


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


More information about the llvm-commits mailing list