
This patch adds additional logic to add additional facts for A != B, if A is a monotonically increasing induction phi. The motivating use case for this is removing checks when using iterators with hardened libc++, e.g. https://godbolt.org/z/zhKEP37vG. The patch pulls in SCEV to detect AddRecs. If possible, the patch adds the following facts for a AddRec phi PN with StartValue as incoming value from the loo preheader and B being an upper bound for PN from a condition in the loop header. * (ICMP_UGE, PN, StartValue) * (ICMP_ULT, PN, B) [if (ICMP_ULE, StartValue, B)] The patch also adds an optional precondition to FactOrCheck (the new DoesHold field) , which can be used to only add a fact if the precondition holds at the point the fact is added to the constraint system. Depends on D151799. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D152730
77 lines
3.2 KiB
LLVM
77 lines
3.2 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
|
|
; RUN: opt -passes='require<demanded-bits>,constraint-elimination,require<demanded-bits>' -disable-verify -verify-analysis-invalidation=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
|
|
|
|
; Check that constraint-elimination properly invalidates anlyses.
|
|
|
|
; FIXME: ssub simplification currently doesn't properly set the change status
|
|
; after modifying the IR, which causes DemandedBits to be preserved.
|
|
|
|
; CHECK: Running pass: RequireAnalysisPass
|
|
; CHECK-NEXT: Running analysis: DemandedBitsAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: AssumptionAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: TargetIRAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running pass: ConstraintEliminationPass on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: LoopAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Invalidating analysis: DemandedBitsAnalysis on ssub_no_overflow_due_to_or_conds
|
|
; CHECK-NEXT: Running pass: RequireAnalysisPass
|
|
; CHECK-NEXT: Running analysis: DemandedBitsAnalysis on ssub_no_overflow_due_to_or_conds
|
|
|
|
; CHECK-NEXT: Running pass: RequireAnalysisPass
|
|
; CHECK-NEXT: Running analysis: DemandedBitsAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: AssumptionAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: TargetIRAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on uge_zext
|
|
; CHECK-NEXT: Running pass: ConstraintEliminationPass on uge_zext
|
|
; CHECK-NEXT: Running analysis: LoopAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on uge_zext
|
|
; CHECK-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on uge_zext
|
|
; CHECK-NEXT: Invalidating analysis: DemandedBitsAnalysis on uge_zext
|
|
; CHECK-NEXT: Running pass: RequireAnalysisPass
|
|
; CHECK-NEXT: Running analysis: DemandedBitsAnalysis on uge_zext
|
|
|
|
declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8)
|
|
|
|
define i8 @ssub_no_overflow_due_to_or_conds(i8 %a, i8 %b) {
|
|
entry:
|
|
%c.1 = icmp sle i8 %b, %a
|
|
%c.2 = icmp slt i8 %a, 0
|
|
%or.cond = or i1 %c.2, %c.1
|
|
br i1 %or.cond, label %exit.fail, label %math
|
|
|
|
math:
|
|
%op = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %b, i8 %a)
|
|
%status = extractvalue { i8, i1 } %op, 1
|
|
br i1 %status, label %exit.fail, label %exit.ok
|
|
|
|
exit.ok:
|
|
%res = extractvalue { i8, i1 } %op, 0
|
|
ret i8 %res
|
|
|
|
exit.fail:
|
|
ret i8 0
|
|
}
|
|
|
|
declare void @use_res({ i8, i1 })
|
|
|
|
|
|
define i1 @uge_zext(i8 %x, i16 %y) {
|
|
entry:
|
|
%x.ext = zext i8 %x to i16
|
|
%c.1 = icmp uge i16 %x.ext, %y
|
|
br i1 %c.1, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
%t.1 = icmp uge i16 %x.ext, %y
|
|
ret i1 %t.1
|
|
|
|
bb2:
|
|
ret i1 false
|
|
}
|
|
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
|
|
; CHECK: {{.*}}
|