Hi, I'm trying to cast one of the SCEV node to "SCEVAddRecExpr". Every time cast return NULL, and I'm unable to do this. SCEV Node: ((4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw> + %var)<nsw> Casting: const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEVNode); 'var' is of type float pointer (float*). Without 'sext' it works, but I'm wondering why it not working in above case. I'm not sure, is such casting allowed ? Regards, Ashutosh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150319/e7c2d65e/attachment.html>
Nema, Ashutosh wrote:> Hi, > I’m trying to cast one of the SCEV node to “SCEVAddRecExpr”. > Every time cast return NULL, and I’m unable to do this. > SCEV Node: > ((4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw> + %var)<nsw> > Casting: > const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEVNode); > ‘var’ is of type float pointer (float*). > Without ‘sext’ it works, but I’m wondering why it not working in above case. > I’m not sure, is such casting allowed ?It looks like your node is a SCEVAddExpr whose LHS is "(4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw>" and RHS is "%var", instead of a SCEVAddRecExpr. Perhaps if the sext weren't there SCEV might simplify the whole thing to a single SCEVAddRecExpr. Can you cast your node to a SCEVAddExpr, then dyn_cast<SCEVAddRecExpr>(AddExpr->getOperand(0))? Note that SCEV does not handle floats as anything but completely opaque values. Nick
Hi Nick, Thanks for looking into it. I have tried that as well but it didn't worked. "AddExpr->getOperand(0))" node is: " (4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw>" When I cast this to "SCEVAddRecExpr" it returns NULL. Regards, Ashutosh -----Original Message----- From: Nick Lewycky [mailto:nicholas at mxc.ca] Sent: Thursday, March 19, 2015 12:19 PM To: Nema, Ashutosh Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Cast to SCEVAddRecExpr Nema, Ashutosh wrote:> Hi, > I'm trying to cast one of the SCEV node to "SCEVAddRecExpr". > Every time cast return NULL, and I'm unable to do this. > SCEV Node: > ((4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw> + %var)<nsw> > Casting: > const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEVNode); > 'var' is of type float pointer (float*). > Without 'sext' it works, but I'm wondering why it not working in above case. > I'm not sure, is such casting allowed ?It looks like your node is a SCEVAddExpr whose LHS is "(4 * (sext i32 {2,+,2}<%for.body4> to i64))<nsw>" and RHS is "%var", instead of a SCEVAddRecExpr. Perhaps if the sext weren't there SCEV might simplify the whole thing to a single SCEVAddRecExpr. Can you cast your node to a SCEVAddExpr, then dyn_cast<SCEVAddRecExpr>(AddExpr->getOperand(0))? Note that SCEV does not handle floats as anything but completely opaque values. Nick