[llvm] [LLVM][InstCombiner] foldICmpEquality: Compare APInt values rather than addresses. (PR #151726)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 09:38:55 PDT 2025
https://github.com/paulwalker-arm created https://github.com/llvm/llvm-project/pull/151726
None
>From 17d995dff053b33c31f169ea13ff3b3711991076 Mon Sep 17 00:00:00 2001
From: Paul Walker <paul.walker at arm.com>
Date: Fri, 1 Aug 2025 16:20:00 +0000
Subject: [PATCH] [LLVM][InstCombiner] foldICmpEquality: Compare APInt values
rather than addresses.
---
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 2 +-
llvm/test/Transforms/InstCombine/compare-signs.ll | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index da9b12686a8f1..c88891563e72d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -6083,7 +6083,7 @@ Instruction *InstCombinerImpl::foldICmpEquality(ICmpInst &I) {
match(Op1, m_OneUse(m_LShr(m_Value(B), m_APIntAllowPoison(AP2))))) ||
(match(Op0, m_OneUse(m_AShr(m_Value(A), m_APIntAllowPoison(AP1)))) &&
match(Op1, m_OneUse(m_AShr(m_Value(B), m_APIntAllowPoison(AP2)))))) {
- if (AP1 != AP2)
+ if (*AP1 != *AP2)
return nullptr;
unsigned TypeBits = AP1->getBitWidth();
unsigned ShAmt = AP1->getLimitedValue(TypeBits);
diff --git a/llvm/test/Transforms/InstCombine/compare-signs.ll b/llvm/test/Transforms/InstCombine/compare-signs.ll
index 59ec9adb30b9e..bed0f6966dd89 100644
--- a/llvm/test/Transforms/InstCombine/compare-signs.ll
+++ b/llvm/test/Transforms/InstCombine/compare-signs.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=instcombine -S < %s | FileCheck %s
+; RUN: opt -passes=instcombine -use-constant-int-for-fixed-length-splat -S < %s | FileCheck %s
; PR5438
More information about the llvm-commits
mailing list