<div dir="ltr"><div dir="ltr"><div dir="ltr">Given this IR:<div><br></div><div><div>  %4 = getelementptr inbounds %LMtop.IRType, %LMtop.IRType* %3, i32 0, i32 8</div><div>  %5 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %4, i32 0, i32 0</div><div>  %6 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %4, i32 0, i32 1</div><div>  %7 = load i8, i8* %5, align 8</div><div>  %8 = load i8, i8* %6, align 1</div><div>  %9 = getelementptr inbounds %LMtop.IRType, %LMtop.IRType* %3, i32 0, i32 9</div><div>  %10 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %9, i32 0, i32 0</div><div>  %11 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %9, i32 0, i32 1</div><div>  %12 = load i8, i8* %10, align 2</div><div>  %13 = load i8, i8* %11, align 1</div><div>  %14 = getelementptr inbounds %LMtop.IRType, %LMtop.IRType* %3, i32 0, i32 10</div><div>  %15 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %14, i32 0, i32 0</div><div>  %16 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %14, i32 0, i32 1</div><div>  %17 = load i8, i8* %15, align 4</div><div>  %18 = load i8, i8* %16, align 1</div><div>  %19 = or i8 %13, %18</div><div>  %20 = add i8 %12, %17</div><div>  %21 = or i8 %8, %19</div><div>  %22 = add i8 %7, %20</div><div>  %23 = icmp ne i8 %21, 0</div><div>  %24 = select i1 %23, i8 -1, i8 %22</div><div>  %25 = select i1 %23, i8 -1, i8 0</div><div>  %26 = and i8 %24, 15</div><div>  %27 = and i8 %25, 15</div><div>  %28 = getelementptr inbounds %LMtop.IRType, %LMtop.IRType* %3, i32 0, i32 11</div><div>  %29 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %28, i32 0, i32 0</div><div>  %30 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %28, i32 0, i32 1</div><div>  store i8 %26, i8* %29, align 2</div><div>  store i8 %27, i8* %30, align 1</div></div><div><br></div><div><br></div><div>LLVM 7.0.0 produces the following x86_64 code:</div><div><br></div><div><div>    86c8:       8a 88 02 01 00 00       mov    0x102(%rax),%cl</div><div>    86ce:       8a 90 03 01 00 00       mov    0x103(%rax),%dl</div><div>    86d4:       0a 90 01 01 00 00       or     0x101(%rax),%dl</div><div>    86da:       02 88 00 01 00 00       add    0x100(%rax),%cl</div><div>    86e0:       02 88 04 01 00 00       add    0x104(%rax),%cl</div><div>    86e6:       80 e1 0f                and    $0xf,%cl</div><div>    86e9:       0a 90 05 01 00 00       or     0x105(%rax),%dl</div><div>    86ef:       40 b6 0f                mov    $0xf,%sil</div><div>    86f2:       b2 0f                   mov    $0xf,%dl</div><div>    86f4:       75 02                   jne    86f8 <LMtop.W0+0x38></div><div>    86f6:       89 ca                   mov    %ecx,%edx</div><div>    86f8:       75 02                   jne    86fc <LMtop.W0+0x3c></div><div>    86fa:       31 f6                   xor    %esi,%esi</div><div>    86fc:       88 90 06 01 00 00       mov    %dl,0x106(%rax)</div><div>    8702:       40 88 b0 07 01 00 00    mov    %sil,0x107(%rax)</div></div><div><br></div><div>Note how the branch at 0x86f4 targets another branch on the same condition. Practically, the branch at 0x86f8 is redundant as it can never be taken.  It ought to be removed, and the branch at 0x86f4 ought to target 0x86fc.</div><div><br></div><div>1. Is this a known issue?   I couldn't find anything obvious in Bugzilla.</div><div>2. Would it be better for me to use branches and phi whenever I knowingly want to do more than one select with the exact same condition?</div><div><br></div></div></div></div>