[llvm] [InstSimplify] Avoid use of ConstantExpr::getICmp. NFC (PR #67873)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 22:35:06 PDT 2023


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/67873

As I understand ICmp ConstantExpr are planned to be removed.

>From d887d75490aa18070fed86b543e9c6674e3f8a4a Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Fri, 29 Sep 2023 22:28:45 -0700
Subject: [PATCH] [InstSimplify] Avoid use of ConstantExpr::getICmp. NFC

As I understand ICmp ConstantExpr are planned to be removed.
---
 llvm/lib/Analysis/InstructionSimplify.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 40a8f6a155b23d2..5bdff48f79b4657 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3916,12 +3916,12 @@ static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
           // is non-negative then LHS <s RHS.
           case ICmpInst::ICMP_SGT:
           case ICmpInst::ICMP_SGE:
-            return ConstantExpr::getICmp(ICmpInst::ICMP_SLT, C,
-                                         Constant::getNullValue(C->getType()));
+            return ConstantFoldCompareInstruction(
+                ICmpInst::ICMP_SLT, C, Constant::getNullValue(C->getType()));
           case ICmpInst::ICMP_SLT:
           case ICmpInst::ICMP_SLE:
-            return ConstantExpr::getICmp(ICmpInst::ICMP_SGE, C,
-                                         Constant::getNullValue(C->getType()));
+            return ConstantFoldCompareInstruction(
+                ICmpInst::ICMP_SGE, C, Constant::getNullValue(C->getType()));
           }
         }
       }



More information about the llvm-commits mailing list