search for: createshl

Displaying 15 results from an estimated 15 matches for "createshl".

2013 Aug 22
2
[LLVMdev] Crash in CreateShl() method
Hi All, AllocaInst * AI = builder.CreateAlloca(type, 0, BBName); StoreInst* ST= builderTF.CreateStore(ConstantInt::get(type,1),AI); Value * Vresult = (Value*)ST; Vresult = builderWait.CreateShl(Vresult, 1); I need to make one bit shift left to the variable stored in the second step I've got crash in this step opt: /home/xx/llvm2/llvm/include/llvm/Support/Casting.h:237: typename enable_if<is_same<Y, typename simplify_type<Y>::SimpleType>, typename cast_retty<X, Y *...
2013 Aug 22
0
[LLVMdev] Crash in CreateShl() method
> How could this crash be fixed? What you've basically written is: %AI = alloca i32 %Vresult = store i32 1, i32* %AI %res = shl i32 %Vresult, 1 The problem is that stores don't produce values that can be used elsewhere (they have type "void"). If you want to shift a variable like "AI" in LLVM you have to load it, do the shift and then store it again.
2011 Sep 22
2
[LLVMdev] Need help in converting int to double
On Thu, Sep 22, 2011 at 3:46 PM, sarath chandra <sarathcse19 at gmail.com>wrote: > Hi James, > > First i converted the void * to int* and then did FPToSI...then did SHL...( > because CreateShl only accepts integers... i pointer casted it to int64 type > first)... Below is the code snippet.... > > > lhs = mBuilder.CreateStructGEP(firstArg, 0); > lhs = mBuilder.CreateLoad(lhs); > lhs = mBuilder.CreatePointerCast(lhs, PointerType::get( > mBuilder.get...
2011 Sep 22
3
[LLVMdev] Need help in converting int to double
...M as a back-end". Now i'm writing code for shift left(SHL) operator. I had my own Value Structure .. it's like this Struct Value { void *val ; char type; } The "char type" holds DoubleType,DoubleConst,StringType,StringConst... when i'm executing the IrBuilder.CreateShl(LHS,RHS) instruction it is returning an integer value as output.. i'm unable to store the value in my structure....(because my structure can hold Doubles,Strings). Is there any way to store the integer output in my structure( i used CreateSIToFP() to change int to double)........ Thanks in...
2011 Sep 22
0
[LLVMdev] Need help in converting int to double
...at cs.uiuc.edu Subject: Re: [LLVMdev] Need help in converting int to double On Thu, Sep 22, 2011 at 3:46 PM, sarath chandra <sarathcse19 at gmail.com<mailto:sarathcse19 at gmail.com>> wrote: Hi James, First i converted the void * to int* and then did FPToSI...then did SHL...( because CreateShl only accepts integers... i pointer casted it to int64 type first)... Below is the code snippet.... lhs = mBuilder.CreateStructGEP(firstArg, 0); lhs = mBuilder.CreateLoad(lhs); lhs = mBuilder.CreatePointerCast(lhs, PointerType::get( mBuilder.getInt64Ty(), 0)); int typelhs =...
2011 Sep 22
1
[LLVMdev] Need help in converting int to double
...eed help in converting int to double**** > > ** ** > > ** ** > > On Thu, Sep 22, 2011 at 3:46 PM, sarath chandra <sarathcse19 at gmail.com> > wrote:**** > > Hi James, > > First i converted the void * to int* and then did FPToSI...then did SHL...( > because CreateShl only accepts integers... i pointer casted it to int64 type > first)... Below is the code snippet.... > > > lhs = mBuilder.CreateStructGEP(firstArg, 0); > lhs = mBuilder.CreateLoad(lhs); > lhs = mBuilder.CreatePointerCast(lhs, PointerType::get( > mBuilder.get...
2017 Sep 13
2
How to add optimizations to InstCombine correctly?
...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, Michael
2011 Sep 22
0
[LLVMdev] FW: Need help in converting int to double
...M) as a double*. Hopefully this makes sense, especially if you know how you would have to do it in C. Cheers, James From: sarath chandra [mailto:sarathcse19 at gmail.com] Sent: 22 September 2011 10:49 To: James Molloy Subject: Re: [LLVMdev] Need help in converting int to double Hi James, CreateShl() accepts only integers or vectors as arguments. At the starting my arguments , let us suppose LHS,RHS, are double values. To pass them as arguments to CreateShl(), i used Pointer Casting to convert the Void* to Int*. Now the problem is after getting the result is, the result variable which capture...
2017 Sep 13
3
How to add optimizations to InstCombine correctly?
...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 >> _______________________________________________ >> LLVM Developers mailing list >&g...
2017 Sep 14
3
How to add optimizations to InstCombine correctly?
...+ 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 16
2
How to add optimizations to InstCombine correctly?
...inus1 = *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 19
0
How to add optimizations to InstCombine correctly?
...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); >> > } >> > >> >...
2017 Sep 19
0
How to add optimizations to InstCombine correctly?
...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); >> > } >> > >> >...
2015 Apr 06
2
[LLVMdev] inconsistent wording in the LangRef regarding "shl nsw"
The LangRef says this for left shifts: "If the nsw keyword is present, then the shift produces a poison value if it shifts out any bits that disagree with the resultant sign bit." ... (1) followed by "As such, NUW/NSW have the same semantics as they would if the shift were expressed as a mul instruction with the same nsw/nuw bits in (mul %op1, (shl 1, %op2))." ... (2) But
2017 Sep 19
5
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); > >> > } > >&gt...