It's always safe to pick the earlier abs regardless of the nsw flag. We'll just lose it if it is on the outer abs but not the inner abs.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Yeah its called from visitUnaryIntrinsic. This intrinsic is binary because of the nsw argument. I could add it to IsIdempotentand add another call to isIdempotent to the top of visitBinaryIntrinsic, but I thought with the oddity of nsw handling abs directly might be more clear.
Comment Actions
LG. This has some overlap with D85043, which will already catch the cases where the inner abs has poison=true, but not those with poison=false, so this seems reasonable as an explicit fold. One could make an argument that this should live in InstCombine and try to preserve the outer poison flag, but this doesn't seem particularly important to me.
Comment Actions
Will need update after:
rG04b99a4d18cf
llvm/lib/Analysis/InstructionSimplify.cpp | ||
---|---|---|
5262 | Could use match here to make this slightly more obvious: if (match(Op0, m_Intrinsic<Intrinsic::abs>(m_Value(), m_Value()))) return Op0; |
Could use match here to make this slightly more obvious: