diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-11-04 23:49:08 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-11-04 23:49:08 +0000 |
| commit | f20d7c4c6134cad587db861bfe46e27f2d46bc73 (patch) | |
| tree | 6168742823c309ceaa19e5a41e30abc9ad4783ba /llvm/test | |
| parent | 941e93e9a8633b42fdbeadc54fd26c93aed5b0ba (diff) | |
| download | bcm5719-llvm-f20d7c4c6134cad587db861bfe46e27f2d46bc73.tar.gz bcm5719-llvm-f20d7c4c6134cad587db861bfe46e27f2d46bc73.zip | |
Analysis: Make isSafeToSpeculativelyExecute fire less for divides
Divides and remainder operations do not behave like other operations
when they are given poison: they turn into undefined behavior.
It's really hard to know if the operands going into a div are or are not
poison. Because of this, we should only choose to speculate if there
are constant operands which we can easily reason about.
This fixes PR21412.
llvm-svn: 221318
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/LICM/speculate.ll | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/test/Transforms/LICM/speculate.ll b/llvm/test/Transforms/LICM/speculate.ll index 4244f157d9f..69266693c47 100644 --- a/llvm/test/Transforms/LICM/speculate.ll +++ b/llvm/test/Transforms/LICM/speculate.ll @@ -3,12 +3,11 @@ ; UDiv is safe to speculate if the denominator is known non-zero. ; CHECK-LABEL: @safe_udiv( -; CHECK: %div = udiv i64 %x, %or +; CHECK: %div = udiv i64 %x, 2 ; CHECK-NEXT: br label %for.body define void @safe_udiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { entry: - %or = or i64 %m, 1 br label %for.body for.body: ; preds = %entry, %for.inc @@ -19,7 +18,7 @@ for.body: ; preds = %entry, %for.inc br i1 %tobool, label %for.inc, label %if.then if.then: ; preds = %for.body - %div = udiv i64 %x, %or + %div = udiv i64 %x, 2 %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 store i64 %div, i64* %arrayidx1, align 8 br label %for.inc @@ -69,13 +68,12 @@ for.end: ; preds = %for.inc, %entry ; known to have at least one zero bit. ; CHECK-LABEL: @safe_sdiv( -; CHECK: %div = sdiv i64 %x, %or +; CHECK: %div = sdiv i64 %x, 2 ; CHECK-NEXT: br label %for.body define void @safe_sdiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { entry: %and = and i64 %m, -3 - %or = or i64 %and, 1 br label %for.body for.body: ; preds = %entry, %for.inc @@ -86,7 +84,7 @@ for.body: ; preds = %entry, %for.inc br i1 %tobool, label %for.inc, label %if.then if.then: ; preds = %for.body - %div = sdiv i64 %x, %or + %div = sdiv i64 %x, 2 %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 store i64 %div, i64* %arrayidx1, align 8 br label %for.inc |

