[PATCH] D117184: Fix failing assertion in SimplifyCFG.cpp as icmp gep fold to constant expression [NFC]

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 08:34:55 PST 2022


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5808-5809
                                                 ValuePair.second, CmpOp1, true);
     if (!CaseConst || CaseConst == DefaultConst || isa<UndefValue>(CaseConst))
       return;
   }
----------------
I think this should be something like:
```
if (!CaseConst || CaseConst == DefaultConst ||
    (CaseConst != TrueConst && CaseConst != FalseConst))
  return; 
```
If we don't get back true or false, we don't assume which way the comparison goes.


================
Comment at: llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-globals.ll:10
+; CHECK:  [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x %struct.ham*], [3 x %struct.ham*]* @switch.table.zot, i32 0, i32 %arg
+; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load %struct.ham*, %struct.ham** [[SWITCH_GEP]], align 8
+
----------------
Can you please use `update_test_checks.py` instead?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117184/new/

https://reviews.llvm.org/D117184



More information about the llvm-commits mailing list