[PATCH] D63382: [InstCombine] fold a shifted zext to a select
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 16 01:12:33 PDT 2019
lebedev.ri added a comment.
Don't know if this is the canonicalization we want, but some notes
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:600
+ // shl (zext (i1 X)), ShAmt --> select (X, 0, 1 << ShAmt)
+ if (X->getType()->isIntegerTy(1)) {
+ return SelectInst::Create(X, ConstantInt::get(Ty, 1 << ShAmt),
----------------
vectors of i1 too (`isIntOrIntVectorTy(1)`)
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:601
+ if (X->getType()->isIntegerTy(1)) {
+ return SelectInst::Create(X, ConstantInt::get(Ty, 1 << ShAmt),
+ ConstantInt::get(Ty, 0));
----------------
this will overflow, you want
```
ConstantInt::get(Ty, APInt(Ty->getScalarType()->getBitWidth(), 1) << ShAmt)
```
or something
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63382/new/
https://reviews.llvm.org/D63382
More information about the llvm-commits
mailing list