================
@@ -193,6 +193,66 @@ static bool replaceSignedInst(SCCPSolver &Solver,
     NewInst = BinaryOperator::Create(NewOpcode, Op0, Op1, "", &Inst);
     break;
   }
+  case Instruction::ICmp: {
+    ICmpInst &ICmp = cast<ICmpInst>(Inst);
+
+    ZExtInst *Op0_zext = dyn_cast<ZExtInst>(ICmp.getOperand(0));
+    SExtInst *Op0_sext = dyn_cast<SExtInst>(ICmp.getOperand(0));
+
+    ZExtInst *Op1_zext = dyn_cast<ZExtInst>(ICmp.getOperand(1));
+    SExtInst *Op1_sext = dyn_cast<SExtInst>(ICmp.getOperand(1));
+
+    CastInst *Op0;
+    CastInst *Op1;
+
+    if (Op0_zext)
+      Op0 = Op0_zext;
+    else
+      Op0 = Op0_sext;
+    if (Op1_zext)
+      Op1 = Op1_zext;
+    else
+      Op1 = Op1_sext;
+
+    bool reversed = false;
+
+    if (!Op0 || !Op1) {
+      // Op0 and Op1 must be defined
+      return false;
+    }
+
+    if (Op1_zext && (!Op0_zext)) {
+      // We force Op0 to be a zext and reverse the arguments
+      //   at the end if we swap
+      reversed = true;
----------------
mariannems wrote:

IMHO the swapping makes it harder to read. Not swapping would force case to be 
checked in the if statement, but would make the code more readable.

https://github.com/llvm/llvm-project/pull/67594
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to