[llvm] [InstCombine] Try optimizing with knownbits which determined from Cond (PR #91762)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 15 09:30:38 PDT 2024
ParkHanbum wrote:
this is why test failed in windows.
```
================
[this have problem with cl.exe but not clang]
unsigned CmpLHSOpc;
bool IsDisjoint = false;
// Specially handling for X^Y==0 transformed to X==Y
if (match(TVal, m_c_BitwiseLogic(m_Specific(CmpLHS), m_Specific(CmpRHS)))) {
X = CmpLHS;
Y = CmpRHS;
>>>>>>>>>>>
APInt ZeroVal = APInt::getZero(CmpLHS->getType()->getScalarSizeInBits());
C = const_cast<APInt *>(&ZeroVal);
================
[this have not a problem]
unsigned CmpLHSOpc;
bool IsDisjoint = false;
APInt ZeroVal;
// Specially handling for X^Y==0 transformed to X==Y
if (match(TVal, m_c_BitwiseLogic(m_Specific(CmpLHS), m_Specific(CmpRHS)))) {
X = CmpLHS;
Y = CmpRHS;
>>>>>>>>>>>
ZeroVal = APInt::getZero(CmpLHS->getType()->getScalarSizeInBits());
C = const_cast<APInt *>(&ZeroVal);
```
I declare ZeroVal in if-match block, but used its reference after off the block.
window compiler didn't allow this, I could see garbage value was setted in `C` through debug message.
```
APInt(32b, 1616897802336u 1990099040s)
```
it obviouly my mistake.
but clang seems allow this as roughly.
how do you think?
https://github.com/llvm/llvm-project/pull/91762
More information about the llvm-commits
mailing list