https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115138

--- Comment #18 from Iain Buclaw <ibuclaw at gcc dot gnu.org> ---
Reduction of opover.d
```
bool __setArrayAllocLength(size_t newLength)
{
    import core.checkedint;
    bool overflow;
    addu(newLength,
         addu(0, 0, overflow),
         overflow);

    return true;
}

enum EXP
{
    greaterOrEqual,
    greaterThan,
    lessOrEqual,
    lessThan,
}

EXP reverseRelation(EXP op)
{
    switch (op)
    {
        case EXP.greaterOrEqual:  op = EXP.lessOrEqual;    break;
        case EXP.greaterThan:     op = EXP.lessThan;       break;
        case EXP.lessOrEqual:     op = EXP.greaterOrEqual; break;
        default:                  break;
    }
    return op;
}
```


Running (from the build directory)
```
./stage1-gcc/gdc -B ./stage1-gcc/ -c -O2 -g -fversion=IN_GCC \
   -I ./stage1-x86_64-pc-linux-gnu/libphobos/libdruntime \
   -I ../../libphobos/libdruntime -I ../../gcc/d/ \
   -J ../../gcc/d/dmd -J ../../gcc/d/dmd/res opover.d -o opover-1.o

../stage2-gcc/gdc -B ../stage2-gcc/ -c -O2 -g -fversion=IN_GCC \
   -I ../stage2-x86_64-pc-linux-gnu/libphobos/libdruntime \
   -I ../../libphobos/libdruntime -I ../../gcc/d/ \
   -J ../../gcc/d/dmd -J ../../gcc/d/dmd/res opover.d -o opover-2.o

cmp --ignore-initial=16 opover-1.o opover-2.o
```


Also observed from assembly output
```
--- opover-1.s  2024-05-22 19:10:36.315939819 +0200
+++ opover-2.s  2024-05-22 19:10:28.763819758 +0200
@@ -29,7 +29,7 @@ _D6opover15reverseRelationFEQBa3EXPZQj:
        movl    %edi, %eax
        cmpl    $2, %eax
        ja      .L5
-       leaq    CSWTCH.8(%rip), %rdx
+       leaq    CSWTCH.9(%rip), %rdx
        movl    (%rdx,%rax,4), %eax
 .L5:
 .LVL2:
@@ -123,9 +123,9 @@ gdc.dso_dtor:
        .quad   gdc.dso_dtor
        .section        .rodata
        .align 8
-       .type   CSWTCH.8, @object
-       .size   CSWTCH.8, 12
-CSWTCH.8:
+       .type   CSWTCH.9, @object
+       .size   CSWTCH.9, 12
+CSWTCH.9:
        .long   2
        .long   3
        .long   0
```

Reply via email to