2019-06-24 21:13:36 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2020-03-21 17:14:17 +08:00
|
|
|
; RUN: opt -S -instcombine < %s | FileCheck %s
|
2019-06-24 21:13:36 +08:00
|
|
|
|
|
|
|
; OSS Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15217
|
|
|
|
define i64 @fuzz15217(i1 %cond, i8* %Ptr, i64 %Val) {
|
[InstCombine] Remove known bits constant folding
If ExpensiveCombines is enabled (which is the case with -O3 on the
legacy PM and always on the new PM), InstCombine tries to compute
the known bits of all instructions in the hope that all bits end up
being known, which is fairly expensive.
How effective is it? If we add some statistics on how often the
constant folding succeeds and how many KnownBits calculations are
performed and run test-suite we get:
"instcombine.NumConstPropKnownBits": 642,
"instcombine.NumConstPropKnownBitsComputed": 18744965,
In other words, we get one fold for every 30000 KnownBits calculations.
However, the truth is actually much worse: Currently, known bits are
computed before performing other folds, so there is a high chance
that cases that get folded by known bits would also have been
handled by other folds.
What happens if we compute known bits after all other folds
(hacky implementation: https://gist.github.com/nikic/751f25b3b9d9e0860db5dde934f70f46)?
"instcombine.NumConstPropKnownBits": 0,
"instcombine.NumConstPropKnownBitsComputed": 18105547,
So it turns out despite doing 18 million known bits calculations,
the known bits fold does not do anything useful on test-suite.
I was originally planning to move this into AggressiveInstCombine
so it only runs once in the pipeline, but seeing this, I think
we're better off removing it entirely.
As this is the only use of the "expensive combines" mechanism,
it may be removed afterwards, but I'll leave that to a separate patch.
Differential Revision: https://reviews.llvm.org/D75801
2020-03-07 17:58:24 +08:00
|
|
|
; 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
|
2019-06-24 21:13:36 +08:00
|
|
|
;
|
|
|
|
entry:
|
|
|
|
br i1 %cond, label %end, label %two
|
|
|
|
|
|
|
|
two:
|
|
|
|
br label %end
|
|
|
|
|
|
|
|
end:
|
|
|
|
%tmp869.0 = phi i128 [ 0, %entry ], [ 18446744073709551616, %two ]
|
|
|
|
%tmp29 = lshr i128 %tmp869.0, 64
|
|
|
|
%B1 = lshr i128 %tmp29, 170141183460469231731687303715884105727
|
|
|
|
%tmp30 = trunc i128 %B1 to i64
|
|
|
|
ret i64 %tmp30
|
|
|
|
}
|