Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for PR20059 (instcombine reorders shufflevector after instruction…
… that may trap) In PR20059 ( http://llvm.org/pr20059 ), instcombine eliminates shuffles that are necessary before performing an operation that can trap (srem). This patch calls isSafeToSpeculativelyExecute() and bails out of the optimization in SimplifyVectorOp() if needed. Differential Revision: http://reviews.llvm.org/D4424 llvm-svn: 212629
- Loading branch information
1 parent
df734cd
commit 5881444
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: opt -S -instcombine < %s | FileCheck %s | ||
|
||
; In PR20059 ( http://llvm.org/pr20059 ), shufflevector operations are reordered/removed | ||
; for an srem operation. This is not a valid optimization because it may cause a trap | ||
; on div-by-zero. | ||
|
||
; CHECK-LABEL: @do_not_reorder | ||
; CHECK: %splat1 = shufflevector <4 x i32> %p1, <4 x i32> undef, <4 x i32> zeroinitializer | ||
; CHECK-NEXT: %splat2 = shufflevector <4 x i32> %p2, <4 x i32> undef, <4 x i32> zeroinitializer | ||
; CHECK-NEXT: %retval = srem <4 x i32> %splat1, %splat2 | ||
define <4 x i32> @do_not_reorder(<4 x i32> %p1, <4 x i32> %p2) { | ||
%splat1 = shufflevector <4 x i32> %p1, <4 x i32> undef, <4 x i32> zeroinitializer | ||
%splat2 = shufflevector <4 x i32> %p2, <4 x i32> undef, <4 x i32> zeroinitializer | ||
%retval = srem <4 x i32> %splat1, %splat2 | ||
ret <4 x i32> %retval | ||
} | ||
; RUN: opt -S -instcombine < %s | FileCheck %s | ||
|
||
; In PR20059 ( http://llvm.org/pr20059 ), shufflevector operations are reordered/removed | ||
; for an srem operation. This is not a valid optimization because it may cause a trap | ||
; on div-by-zero. | ||
|
||
; CHECK-LABEL: @do_not_reorder | ||
; CHECK: %splat1 = shufflevector <4 x i32> %p1, <4 x i32> undef, <4 x i32> zeroinitializer | ||
; CHECK-NEXT: %splat2 = shufflevector <4 x i32> %p2, <4 x i32> undef, <4 x i32> zeroinitializer | ||
; CHECK-NEXT: %retval = srem <4 x i32> %splat1, %splat2 | ||
define <4 x i32> @do_not_reorder(<4 x i32> %p1, <4 x i32> %p2) { | ||
%splat1 = shufflevector <4 x i32> %p1, <4 x i32> undef, <4 x i32> zeroinitializer | ||
%splat2 = shufflevector <4 x i32> %p2, <4 x i32> undef, <4 x i32> zeroinitializer | ||
%retval = srem <4 x i32> %splat1, %splat2 | ||
ret <4 x i32> %retval | ||
} |