diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -130,6 +130,7 @@ EnableCodeSinking("instcombine-code-sinking", cl::desc("Enable code sinking"), cl::init(true)); +// FIXME: This option is no longer used for anything and may be removed. static cl::opt EnableExpensiveCombines("expensive-combines", cl::desc("Enable expensive instruction combines")); @@ -3491,27 +3492,6 @@ } } - // In general, it is possible for computeKnownBits to determine all bits in - // a value even when the operands are not all constants. - Type *Ty = I->getType(); - if (ExpensiveCombines && !I->use_empty() && Ty->isIntOrIntVectorTy() && - !isMustTailCall(I)) { - KnownBits Known = computeKnownBits(I, /*Depth*/0, I); - if (Known.isConstant()) { - Constant *C = ConstantInt::get(Ty, Known.getConstant()); - LLVM_DEBUG(dbgs() << "IC: ConstFold (all bits known) to: " << *C - << " from: " << *I << '\n'); - - // Add operands to the worklist. - replaceInstUsesWith(*I, C); - ++NumConstProp; - if (isInstructionTriviallyDead(I, &TLI)) - eraseInstFromFunction(*I); - MadeIRChange = true; - continue; - } - } - // See if we can trivially sink this instruction to a successor basic block. if (EnableCodeSinking && I->hasOneUse()) { BasicBlock *BB = I->getParent(); diff --git a/llvm/test/Transforms/InstCombine/assume.ll b/llvm/test/Transforms/InstCombine/assume.ll --- a/llvm/test/Transforms/InstCombine/assume.ll +++ b/llvm/test/Transforms/InstCombine/assume.ll @@ -353,16 +353,12 @@ ; PR35846 - https://bugs.llvm.org/show_bug.cgi?id=35846 define i32 @assumption_conflicts_with_known_bits(i32 %a, i32 %b) { -; EXPENSIVE-ON-LABEL: @assumption_conflicts_with_known_bits( -; EXPENSIVE-ON-NEXT: tail call void @llvm.assume(i1 false) -; EXPENSIVE-ON-NEXT: ret i32 0 -; -; EXPENSIVE-OFF-LABEL: @assumption_conflicts_with_known_bits( -; EXPENSIVE-OFF-NEXT: [[AND1:%.*]] = and i32 [[B:%.*]], 3 -; EXPENSIVE-OFF-NEXT: tail call void @llvm.assume(i1 false) -; EXPENSIVE-OFF-NEXT: [[CMP2:%.*]] = icmp eq i32 [[AND1]], 0 -; EXPENSIVE-OFF-NEXT: tail call void @llvm.assume(i1 [[CMP2]]) -; EXPENSIVE-OFF-NEXT: ret i32 0 +; CHECK-LABEL: @assumption_conflicts_with_known_bits( +; CHECK-NEXT: [[AND1:%.*]] = and i32 [[B:%.*]], 3 +; CHECK-NEXT: tail call void @llvm.assume(i1 false) +; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[AND1]], 0 +; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP2]]) +; CHECK-NEXT: ret i32 0 ; %and1 = and i32 %b, 3 %B1 = lshr i32 %and1, %and1 diff --git a/llvm/test/Transforms/InstCombine/known-signbit-shift.ll b/llvm/test/Transforms/InstCombine/known-signbit-shift.ll --- a/llvm/test/Transforms/InstCombine/known-signbit-shift.ll +++ b/llvm/test/Transforms/InstCombine/known-signbit-shift.ll @@ -30,11 +30,8 @@ ; If sign bit is a known zero, it cannot be a known one. ; This test should not crash opt. The shift produces poison. define i32 @test_no_sign_bit_conflict1(i1 %b) { -; EXPENSIVE-OFF-LABEL: @test_no_sign_bit_conflict1( -; EXPENSIVE-OFF-NEXT: ret i32 undef -; -; EXPENSIVE-ON-LABEL: @test_no_sign_bit_conflict1( -; EXPENSIVE-ON-NEXT: ret i32 0 +; CHECK-LABEL: @test_no_sign_bit_conflict1( +; CHECK-NEXT: ret i32 undef ; %sel = select i1 %b, i32 8193, i32 8192 %mul = shl nsw i32 %sel, 18 @@ -44,11 +41,8 @@ ; If sign bit is a known one, it cannot be a known zero. ; This test should not crash opt. The shift produces poison. define i32 @test_no_sign_bit_conflict2(i1 %b) { -; EXPENSIVE-OFF-LABEL: @test_no_sign_bit_conflict2( -; EXPENSIVE-OFF-NEXT: ret i32 undef -; -; EXPENSIVE-ON-LABEL: @test_no_sign_bit_conflict2( -; EXPENSIVE-ON-NEXT: ret i32 0 +; CHECK-LABEL: @test_no_sign_bit_conflict2( +; CHECK-NEXT: ret i32 undef ; %sel = select i1 %b, i32 -8193, i32 -8194 %mul = shl nsw i32 %sel, 18 diff --git a/llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll b/llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll --- a/llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll +++ b/llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll @@ -4,17 +4,11 @@ ; Check that we don't crash on unreasonable constant indexes define i32 @test_out_of_bounds(i32 %a, i1 %x, i1 %y) { -; EXPENSIVE-OFF-LABEL: @test_out_of_bounds( -; EXPENSIVE-OFF-NEXT: entry: -; EXPENSIVE-OFF-NEXT: [[AND1:%.*]] = and i32 [[A:%.*]], 3 -; EXPENSIVE-OFF-NEXT: tail call void @llvm.assume(i1 undef) -; EXPENSIVE-OFF-NEXT: ret i32 [[AND1]] -; -; EXPENSIVE-ON-LABEL: @test_out_of_bounds( -; EXPENSIVE-ON-NEXT: entry: -; EXPENSIVE-ON-NEXT: [[AND1:%.*]] = and i32 [[A:%.*]], 3 -; EXPENSIVE-ON-NEXT: tail call void @llvm.assume(i1 false) -; EXPENSIVE-ON-NEXT: ret i32 [[AND1]] +; CHECK-LABEL: @test_out_of_bounds( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[AND1:%.*]] = and i32 [[A:%.*]], 3 +; CHECK-NEXT: tail call void @llvm.assume(i1 undef) +; CHECK-NEXT: ret i32 [[AND1]] ; entry: %and1 = and i32 %a, 3 @@ -25,15 +19,10 @@ } define i128 @test_non64bit(i128 %a) { -; EXPENSIVE-OFF-LABEL: @test_non64bit( -; EXPENSIVE-OFF-NEXT: [[AND1:%.*]] = and i128 [[A:%.*]], 3 -; EXPENSIVE-OFF-NEXT: tail call void @llvm.assume(i1 undef) -; EXPENSIVE-OFF-NEXT: ret i128 [[AND1]] -; -; EXPENSIVE-ON-LABEL: @test_non64bit( -; EXPENSIVE-ON-NEXT: [[AND1:%.*]] = and i128 [[A:%.*]], 3 -; EXPENSIVE-ON-NEXT: tail call void @llvm.assume(i1 false) -; EXPENSIVE-ON-NEXT: ret i128 [[AND1]] +; CHECK-LABEL: @test_non64bit( +; CHECK-NEXT: [[AND1:%.*]] = and i128 [[A:%.*]], 3 +; CHECK-NEXT: tail call void @llvm.assume(i1 undef) +; CHECK-NEXT: ret i128 [[AND1]] ; %and1 = and i128 %a, 3 %B = lshr i128 %and1, -1 diff --git a/llvm/test/Transforms/InstCombine/phi-shifts.ll b/llvm/test/Transforms/InstCombine/phi-shifts.ll --- a/llvm/test/Transforms/InstCombine/phi-shifts.ll +++ b/llvm/test/Transforms/InstCombine/phi-shifts.ll @@ -4,21 +4,13 @@ ; OSS Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15217 define i64 @fuzz15217(i1 %cond, i8* %Ptr, i64 %Val) { -; EXPENSIVE-OFF-LABEL: @fuzz15217( -; EXPENSIVE-OFF-NEXT: entry: -; EXPENSIVE-OFF-NEXT: br i1 [[COND:%.*]], label [[END:%.*]], label [[TWO:%.*]] -; EXPENSIVE-OFF: two: -; EXPENSIVE-OFF-NEXT: br label [[END]] -; EXPENSIVE-OFF: end: -; EXPENSIVE-OFF-NEXT: ret i64 undef -; -; EXPENSIVE-ON-LABEL: @fuzz15217( -; EXPENSIVE-ON-NEXT: entry: -; EXPENSIVE-ON-NEXT: br i1 [[COND:%.*]], label [[END:%.*]], label [[TWO:%.*]] -; EXPENSIVE-ON: two: -; EXPENSIVE-ON-NEXT: br label [[END]] -; EXPENSIVE-ON: end: -; EXPENSIVE-ON-NEXT: ret i64 0 +; CHECK-LABEL: @fuzz15217( +; CHECK-NEXT: entry: +; CHECK-NEXT: br i1 [[COND:%.*]], label [[END:%.*]], label [[TWO:%.*]] +; CHECK: two: +; CHECK-NEXT: br label [[END]] +; CHECK: end: +; CHECK-NEXT: ret i64 undef ; entry: br i1 %cond, label %end, label %two