forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86] Fix checked arithmetic for i8 on X86.
When lowering a ISD::BRCOND into a test+branch, make sure that we always use the correct condition code to emit the test operation. This fixes PR19858: "i8 checked mul is wrong on x86". Patch by Keno Fisher! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210032 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Andrea Di Biagio
authored and
Andrea Di Biagio
committed
Jun 2, 2014
1 parent
d958619
commit 0bedfa4
Showing
2 changed files
with
27 additions
and
2 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,24 @@ | ||
; RUN: llc -mcpu=generic -march=x86 < %s | FileCheck %s | ||
; PR19858 | ||
|
||
declare {i8, i1} @llvm.umul.with.overflow.i8(i8 %a, i8 %b) | ||
define i8 @testumulo(i32 %argc) { | ||
; CHECK: imulw | ||
; CHECK: testb %{{.+}}, %{{.+}} | ||
; CHECK: je [[NOOVERFLOWLABEL:.+]] | ||
; CHECK: {{.*}}[[NOOVERFLOWLABEL]]: | ||
; CHECK-NEXT: movb | ||
; CHECK-NEXT: retl | ||
top: | ||
%RHS = trunc i32 %argc to i8 | ||
%umul = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 25, i8 %RHS) | ||
%ex = extractvalue { i8, i1 } %umul, 1 | ||
br i1 %ex, label %overflow, label %nooverlow | ||
|
||
overflow: | ||
ret i8 %RHS | ||
|
||
nooverlow: | ||
%umul.value = extractvalue { i8, i1 } %umul, 0 | ||
ret i8 %umul.value | ||
} |