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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 30 10:24:31 PDT 2023


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

>From 7cb5b6eddf857624b552665aff7c32cff8faaff0 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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 40a8f6a155b23d2..b3feb2470e58efd 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3916,12 +3916,14 @@ 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 ConstantFoldCompareInstOperands(
+                ICmpInst::ICMP_SLT, C, Constant::getNullValue(C->getType()),
+                Q.DL);
           case ICmpInst::ICMP_SLT:
           case ICmpInst::ICMP_SLE:
-            return ConstantExpr::getICmp(ICmpInst::ICMP_SGE, C,
-                                         Constant::getNullValue(C->getType()));
+            return ConstantFoldCompareInstOperands(
+                ICmpInst::ICMP_SGE, C, Constant::getNullValue(C->getType()),
+                Q.DL);
           }
         }
       }



More information about the llvm-commits mailing list