[llvm-commits] [llvm] r57226 - in /llvm/trunk: include/llvm/Intrinsics.td include/llvm/IntrinsicsAlpha.td lib/Target/Alpha/AlphaISelDAGToDAG.cpp lib/Target/Alpha/AlphaISelLowering.cpp

Chris Lattner clattner at apple.com
Tue Oct 7 23:25:11 PDT 2008


On Oct 6, 2008, at 10:27 PM, Andrew Lenharth wrote:

> On Mon, Oct 6, 2008 at 11:04 PM, Chris Lattner <clattner at apple.com>  
> wrote:
>>
>> On Oct 6, 2008, at 7:10 PM, Andrew Lenharth wrote:
>>
>>> Author: alenhar2
>>> Date: Mon Oct  6 21:10:26 2008
>>> New Revision: 57226
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=57226&view=rev
>>> Log:
>>> Note that ADDC and company don't actually expand yet (missing in  
>>> legalize
>>
>> Hi Andrew,
>>
>> __builtin_alpha_umulh can be represented with generic LLVM IR (zext  
>> to i128,
>> multiply, shr by 64, truncate to i64).  You should get good code  
>> for that
>> sequence already, if not, that's a bug.
>>
>> Can you just have llvm-gcc expand the builtin like we do for other  
>> builtins
>> supported by LLVM IR?
>
> I was thinking of doing that, but I hadn't tried to see what kind of
> code I got for it.

We have the ability to write unit tests for this sort of thing :)

$ cat t.ll
define i64 @test(i64 %in1, i64 %in2) {
	%t = zext i64 %in1 to i128
	%s = zext i64 %in2 to i128
	%u = mul i128 %t, %s
	%v = lshr i128 %u, 64
	%q = trunc i128 %v to i64
	ret i64 %q
}
$ llvm-as < t.ll | llc -march=alpha
...
test:
	ldah $29,0($27)		!gpdisp!1
	lda $29,0($29)		!gpdisp!1
	$test..ng:

	umulh $16,$17,$0
	ret $31,($26),1
	.end test

I'm no alpha guru, but that looks pretty good to me,

-Chris




More information about the llvm-commits mailing list