[llvm] r286958 - [X86][FastISel] Fix lowering of overflow result on AVX512 targets
Zvi Rackover via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 15 05:29:24 PST 2016
Author: zvi
Date: Tue Nov 15 07:29:23 2016
New Revision: 286958
URL: http://llvm.org/viewvc/llvm-project?rev=286958&view=rev
Log:
[X86][FastISel] Fix lowering of overflow result on AVX512 targets
Summary:
Fix a case where the overflow value of type i1, which is legal on AVX512, was assigned to a VK1 register class.
We always want this value to be assigned to a GPR since the overflow return value is lowered to a SETO instruction.
Fixes pr30981.
Reviewers: mkuper, igorb, craig.topper, guyblank, qcolombet
Subscribers: qcolombet, llvm-commits
Differential Revision: https://reviews.llvm.org/D26620
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=286958&r1=286957&r2=286958&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Nov 15 07:29:23 2016
@@ -2769,7 +2769,6 @@ bool X86FastISel::fastLowerIntrinsicCall
const Function *Callee = II->getCalledFunction();
auto *Ty = cast<StructType>(Callee->getReturnType());
Type *RetTy = Ty->getTypeAtIndex(0U);
- Type *CondTy = Ty->getTypeAtIndex(1);
MVT VT;
if (!isTypeLegal(RetTy, VT))
@@ -2879,7 +2878,8 @@ bool X86FastISel::fastLowerIntrinsicCall
if (!ResultReg)
return false;
- unsigned ResultReg2 = FuncInfo.CreateRegs(CondTy);
+ // Assign to a GPR since the overflow return value is lowered to a SETcc.
+ unsigned ResultReg2 = createResultReg(&X86::GR8RegClass);
assert((ResultReg+1) == ResultReg2 && "Nonconsecutive result registers.");
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(CondOpc),
ResultReg2);
Modified: llvm/trunk/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll?rev=286958&r1=286957&r2=286958&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll Tue Nov 15 07:29:23 2016
@@ -10,14 +10,14 @@ declare %0 @llvm.sadd.with.overflow.i32(
define fastcc i32 @test() nounwind {
entry:
-; CHECK-LABEL: _test:
-; CHECK: ## BB#0:
-; CHECK-NEXT: movl $1, %eax
-; CHECK-NEXT: addl $0, %eax
-; CHECK-NEXT: seto %k0
-; CHECK-NEXT: movl %eax, -4(%rsp) ## 4-byte Spill
-; CHECK-NEXT: kmovw %k0, -6(%rsp) ## 2-byte Spill
-; CHECK-NEXT: jo LBB0_2
+; CHECK-LABEL: test:
+; CHECK: ## BB#0:
+; CHECK-NEXT: movl $1, %eax
+; CHECK-NEXT: addl $0, %eax
+; CHECK-NEXT: seto %cl
+; CHECK-NEXT: movl %eax, -{{[0-9]+}}(%rsp) ## 4-byte Spill
+; CHECK-NEXT: movb %cl, -{{[0-9]+}}(%rsp) ## 1-byte Spill
+; CHECK-NEXT: jo LBB0_2
%tmp1 = call %0 @llvm.sadd.with.overflow.i32(i32 1, i32 0)
%tmp2 = extractvalue %0 %tmp1, 1
br i1 %tmp2, label %.backedge, label %BB3
More information about the llvm-commits
mailing list