}
} else if (match(I, m_Sub(m_SExt(m_Value(LHS)), m_SExt(m_Value(RHS))))) {
if (LHS->getType() == RHS->getType()) {
- const SCEV *Key =
- SE->getAddExpr(SE->getUnknown(LHS), SE->getUnknown(RHS));
+ const SCEV *Key = SE->getAddExpr(
+ SE->getUnknown(LHS), SE->getNegativeSCEV(SE->getUnknown(RHS)));
if (auto *Dom = findClosestMatchingDominator(Key, I, DominatingSubs)) {
Instruction *NewSExt = new SExtInst(Dom, I->getType(), "", I);
NewSExt->takeName(I);
}
} else if (match(I, m_NSWSub(m_Value(LHS), m_Value(RHS)))) {
if (programUndefinedIfPoison(I)) {
- const SCEV *Key =
- SE->getAddExpr(SE->getUnknown(LHS), SE->getUnknown(RHS));
+ const SCEV *Key = SE->getAddExpr(
+ SE->getUnknown(LHS), SE->getNegativeSCEV(SE->getUnknown(RHS)));
DominatingSubs[Key].push_back(I);
}
}
; CHECK-NEXT: [[CMP26:%.*]] = icmp ult i32 [[SUB1]], 512
; CHECK-NEXT: br i1 [[CMP26]], label [[COND_TRUE:%.*]], label [[COND_END]]
; CHECK: cond.true:
-; CHECK-NEXT: [[SUB22:%.*]] = sext i32 [[SUB1]] to i64
-; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[P:%.*]] to i64
-; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[SUB22]], 2
-; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[TMP1]], [[TMP2]]
-; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[TMP3]], 2044
-; CHECK-NEXT: [[TMP5:%.*]] = inttoptr i64 [[TMP4]] to ptr
-; CHECK-NEXT: store float 1.000000e+00, ptr [[TMP5]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[MUL]] to i64
+; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[REM]] to i64
+; CHECK-NEXT: [[SUB22:%.*]] = sub i64 [[TMP2]], [[TMP1]]
+; CHECK-NEXT: [[TMP3:%.*]] = ptrtoint ptr [[P:%.*]] to i64
+; CHECK-NEXT: [[TMP4:%.*]] = shl i64 [[SUB22]], 2
+; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[TMP3]], [[TMP4]]
+; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[TMP5]], 2044
+; CHECK-NEXT: [[TMP7:%.*]] = inttoptr i64 [[TMP6]] to ptr
+; CHECK-NEXT: store float 1.000000e+00, ptr [[TMP7]], align 4
; CHECK-NEXT: br label [[COND_END]]
; CHECK: cond.end:
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[K]], 1