Issue |
131053
|
Summary |
Missed Optimization: bswap in big endian
|
Labels |
llvm:optimizations,
missed-optimization
|
Assignees |
|
Reporter |
hstk30-hw
|
https://godbolt.org/z/f4x9aoax6
```
typedef unsigned int UINT32;
typedef signed short INT16;
typedef unsigned short UINT16;
typedef unsigned char UINT8;
typedef unsigned long int UINT64;
typedef struct {
UINT16 coma;
UINT16 comb;
} Stru;
extern Stru *g_Ptr;
UINT32 CheckFrmAndSlot(int *a)
{
UINT16 coma = g_Ptr->coma;
if (coma == 100) {
return 0;
}
return ((UINT32)coma << 16) | g_Ptr->comb;
}
```
Current llvm output :
```
CheckFrmAndSlot:
adrp x8, :got:g_Ptr
ldr x8, [x8, :got_lo12:g_Ptr]
ldr x8, [x8]
ldrh w9, [x8]
cmp w9, #100
b.ne .LBB0_2
mov w0, wzr
ret
.LBB0_2:
ldrh w8, [x8, #2]
orr w0, w8, w9, lsl #16
ret
```
expected like gcc, it equals `((UINT32)coma << 16) | g_Ptr->comb == (*(UINT32*)g_Ptr)` in bswap pass
```
CheckFrmAndSlot:
adrp x1, g_Ptr
mov w0, 0
ldr x1, [x1, #:lo12:g_Ptr]
ldrh w2, [x1]
cmp w2, 100
beq .L1
ldr w0, [x1]
.L1:
ret
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs