Value *Op0 = Cmp->getOperand(0);
Value *Op1 = Cmp->getOperand(1);
if (!Op0->getType()->isIntegerTy() || isa<Constant>(Op0) ||
- isa<Constant>(Op1))
+ isa<Constant>(Op1) || Op0 == Op1)
return false;
// If a subtract already has the same operands as a compare, swapping would be
--- /dev/null
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt -S -mtriple=x86_64-- -codegenprepare < %s | FileCheck %s
+
+define i1 @test(i32 %arg) {
+; CHECK-LABEL: define i1 @test
+; CHECK-SAME: (i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[ARG]], [[ARG]]
+; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[ARG]], [[ARG]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %cmp = icmp ne i32 %arg, %arg
+ %sub = sub i32 %arg, %arg
+ ret i1 %cmp
+}