[llvm] [InstCombine] Simplify zext(sub(0, trunc(x))) -> and(sub(0, x), mask) (Fixes #165306) (PR #167101)
V S Susi Krishna via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 8 05:16:03 PST 2025
Susikrishna wrote:
You were right about the scalar case, it worked when I kept the datalayout.
Like RKSimon mentioned, when I run the test (even with the datalayout), my output shows that:
@foo (which uses <2 x i64>)
@bar (which uses <4 x i64>)
@baz (which uses <8 x i64>) ...are all still not being simplified.
I think I found the reason for the difference. I was looking at the shouldChangeType function, and the Type* version has this check at the very top:
C++
```
bool InstCombinerImpl::shouldChangeType(Type *From, Type *To) const {
if (!From->isIntegerTy() || !To->isIntegerTy())
return false;
...
}
```
This check returns false for all vector types, so the canEvaluateZExtd path is never reached for them (but it is reached for the scalar i6 type).
https://github.com/llvm/llvm-project/pull/167101
More information about the llvm-commits
mailing list