Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 2a89c94

Browse files
committed
Revert "[InstCombine] Don't miscompile safe increment idiom"
This is breaking a lot of build bots and is causing very long-running compiles (infinite loops)? Likely, we shouldn't return nullptr? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239139 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8beac08 commit 2a89c94

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -292,28 +292,10 @@ static Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
292292

293293
// If this is a binary operator, try to simplify it with the replaced op.
294294
if (BinaryOperator *B = dyn_cast<BinaryOperator>(I)) {
295-
Value *Simplified = nullptr;
296295
if (B->getOperand(0) == Op)
297-
Simplified =
298-
SimplifyBinOp(B->getOpcode(), RepOp, B->getOperand(1), DL, TLI);
299-
if (!Simplified && B->getOperand(1) == Op)
300-
Simplified =
301-
SimplifyBinOp(B->getOpcode(), B->getOperand(0), RepOp, DL, TLI);
302-
if (Simplified) {
303-
// Consider:
304-
// %cmp = icmp eq i32 %x, 2147483647
305-
// %add = add nsw i32 %x, 1
306-
// %sel = select i1 %cmp, i32 -2147483648, i32 %add
307-
//
308-
// We can't replace %sel with %add unless we strip away the flags.
309-
if (isa<OverflowingBinaryOperator>(B)) {
310-
B->setHasNoSignedWrap(false);
311-
B->setHasNoUnsignedWrap(false);
312-
}
313-
if (isa<PossiblyExactOperator>(B))
314-
B->setIsExact(false);
315-
}
316-
return Simplified;
296+
return SimplifyBinOp(B->getOpcode(), RepOp, B->getOperand(1), DL, TLI);
297+
if (B->getOperand(1) == Op)
298+
return SimplifyBinOp(B->getOpcode(), B->getOperand(0), RepOp, DL, TLI);
317299
}
318300

319301
// Same for CmpInsts.

test/Transforms/InstCombine/select.ll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,13 +1532,3 @@ define i32 @test_max_of_min(i32 %a) {
15321532
%s1 = select i1 %c1, i32 %s0, i32 -1
15331533
ret i32 %s1
15341534
}
1535-
1536-
define i32 @PR23757(i32 %x) {
1537-
; CHECK-LABEL: @PR23757
1538-
; CHECK: %[[add:.*]] = add i32 %x, 1
1539-
; CHECK-NEXT: ret i32 %[[add]]
1540-
%cmp = icmp eq i32 %x, 2147483647
1541-
%add = add nsw i32 %x, 1
1542-
%sel = select i1 %cmp, i32 -2147483648, i32 %add
1543-
ret i32 %sel
1544-
}

0 commit comments

Comments
 (0)