[llvm-branch-commits] [llvm-branch] r331729 - Cherry-pick @=r330951 to google/stable for 2018-04-24
David L. Jones via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 7 21:11:42 PDT 2018
Author: dlj
Date: Mon May 7 21:11:42 2018
New Revision: 331729
URL: http://llvm.org/viewvc/llvm-project?rev=331729&view=rev
Log:
Cherry-pick @=r330951 to google/stable for 2018-04-24
Modified:
llvm/branches/google/stable/ (props changed)
llvm/branches/google/stable/BRANCH_HISTORY
llvm/branches/google/stable/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/branches/google/stable/test/CodeGen/X86/ftrunc.ll
Propchange: llvm/branches/google/stable/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 7 21:11:42 2018
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,330893,330947,330950
+/llvm/trunk:155241,330893,330947,330950-330951
Modified: llvm/branches/google/stable/BRANCH_HISTORY
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/stable/BRANCH_HISTORY?rev=331729&r1=331728&r2=331729&view=diff
==============================================================================
--- llvm/branches/google/stable/BRANCH_HISTORY (original)
+++ llvm/branches/google/stable/BRANCH_HISTORY Mon May 7 21:11:42 2018
@@ -2,3 +2,4 @@
@=r330893
@=r330947
@=r330950
+@=r330951
Modified: llvm/branches/google/stable/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/stable/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=331729&r1=331728&r2=331729&view=diff
==============================================================================
--- llvm/branches/google/stable/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/google/stable/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon May 7 21:11:42 2018
@@ -10908,6 +10908,14 @@ SDValue DAGCombiner::visitFCOPYSIGN(SDNo
static SDValue foldFPToIntToFP(SDNode *N, SelectionDAG &DAG,
const TargetLowering &TLI) {
+ // This optimization is guarded by a function attribute because it may produce
+ // unexpected results. Ie, programs may be relying on the platform-specific
+ // undefined behavior when the float-to-int conversion overflows.
+ const Function &F = DAG.getMachineFunction().getFunction();
+ Attribute CastWorkaround = F.getFnAttribute("fp-cast-overflow-workaround");
+ if (CastWorkaround.getValueAsString().equals("true"))
+ return SDValue();
+
// We only do this if the target has legal ftrunc. Otherwise, we'd likely be
// replacing casts with a libcall.
EVT VT = N->getValueType(0);
Modified: llvm/branches/google/stable/test/CodeGen/X86/ftrunc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/stable/test/CodeGen/X86/ftrunc.ll?rev=331729&r1=331728&r2=331729&view=diff
==============================================================================
--- llvm/branches/google/stable/test/CodeGen/X86/ftrunc.ll (original)
+++ llvm/branches/google/stable/test/CodeGen/X86/ftrunc.ll Mon May 7 21:11:42 2018
@@ -356,7 +356,7 @@ define <4 x double> @trunc_signed_v4f64(
ret <4 x double> %r
}
-; FIXME: The attribute name is subject to change, but the fold may be
+; The attribute name is subject to change, but the fold may be
; guarded to allow existing code to continue working based on its
; assumptions of float->int overflow.
@@ -371,12 +371,17 @@ define float @trunc_unsigned_f32_disable
;
; SSE41-LABEL: trunc_unsigned_f32_disable_via_attr:
; SSE41: # %bb.0:
-; SSE41-NEXT: roundss $11, %xmm0, %xmm0
+; SSE41-NEXT: cvttss2si %xmm0, %rax
+; SSE41-NEXT: movl %eax, %eax
+; SSE41-NEXT: xorps %xmm0, %xmm0
+; SSE41-NEXT: cvtsi2ssq %rax, %xmm0
; SSE41-NEXT: retq
;
; AVX1-LABEL: trunc_unsigned_f32_disable_via_attr:
; AVX1: # %bb.0:
-; AVX1-NEXT: vroundss $11, %xmm0, %xmm0, %xmm0
+; AVX1-NEXT: vcvttss2si %xmm0, %rax
+; AVX1-NEXT: movl %eax, %eax
+; AVX1-NEXT: vcvtsi2ssq %rax, %xmm1, %xmm0
; AVX1-NEXT: retq
%i = fptoui float %x to i32
%r = uitofp i32 %i to float
@@ -393,12 +398,15 @@ define double @trunc_signed_f64_disable_
;
; SSE41-LABEL: trunc_signed_f64_disable_via_attr:
; SSE41: # %bb.0:
-; SSE41-NEXT: roundsd $11, %xmm0, %xmm0
+; SSE41-NEXT: cvttsd2si %xmm0, %rax
+; SSE41-NEXT: xorps %xmm0, %xmm0
+; SSE41-NEXT: cvtsi2sdq %rax, %xmm0
; SSE41-NEXT: retq
;
; AVX1-LABEL: trunc_signed_f64_disable_via_attr:
; AVX1: # %bb.0:
-; AVX1-NEXT: vroundsd $11, %xmm0, %xmm0, %xmm0
+; AVX1-NEXT: vcvttsd2si %xmm0, %rax
+; AVX1-NEXT: vcvtsi2sdq %rax, %xmm1, %xmm0
; AVX1-NEXT: retq
%i = fptosi double %x to i64
%r = sitofp i64 %i to double
More information about the llvm-branch-commits
mailing list