Displaying 7 results from an estimated 7 matches for "logbase2".
2017 Sep 13
2
How to add optimizations to InstCombine correctly?
...rong in my code?
// Replace X * (2^C+/-1) with (X << C) -/+ X
APInt Plus1 = *IVal + 1;
APInt Minus1 = *IVal - 1;
int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0;
if (isPow2) {
APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub :
BinaryOperator::Add, Shl, Op0);
}
Thanks,
Michael
2017 Sep 13
3
How to add optimizations to InstCombine correctly?
...-/+ X
>> APInt Plus1 = *IVal + 1;
>> APInt Minus1 = *IVal - 1;
>> int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ? -1 : 0;
>>
>> if (isPow2) {
>> APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
>> return BinaryOperator::Create(isPow2 > 0 ? BinaryOperator::Sub :
>> BinaryOperator::Add, Shl, Op0);
>> }
>>
>> Thanks,
>> Michael
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at list...
2017 Sep 14
3
How to add optimizations to InstCombine correctly?
...APInt Minus1 = *IVal - 1;
> int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ?
> -1 : 0;
>
> if (isPow2) {
> APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
> Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
> return BinaryOperator::Create(isPow2 > 0 ?
> BinaryOperator::Sub :
> BinaryOperator::Add, Shl, Op0);
> }
>
> Thanks,
> Michael
> _______________________________________________...
2017 Sep 16
2
How to add optimizations to InstCombine correctly?
...gt; > int isPow2 = Plus1.isPowerOf2() ? 1 : Minus1.isPowerOf2() ?
> > -1 : 0;
> >
> > if (isPow2) {
> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
> > Value *Shl = Builder.CreateShl(Op0, Pow2.logBase2());
> > return BinaryOperator::Create(isPow2 > 0 ?
> > BinaryOperator::Sub :
> > BinaryOperator::Add, Shl, Op0);
> > }
> >
> > Thanks,
> > Michael
-------------- next part -----...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...; Minus1.isPowerOf2() ?
>> > -1 : 0;
>> >
>> > if (isPow2) {
>> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> > Value *Shl = Builder.CreateShl(Op0,
>> Pow2.logBase2());
>> > return BinaryOperator::Create(isPow2 > 0 ?
>> > BinaryOperator::Sub :
>> > BinaryOperator::Add, Shl, Op0);
>> > }
>> >
>> > Thanks,
>>...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...; Minus1.isPowerOf2() ?
>> > -1 : 0;
>> >
>> > if (isPow2) {
>> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
>> > Value *Shl = Builder.CreateShl(Op0,
>> Pow2.logBase2());
>> > return BinaryOperator::Create(isPow2 > 0 ?
>> > BinaryOperator::Sub :
>> > BinaryOperator::Add, Shl, Op0);
>> > }
>> >
>> > Thanks,
>>...
2017 Sep 19
5
How to add optimizations to InstCombine correctly?
...t; >> > -1 : 0;
> >> >
> >> > if (isPow2) {
> >> > APInt &Pow2 = isPow2 > 0 ? Plus1 : Minus1;
> >> > Value *Shl = Builder.CreateShl(Op0,
> >> Pow2.logBase2());
> >> > return BinaryOperator::Create(isPow2 > 0 ?
> >> > BinaryOperator::Sub :
> >> > BinaryOperator::Add, Shl, Op0);
> >> > }
> >> >
> >> >...