search for: ispow2

Displaying 8 results from an estimated 8 matches for "ispow2".

2017 Sep 13
2
How to add optimizations to InstCombine correctly?
...should replace the original Instruction in the Worklist. However, I end up in an infinite loop and the Instruction I try to replace gets scheduled again and again. What is wrong 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, Mi...
2017 Sep 13
3
How to add optimizations to InstCombine correctly?
...t;> However, I end up in an infinite loop and the Instruction I try to >> replace gets scheduled again and again. What is wrong 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 : &g...
2017 Sep 14
3
How to add optimizations to InstCombine correctly?
...try to > replace gets scheduled again and again. What is wrong 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...
2017 Sep 16
2
How to add optimizations to InstCombine correctly?
...replace gets scheduled again and again. What is wrong 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()); > >...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...gt; wrong 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 = Builde...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...gt; wrong 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 = Builde...
2017 Sep 19
5
How to add optimizations to InstCombine correctly?
...gt; > 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; > >> >...
2014 May 18
1
[PATCH 1/2] nv50/ir: fix s32 x s32 -> high s32 multiply logic
Retrieving the high 32 bits of a signed multiply is rather annoying. It appears that the simplest way to do this is to compute the absolute value of the arguments, and perform a u32 x u32 -> u64 operation. If the arguments' signs differ, then negate the result. Since there is no u64 support in the cvt instruction, we have the perform the 2's complement negation "by hand".