<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58402>58402</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            timeout:infinite recursion in ScalarEvolution -O3
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          younglx643
      </td>
    </tr>
</table>

<pre>
    It seems cause infinite recursion when use -O3.
godbolt: https://godbolt.org/z/ej1jEsT6W

sourcecode:
```
#include <stdint.h>
int a() {
  int b, c;
  uint32_t d;
  for (;;)
    if (d + (d = 0 >= b)) {
      b = 3;
      for (; b <= 58; b++) {
        uint32_t *e = &d;
        *e += ((c || b) & d ^ (0 || 4)) + 3;
      }
    }
  return 0;
}
```
gdb backtrace:
```
#0  llvm::cast<llvm::SCEVConstant, llvm::SCEV const> (Val=0x555555968310)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Support/Casting.h:268
#1  0x00007ffff38e9c15 in llvm::SCEV::getType (this=<optimized out>)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:385
#2  0x00007ffff3904a1c in llvm::ScalarEvolution::getZeroExtendExpr (this=this@entry=0x555555931580, Op=0x555555968310, Ty=Ty@entry=0x555555603030,
    Depth=Depth@entry=0) at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:1537
#3  0x00007ffff3917554 in llvm::ScalarEvolution::getUDivExpr (this=this@entry=0x555555931580, LHS=<optimized out>, RHS=RHS@entry=0x555555962970)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:3208
#4  0x00007ffff3904ea1 in llvm::ScalarEvolution::getZeroExtendExpr (this=0x555555931580, Op=<optimized out>, Ty=0x555555603010, Depth=2)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:315
#5  0x00007ffff3904ae8 in llvm::ScalarEvolution::getZeroExtendExpr (this=0x555555931580, Op=0x55555598bba0, Ty=0x555555603010, Depth=1)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:84
#6  0x00007ffff3905455 in llvm::ScalarEvolution::getZeroExtendExpr (this=this@entry=0x555555931580, Op=Op@entry=0x55555598bc00, Ty=Ty@entry=0x555555603010,
    Depth=Depth@entry=0) at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:1796
#7  0x00007ffff3917477 in llvm::ScalarEvolution::getUDivExpr (this=0x555555931580, LHS=<optimized out>, RHS=<optimized out>)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:3177
#8  0x00007ffff3917907 in llvm::ScalarEvolution::getUDivExpr (this=this@entry=0x555555931580, LHS=<optimized out>, RHS=RHS@entry=0x5555559682d0)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:201
#9  0x00007ffff3904ea1 in llvm::ScalarEvolution::getZeroExtendExpr (this=0x555555931580, Op=<optimized out>, Ty=0x555555602ff0, Depth=3)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:315
#10 0x00007ffff3904ae8 in llvm::ScalarEvolution::getZeroExtendExpr (this=0x555555931580, Op=0x55555598bf40, Ty=0x555555602ff0, Depth=2)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:84
#11 0x00007ffff3905455 in llvm::ScalarEvolution::getZeroExtendExpr (this=0x555555931580, Op=<optimized out>, Ty=0x555555602ff0, Depth=1)
    at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:1796
#12 0x00007ffff3904fca in llvm::ScalarEvolution::getZeroExtendExpr (this=this@entry=0x555555931580, Op=Op@entry=0x55555598c000, Ty=Ty@entry=0x555555602ff0,
    Depth=Depth@entry=0) at /home/ylx/project_retargetabl/branch_test/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:1763

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNWN1vozgQ_2vIi7WRP_gwDzykJNWddNJK196udC-VbZyEHgEEppvsX39jSAkh6V2ut9mGUoNnxuOZ34xnWmSR7KJfDaq13tRIiabWKM2XaZ4ajSqtmqpOixx9W-scWd6nz2zq4LmDZ6sikUVmHDZDa2PKGl4ceg_3njEtqhXMvsOvfibPi_rR_9qt7Ma6aCqlVZFou7Jj-Hh_d1PK0lxlTaKRw-LaJGlupmuHLTo2zJBwKHdoiJzgriMiZMnSoTFSDuuJDVAZfTIoGRCXRYXseqDATcNXOuhYWkYCw93-hc0RRnZreJFW9nhTe8lWig02sNdhk1YgtjJeNwXt7X2iaWCvQ2e61etQPxmpRnsu6GgFAAmuQFcMd2ukXYTAeG9hufiV5b7aD96NzXWC-WE6mFTaNFWOcC_e80ZBWyUSSaH-MpVQ_xRZjFCWvWysBJspUUMixQfCQ7z4Ehd5bURubCyPOUhZFkTDuvVFZOA-3nrtFfqcEXwUTGFRvF8XGw2PXbaFsayKZ63ME3glqhUMMgOqrESu1k9Gg256b7f8tBfcT-GxT8gD4aEpy6KyEjE4keYrm6Ez6vPeU4IQ3mK4giVcjOtQEQ_SdORU9wbGPO5KG1Ru1ikcqjngUpQm3aTfdYKKxrp9PfeyFPLmfpaLbFfD7uCeEpmoFi9F1hgoBFNVlmAl417vHj12L8SuIGrk3rGS3tM_dVUstkbnyWJbVgOf24eLdW6q3TC4jHgc23z4XJ6JeYwerTQMp0t9zOAHZA7AzXVpIFbz7jlYYs_GR6BKPBb0sLIRrCTwPPcyWP-Ypy__FdDffnl4K9di9HvLtOMZFT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