-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[InstCombine][VectorCombine][NFC] Unify uses of lossless inverse cast #156597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e279282
3bc3ce2
1b9aa50
fe59e8b
14a4e42
f774ff8
3b60666
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1799,16 +1799,19 @@ static Instruction *foldLogicCastConstant(BinaryOperator &Logic, CastInst *Cast, | |
| // type may provide more information to later folds, and the smaller logic | ||
| // instruction may be cheaper (particularly in the case of vectors). | ||
| Value *X; | ||
| auto &DL = IC.getDataLayout(); | ||
| if (match(Cast, m_OneUse(m_ZExt(m_Value(X))))) { | ||
| if (Constant *TruncC = IC.getLosslessUnsignedTrunc(C, SrcTy)) { | ||
| if (Constant *TruncC = | ||
| getLosslessInvCast(C, SrcTy, Instruction::ZExt, DL)) { | ||
|
||
| // LogicOpc (zext X), C --> zext (LogicOpc X, C) | ||
| Value *NewOp = IC.Builder.CreateBinOp(LogicOpc, X, TruncC); | ||
| return new ZExtInst(NewOp, DestTy); | ||
| } | ||
| } | ||
|
|
||
| if (match(Cast, m_OneUse(m_SExtLike(m_Value(X))))) { | ||
| if (Constant *TruncC = IC.getLosslessSignedTrunc(C, SrcTy)) { | ||
| if (Constant *TruncC = | ||
| getLosslessInvCast(C, SrcTy, Instruction::SExt, DL)) { | ||
| // LogicOpc (sext X), C --> sext (LogicOpc X, C) | ||
| Value *NewOp = IC.Builder.CreateBinOp(LogicOpc, X, TruncC); | ||
| return new SExtInst(NewOp, DestTy); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CastOp(InvC) == Cis imprecise (e.g.,bitcast <2 x i16> <i16 0, i16 poison> to i32is refined to 0).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. What about
CastOp(InvC) == C or CastOp(InvC) is one of the possible values of C if C is undefined