This repository was archived by the owner on Sep 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Support MULH[US] for all integer types #190
Merged
shepmaster
merged 2 commits into
avr-llvm:avr-support
from
shepmaster:mulh-for-everyone
May 17, 2016
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,31 @@ | ||
; RUN: llc < %s -march=avr | FileCheck %s | ||
|
||
define i1 @signed_multiplication_did_overflow(i8, i8) unnamed_addr { | ||
; CHECK-LABEL: signed_multiplication_did_overflow: | ||
entry-block: | ||
%2 = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %0, i8 %1) | ||
%3 = extractvalue { i8, i1 } %2, 1 | ||
ret i1 %3 | ||
|
||
; Multiply, fill the low byte with the sign of the low byte via | ||
; arithmetic shifting, compare it to the high byte. | ||
; | ||
; CHECK: muls r24, r22 | ||
; CHECK: mov [[HIGH:r[0-9]+]], r1 | ||
; CHECK: mov [[LOW:r[0-9]+]], r0 | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: asr {{.*}}[[LOW]] | ||
; CHECK: ldi [[RET:r[0-9]+]], 1 | ||
; CHECK: cp {{.*}}[[HIGH]], {{.*}}[[LOW]] | ||
; CHECK: brne [[LABEL:LBB[_0-9]+]] | ||
; CHECK: ldi {{.*}}[[RET]], 0 | ||
; CHECK: {{.*}}[[LABEL]] | ||
; CHECK: ret | ||
} | ||
|
||
declare { i8, i1 } @llvm.smul.with.overflow.i8(i8, i8) |
This file contains hidden or 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,22 @@ | ||
; RUN: llc < %s -march=avr | FileCheck %s | ||
|
||
define i1 @unsigned_multiplication_did_overflow(i8, i8) unnamed_addr { | ||
; CHECK-LABEL: unsigned_multiplication_did_overflow: | ||
entry-block: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assembly: unsigned_multiplication_did_overflow: ; @unsigned_multiplication_did_overflow
; BB#0: ; %entry-block
mul r24, r22
mov r25, r1
eor r1, r1
ldi r24, 1
cpi r25, 0
brne LBB0_2
; BB#1: ; %entry-block
ldi r24, 0
LBB0_2: ; %entry-block
ret This one is straight-forward - do the multiply and then check to see if the high byte is zero. There's some small inefficiencies. What general shape of tests would you like to see? |
||
%2 = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %0, i8 %1) | ||
%3 = extractvalue { i8, i1 } %2, 1 | ||
ret i1 %3 | ||
|
||
; Multiply, return if the high byte is zero | ||
; | ||
; CHECK: mul r{{[0-9]+}}, r{{[0-9]+}} | ||
; CHECK: mov [[HIGH:r[0-9]+]], r1 | ||
; CHECK: ldi [[RET:r[0-9]+]], 1 | ||
; CHECK: cpi {{.*}}[[HIGH]], 0 | ||
; CHECK: brne [[LABEL:LBB[_0-9]+]] | ||
; CHECK: ldi {{.*}}[[RET]], 0 | ||
; CHECK: {{.*}}[[LABEL]] | ||
; CHECK: ret | ||
} | ||
|
||
declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to add
CHECK
andCHECK-NEXT
lines to make sure the correct sequence of instructions is generated? Just something basic would suffice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit more involved than unsigned. What shape of tests would you like to see here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this would be good (with patterns instead of registers):
Of course, don't worry about any calling convention or prologue/epilogue junk.
Same with the other test btw